简体   繁体   中英

Flutter iOS build on the App Center fails with error: "Invalid Podfile file: Generated.xcconfig must exist

I've just set up my app to be built on the App Center, by following the article here .

Although the Android version builds and deploys fine on App Center, I'm getting an error with the iOS build, shown in the excerpt from the build output below:

==============================================================================
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)

My build script is:

#!/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

I did add the flutter pub get as mentioned in the error, but that didn't make a difference. Also worth noting that the build works fine when I do it in Xcode locally. I can also deploy the built archive to Testflight with no problems. It's just the App Center build process I'm having issues with.

I'm a bit lost now and I can't find any information on how to resolve this. I'm also new to CI/CD, so any help appreciated!

Update

I've also tried adding the following to the script to force App Center to run the same version of Cocoapods as my local machine, but it didn't make a difference to the error.

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.9.1
pod setup

I did this to my post-clone script and it worked:

#!/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

The trick seems to have been moving the "fail if any command fails" section to after the pod re-installation

Check your .gitIgnore. Had the same issue due to the file being excluded from the repo.

Once added back everything went fine.

Be also careful on the Paths defined for Flutter in your project.

I had the same issue. It happens when the appcenter-post-clone.sh fails to run, so, the flutter is not installed and the command flutter build ios does not run to generate the Generated.xcconfig .

To fix it, I just:

  • Deleted the appcenter-post-clone and pushed this commit
  • Opened the configuration of the branch, on Build section. Now the post-clone tag has gone. Save it.
  • Push another commit with the appcenter-post-clone.sh again.
  • Configure the branch again, now with the post-clone tag back.
  • Save & Build.

1- 导航到 flutter 模块目录 2- 执行 flutter pub get ** 还要确保您在稳定频道“Flutter”上

It appears to work now. I think there's been an update to the App Center build process. For your info, I've included my final post-build script below, in case this is useful:

#!/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

I encountered the same issue after I copied an existing build profile from another branch. The problem was resolved after deleting the build config and creating a new one from scratch for the target branch.

Try to enter the IOS folder then pod install or pod update

in the terminal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM