![](/img/trans.png)
[英]Xcode Cloud build from Flutter project unable to find included file 'Generated.xcconfig' in search paths
[英]Flutter iOS build on the App Center fails with error: "Invalid Podfile file: Generated.xcconfig must exist
我剛剛按照此處的文章將我的應用程序設置為在 App Center 上構建。
盡管 Android 版本在 App Center 上構建和部署良好,但我在 iOS 構建時遇到錯誤,如下面的構建 output 摘錄所示:
==============================================================================
Task : CocoaPods
Description : Install CocoaPods dependencies for Swift and Objective-C Cocoa projects
Version : 0.151.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/cocoapods
==============================================================================
[command]/usr/local/lib/ruby/gems/2.6.0/bin/pod --version
1.9.1
[command]/usr/local/lib/ruby/gems/2.6.0/bin/pod install --repo-update
[!] Invalid `Podfile` file: Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first.
# from /Users/runner/runners/2.165.2/work/1/s/bdstories/ios/Podfile:51
# -------------------------------------------
# unless File.exist?(generated_xcode_build_settings_path)
> raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
# end
# -------------------------------------------
##[error]The process '/usr/local/lib/ruby/gems/2.6.0/bin/pod' failed with exit code 1
##[error]The 'pod' command failed with error: The process '/usr/local/lib/ruby/gems/2.6.0/bin/pod' failed with exit code 1
##[section]Finishing: Pod install
##[section]Starting: Xcode build (signed)
我的構建腳本是:
#!/usr/bin/env bash
# Place this script in project/ios/.
# Fail if any command fails.
set -e
# Debug log.
set -x
cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
flutter channel beta
flutter doctor
echo "Installed flutter to `pwd`/flutter"
# Build the app.
flutter build ios --release --no-codesign
我確實按照錯誤中的說明添加了flutter pub get
,但這並沒有什么不同。 還值得注意的是,當我在本地 Xcode 中構建時,構建工作正常。 我也可以毫無問題地將構建的存檔部署到 Testflight。 這只是我遇到問題的 App Center 構建過程。
我現在有點迷路了,我找不到任何關於如何解決這個問題的信息。 我也是 CI/CD 的新手,所以感謝您的幫助!
更新
我還嘗試將以下內容添加到腳本中以強制 App Center 運行與我的本地計算機相同版本的 Cocoapods,但這對錯誤沒有影響。
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.9.1
pod setup
我對我的克隆后腳本做了這個,它起作用了:
#!/usr/bin/env bash
#Place this script in project/ios/
echo "Uninstalling all CocoaPods versions"
sudo gem uninstall cocoapods --all --executables
COCOAPODS_VER=`sed -n -e 's/^COCOAPODS: \([0-9.]*\)/\1/p' Podfile.lock`
echo "Installing CocoaPods version $COCOAPODS_VER"
sudo gem install cocoapods -v $COCOAPODS_VER
# fail if any command fails
set -e
# debug log
set -x
pod setup
cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
flutter channel master
flutter doctor
flutter pub get
echo "Installed flutter to `pwd`/flutter"
flutter build ios --release --no-codesign
訣竅似乎是將“如果任何命令失敗則失敗”部分移至重新安裝 pod 之后
檢查您的 .gitIgnore。 由於文件被從 repo 中排除,因此遇到了同樣的問題。
一旦添加回來,一切都很好。
還要注意項目中為 Flutter 定義的 Paths。
我遇到過同樣的問題。 它發生在 appcenter-post-clone.sh 無法運行時,因此,未安裝flutter build ios
並且命令flutter build ios
未運行以生成Generated.xcconfig
。
為了解決它,我只是:
appcenter-post-clone
並推送了這個提交1- 導航到 flutter 模塊目錄 2- 執行 flutter pub get ** 還要確保您在穩定頻道“Flutter”上
它現在似乎可以工作了。 我認為 App Center 構建過程已經更新。 為了您的信息,我在下面包含了我的最終構建后腳本,以防萬一這很有用:
#!/usr/bin/env bash
#Place this script in project/ios/
# fail if any command fails
set -e
# debug log
set -x
cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
flutter channel beta
flutter doctor
echo "Installed flutter to `pwd`/flutter"
flutter build ios --release --no-codesign
從另一個分支復制現有構建配置文件后,我遇到了同樣的問題。 刪除構建配置並為目標分支從頭開始創建新配置后,問題得到解決。
嘗試進入IOS文件夾然后pod install
或pod update
在終端
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.