8

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://docs.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
Tarique Naseem
  • 733
  • 7
  • 12
  • Did you ever come up with a resolution for this? I'm running into the exact same issues and I've tried all the same things – Tyler Merle Apr 04 '20 at 22:32
  • Not yet, unfortunately. I'll be looking at it again in the coming days though. The App Center support guys say they'll pass the info on, but as it's not officially supported, they can't promise anything. – Tarique Naseem Apr 04 '20 at 23:39

6 Answers6

2

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

Ndivhuwo
  • 203
  • 1
  • 6
1

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.

  • Can you be more specific? I had to do this for the Android App Center build, which works fine, but what specific files do I need to remove from .gitignore for an iOS build to work? – Tarique Naseem Mar 19 '20 at 20:13
  • This link explains everything, follow the steps, and tell me if you still have issues! https://medium.com/codespace69/common-mistakes-when-writing-a-flutter-app-errors-collection-part-1-2d40abfcea2f – Marco Mascii Mar 19 '20 at 21:07
  • When answering questions on Stack Overflow, It's better to link to the source AND provide the relevant information in the answer. I cannot read that article due to being over the limit on Medium for the month - and from the title, it doesn't even sound relevant to my issue with the App Centre CI/CD setup. – Tarique Naseem Mar 20 '20 at 05:42
  • To fix that issue you need to comment the Generated.xcconfig in the .gitIgnore. This will resolve that issue. If then you will run in other issue, then probably the project was generated incorrectly, like happened to me. In my case this was due to the use of VSCode instead of Android studio. This fixed all the issues in my project. – Marco Mascii Mar 20 '20 at 06:25
  • The generated.xcconfig is excluded in .gitgnore, as it's designed to be generated during the build process, whether it's on your machine or built by App Center. Having said that, one of the things I did do as a test was to remove it from gitignore, to see what would happen. As expected, it came up with a whole set of other problems due to the paths therein (which were only relevant to my machine). Editing the file is not a good idea either, as it would get overwritten each time I did a build locally to test. So, not a good solution! – Tarique Naseem Mar 20 '20 at 06:55
  • You are using VSCode or Android Studio? – Marco Mascii Mar 20 '20 at 07:33
1

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.
Danilo Rêgo
  • 161
  • 1
  • 3
  • This solved my ploblem. I also commented `Generated.xcconfig` in the `.gitignore` from `ios` folder. But i think it would work without changing `.gitignore`. – Ovidiu Uşvat Nov 25 '20 at 17:36
1

1- Navigate to the flutter module directory 2- Do a flutter pub get ** Also make sure that you are on the stable channel "Flutter"

K-Soliman
  • 534
  • 3
  • 7
0

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
Tarique Naseem
  • 733
  • 7
  • 12
-1

Try to enter the IOS folder then pod installor pod update

in the terminal