Describe the solution you'd like
appcenter build automatically installs pods from a Podfile in the source tree. Our Podfile references pods by relative path from Capacitor:
def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
end
These pods are not in the source tree; npm install must be called first for those dependencies to be installed.
We have tried using appcenter-post-clone.sh as a solution to run npm install however it looks like pod install is automatically called by appcenter prior to that build script.
Unless I'm missing something, this makes it impossible to use appcenter for builds using Capacitor without adding node_modules to the Git repository (we don't want to do that.)
Describe alternatives you've considered
We could add node_modules to Git, but don't want to have 3rd party dependencies in our Git repository.
Additional context
Build output:
Hosted Agent successfully assigned.
Configuring connection settings for Hosted Agent
Starting Hosted Agent
##[section]Starting: Job
##[section]Starting: Initialize job
Current agent version: '2.148.2'
Prepare build directory.
Set build variables.
Download all required tasks.
Downloading task: ShellScript
Downloading task: CmdLine
Downloading task: CocoaPods
Downloading task: DeleteFiles
Downloading task: Xcode
Downloading task: CopyFiles
Downloading task: PublishBuildArtifacts
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Checkout
==============================================================================
Task : Get sources
Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version : 1.0.0
Author : Microsoft
Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Syncing repository: prod-client-app (ExternalGit)
##[command]git version
git version 2.21.0
##[command]git lfs version
git-lfs/2.7.1 (GitHub; darwin amd64; go 1.12)
##[command]git init "/Users/vsts/agent/2.148.2/work/1/s"
Initialized empty Git repository in /Users/vsts/agent/2.148.2/work/1/s/.git/
##[command]git remote add origin https://github.com/....git
##[command]git config gc.auto 0
##[command]git config --get-all http.https://github.com/....git.extraheader
##[command]git config --get-all http.proxy
##[command]git remote set-url origin https://***:***@github.com/....git
##[command]git remote set-url --push origin https://***:***@github.com/....git
##[command]git lfs install --local
Updated git hooks.
Git LFS initialized.
##[command]git config remote.origin.lfsurl https://***:***@github.com/....git/info/lfs
##[command]git config remote.origin.lfspushurl https://***:***@github.com/....git/info/lfs
##[command]git fetch --tags --prune --progress --no-recurse-submodules origin
...
remote: Total 127 (delta 28), reused 108 (delta 15), pack-reused 0
Receiving objects: 100% (127/127), 372.84 KiB | 1.10 MiB/s, done.
Resolving deltas: 100% (28/28), done.
From https://github.com/.../...
* [new branch] appcenter2 -> origin/appcenter2
* [new branch] master -> origin/master
##[command]git lfs fetch origin 50d0318bcbb6d5058290c6e564d9a52b2818fa6a
fetch: Fetching reference 50d0318bcbb6d5058290c6e564d9a52b2818fa6a
##[command]git checkout --progress --force 50d0318bcbb6d5058290c6e564d9a52b2818fa6a
HEAD is now at 50d0318 PROD-52: add appcenter post-clone script
##[command]git submodule sync --recursive
##[command]git submodule update --init --force --recursive
##[command]git remote set-url origin https://github.com/<obscured>.git
##[command]git remote set-url --push origin https://github.com/<obscured>.git
##[command]git config --unset-all remote.origin.lfsurl
##[command]git config --unset-all remote.origin.lfspushurl
##[section]Finishing: Checkout
##[section]Starting: Tag build
==============================================================================
Task : Shell Script
Description : Run a shell script using bash
Version : 2.1.3
Author : Microsoft Corporation
Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613738)
==============================================================================
[command]/bin/bash /Users/vsts/agent/2.148.2/scripts/emit-tags.sh continuous,xcode
##[section]Async Command Start: Add Build Tag
Build '3' has following tags now: normal, continuous
##[section]Async Command End: Add Build Tag
##[section]Async Command Start: Add Build Tag
Build '3' has following tags now: normal, continuous, xcode
##[section]Async Command End: Add Build Tag
##[section]Finishing: Tag build
##[section]Starting: Set Xcode path
==============================================================================
Task : Command Line
Description : Run a command line with arguments
Version : 1.1.3
Author : Microsoft Corporation
Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735)
==============================================================================
[command]/bin/bash -c sudo xcode-select --switch /Applications/Xcode_10.1.app/Contents/Developer
##[section]Finishing: Set Xcode path
##[section]Starting: Pod install
==============================================================================
Task : CocoaPods
Description : CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. This task runs 'pod install'.
Version : 0.142.2
Author : Microsoft Corporation
Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613745)
==============================================================================
[command]/usr/local/lib/ruby/gems/2.6.0/bin/pod install --repo-update
Updating local specs repositories
$ /usr/local/bin/git -C /Users/vsts/.cocoapods/repos/master fetch origin --progress
...
Resolving deltas: 100% (16427/16427), completed with 2893 local objects.
From https://github.com/CocoaPods/Specs
42b70470f77..ee357c424c6 master -> origin/master
$ /usr/local/bin/git -C /Users/vsts/.cocoapods/repos/master rev-parse --abbrev-ref HEAD
master
$ /usr/local/bin/git -C /Users/vsts/.cocoapods/repos/master reset --hard origin/master
Checking out files: 100% (2599/2599), done.
HEAD is now at ee357c424c6 [Add] TJNetwork 0.0.1
CocoaPods 1.7.0.beta.2 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.7.0.beta.2
[!] The version of CocoaPods used to generate the lockfile (1.6.1) is higher than the version of the current executable (1.5.3). Incompatibility issues may arise.
Analyzing dependencies
Fetching podspec for `Capacitor` from `../../node_modules/@capacitor/ios`
[!] No podspec found for `Capacitor` in `../../node_modules/@capacitor/ios`
##[error]/usr/local/lib/ruby/gems/2.6.0/bin/pod failed with return code: 1
##[error]The 'pod' command failed with error: /usr/local/lib/ruby/gems/2.6.0/bin/pod failed with return code: 1
##[section]Finishing: Pod install
##[section]Starting: Xcode build (not signed)
==============================================================================
Task : Xcode
Description : Build, test, or archive an Xcode workspace on macOS. Optionally package an app.
Version : 4.130.0
Author : Microsoft Corporation
Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613730)
==============================================================================
##[section]Finishing: Xcode build (not signed)
##[section]Starting: Checkout
==============================================================================
Task : Get sources
Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version : 1.0.0
Author : Microsoft
Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: prod-client-app (ExternalGit)
##[section]Finishing: Checkout
##[section]Starting: Finalize Job
Start cleaning up orphan processes.
##[section]Finishing: Finalize Job
##[section]Finishing: Job
Having a similar issue. We are using react-native-unimodules from expo, which references node_modules in the Podfile.
Like @greensopinion I have tried using the post-clone build script, which _says_ it is run immediately after clone and before doing anything else, but this is not the case.
@greensopinion @Maximell Are your apps React Native? If so, that is a known issue. At one point, we attempted to try to move the script earlier in the process, but that ended up breaking many existing apps, who built the scripts with assumption of when it is currently executed. So we reverted that effort. I'd still like to see how we can resolve this, but haven't been able to prioritize it.
Hi @DennisPan, yes, my app is in React-Native.
I was actually able to resolve this issue, with some help from Jorge in AppCenter support (thanks!). Despite having builds queue automatically from git push, I had to go into the build configuration and push Save and Build for it to recognize my appcenter-post-clone.sh file (placed next to my .xcodeproj file).
Still working through other build issues, but npm install is happening before pod install now! 馃帀
I have the same error:
@maximell could you share your appcenter-post-clone.sh ?
@manolobattista93 sure! It is really long and complicated... ;)
#!/usr/bin/env bash
# Install node_modules
npm install
Hope that helps!
@greensopinion @Maximell Are your apps React Native? If so, that is a known issue. At one point, we attempted to try to move the script earlier in the process, but that ended up breaking many existing apps, who built the scripts with assumption of when it is currently executed. So we reverted that effort. I'd still like to see how we can resolve this, but haven't been able to prioritize it.
No, it's not React Native. We're using JavaScript/Vue in a WebView, facilitated by the Capacitor Framework
@Maximell thanks :) I solved with another solution, adding on appcenter-post-clone.sh:
# Force the 1.5.3 version of cocoapods
echo "uninstalling all cocoapods versions"
sudo gem uninstall cocoapods --all
echo "installing cocoapods version 1.5.3"
sudo gem install cocoapods -v 1.5.3
This remove the cocoapods version installed on my App Center and force the specified version, 1.5.3 in my case.
Combining the contributions in this thread has helped me achieve a flawless build process in AppCenter for my React Native 0.60 project. My ios/appcenter-post-clone.sh now looks like this:
#!/usr/bin/env bash
# Force the 1.7.5 version of cocoapods, as opposed to the version installed by AppCenter
echo "Uninstalling all cocoapods versions"
sudo gem uninstall cocoapods --all
echo "Installing cocoapods version 1.7.5"
sudo gem install cocoapods -v 1.7.5
# Upgrade Node to a version expected by React Native 0.60
set -ex
brew uninstall node@6
NODE_VERSION="8.10.0"
curl "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.pkg" > "$HOME/Downloads/node-installer.pkg"
sudo installer -store -pkg "$HOME/Downloads/node-installer.pkg" -target "/"
# Run Yarn
yarn
Please mind the version numbers so that they correspond to your Podfile and package.json. And after adding this script, go to your Build settings in AppCenter, confirm that your post clone script is recognized, then hit Save & Build.
Thanks gents.
Glad to hear it @jorisw! Feel free to make a PR with the script that worked for you in our collection of community driven build scripts.
Hi @DennisPan, yes, my app is in React-Native.
I was actually able to resolve this issue, with some help from Jorge in AppCenter support (thanks!). Despite having builds queue automatically from
git push, I had to go into the build configuration and pushSave and Buildfor it to recognize myappcenter-post-clone.shfile (placed next to my.xcodeprojfile).Still working through other build issues, but
npm installis happening beforepod installnow! 馃帀
I had similar issue for flutter app. I was pulling my hair out trying to figure out why my post-build wasn't getting run before pod install. Need "flutter pub get" to be run in order to generate the file needed by pod install. @Maximell's suggestion to press "Save and build" worked! Now it's finally recognizing and using it.
Having a similar issue in Flutter. The build server says you need to run pod repo update in order to satisfy latest dependencies. I am still figuring out how to tell the build script to run pod repo update. It does pod install automatically on 'flutter pub get' but I need to run pod repo update.
Please let me know if anyone figures this out.
This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.
This issue will now be closed because it hasn't had any activity for 15 days after stale. Please feel free to open a new issue if you still have a question/issue or suggestion.
Most helpful comment
Hi @DennisPan, yes, my app is in React-Native.
I was actually able to resolve this issue, with some help from Jorge in AppCenter support (thanks!). Despite having builds queue automatically from
git push, I had to go into the build configuration and pushSave and Buildfor it to recognize myappcenter-post-clone.shfile (placed next to my.xcodeprojfile).Still working through other build issues, but
npm installis happening beforepod installnow! 馃帀