Flutter iOS on Circle CI - ios

Currently I'm trying to build flutter project on circle CI. When trying to install pods I got following output.
-> Fetching podspec for `Flutter` from `Flutter`
[!] No podspec found for `Flutter` in `Flutter
My config
build_ios:
resource_class: large
working_directory: ~/project/ios
macos:
xcode: 12.3.0
steps:
- checkout:
path: ~/project
- run:
name: download flutter SDK
command: if ! test -f "~/flutter_sdk.zip"; then curl -o ~/flutter_sdk.zip https://storage.googleapis.com/flutter_infra/releases/stable/macos/flutter_macos_1.22.5-stable.zip; fi
- run:
name: unzip flutter SDK
command: unzip ~/flutter_sdk.zip -d ~
- run:
name: export flutter path
command: echo 'export PATH="$PATH:~/flutter/bin"' >> $BASH_ENV
- run: flutter doctor
- run: flutter pub get
- run:
name: Bundle install
working_directory: ./ios
command: bundle install
- run:
name: Pod install
working_directory: ./ios
command: bundle exec pod install --repo-update
Do you have any suggestions?

In case someone will have same issue: I was missing the following command
- run: flutter precache --no-android

Related

The following build commands failed: PhaseScriptExecution Run Script in fastlane

when I build the ios project using this command in Flutter in github actions(by the way, using the same command in my local macOS catalina 10.15.7 and xcode 12.3 works fine):
./ios && bundle exec fastlane beta
shows this error:
** ARCHIVE FAILED **
The following build commands failed:
PhaseScriptExecution Run\ Script /Users/runner/Library/Developer/Xcode/DerivedData/Runner-gzzbtgmsqethlzedjqlbspydxjjv/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-9740EEB61CF901F6004384FC.sh
(1 failure)
[05:17:23]: Exit status: 65
[05:17:23]:
[05:17:23]: Maybe the error shown is caused by using the wrong version of Xcode
[05:17:23]: Found multiple versions of Xcode in '/Applications/'
[05:17:23]: Make sure you selected the right version for your project
[05:17:23]: This build process was executed using '/Applications/Xcode_12.3.app'
[05:17:23]: If you want to update your Xcode path, either
[05:17:23]:
[05:17:23]: - Specify the Xcode version in your Fastfile
[05:17:23]: ▸ xcversion(version: "8.1") # Selects Xcode 8.1.0
[05:17:23]:
[05:17:23]: - Specify an absolute path to your Xcode installation in your Fastfile
[05:17:23]: ▸ xcode_select "/Applications/Xcode8.app"
[05:17:23]:
[05:17:23]: - Manually update the path using
[05:17:23]: ▸ sudo xcode-select -s /Applications/Xcode.app
[05:17:23]:
this is the fastlane, in this script, I specify the xcode version 12.3 :
xcversion(version: "12.3")
xcode_select("/Applications/Xcode_12.3.app")
if is_ci
create_keychain(
name: ENV['MATCH_KEYCHAIN_NAME'],
password: ENV["MATCH_KEYCHAIN_PASSWORD"],
default_keychain: true,
unlock: true,
timeout: 3600,
lock_when_sleeps: false
)
end
where is going wrong and what should I do to fix it? I have tried to execute the commad in github actions, this is my config:
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v1
with:
java-version: '12.x'
- uses: subosito/flutter-action#v1
with:
flutter-version: '1.22.5'
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_12.3.app/Contents/Developer'
- name: Bundle install
run: cd ./ios && bundle install && bundle update fastlane
- name: Install tools
run: |
flutter precache
flutter pub get
cd ./ios && pod repo update && pod install
#- run: flutter pub get
#- run: flutter build apk
#- run: flutter build ios --release --no-codesign
- name: Setup SSH Keys and known_hosts for fastlane match
run: |
SSH_PATH="$HOME/.ssh"
mkdir -p "$SSH_PATH"
touch "$SSH_PATH/known_hosts"
echo "$PRIVATE_KEY" > "$SSH_PATH/id_rsa"
chmod 700 "$SSH_PATH"
ssh-keyscan github.com >> ~/.ssh/known_hosts
chmod 600 "$SSH_PATH/known_hosts"
chmod 600 "$SSH_PATH/id_rsa"
eval $(ssh-agent)
ssh-add "$SSH_PATH/id_rsa"
env:
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy to TestFlight/PGY
run: |
cd ./ios && bundle exec fastlane beta
I tried to install new version(1.10.0) of cocopods(the same verion of my local Macbook Pro):
- name: Bundle install
run: cd ./ios && gem install cocoapods -v 1.10.0 && bundle install && bundle update fastlane
and tried to tweak the build type of xcode:
still not work.
Your build log shows the following error:
[05:32:01]: ▸ ../../../hostedtoolcache/flutter/1.22.5-stable/x64/packages/flutter/lib/src/widgets/scroll_view.dart:588:9: Context: Found this candidate, but the arguments don't match.
[05:32:01]: ▸ const CustomScrollView({
[05:32:01]: ▸ ^^^^^^^^^^^^^^^^
[05:32:01]: ▸ Command PhaseScriptExecution failed with a nonzero exit code
[05:32:01]:
Could you check this? It might be possible that the error is not due to any xcode version.

CircleCI 2.0 iOS build stuck at Signing

I am building my React Native iOS app with circleci 2.0, my build is stuck at Signing for about 40 minutes and not moving ahead.
I have my apple id with 2FA so have added FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD in environment variables.
My github id is also having 2FA and have deployed adhoc certificates on git with GH_TOKEN in circle ci env. variables.
My Fastlane file looks like this -
update_fastlane
default_platform(:ios)
platform :ios do
before_all do
setup_circle_ci
end
desc "Push a new beta build to TestFlight"
lane :beta do
increment_build_number(xcodeproj: "xxxApp.xcodeproj")
match(type:'adhoc')
gym(export_method: "ad-hoc")
build_app(workspace: "xxxApp.xcworkspace", scheme: "xxxApp")
# upload_to_testflight
end
end
My circle ci config.yml looks like this
version: 2
jobs:
node:
working_directory: ~/sekuraRN
docker:
- image: circleci/node:10.16.0
steps:
- checkout
- run:
name: set Ruby version
command: echo "ruby-2.4" > ~/.ruby-version
- run: npm install
- persist_to_workspace:
root: ~/xxxApp
paths:
- node_modules
ios:
macos:
xcode: '11.2.1'
resource_class: large
working_directory: ~/xxxApp
shell: /bin/bash --login -o pipefail
steps:
- checkout
- add_ssh_keys:
fingerprints:
- "XXXXXXXX"
- run:
name: set Ruby version
command: echo 'chruby ruby-2.5.7' >> ~/.bash_profile
- run:
name: Update Bundler version
command: sudo gem install bundler:2.1.1
- restore_cache:
key: npm-v1-{{ checksum "package-lock.json" }}-{{ arch }}
- restore_cache:
key: node-v1-{{ checksum "package.json" }}-{{ arch }}
- run: npm install
- save_cache:
key: npm-v1-{{ checksum "package-lock.json" }}-{{ arch }}
paths:
- ~/.cache/npm
- save_cache:
key: bundle-v1-{{ checksum "ios/Podfile.lock" }}
paths:
- ./Pods
- save_cache:
key: node-v1-{{ checksum "package.json" }}-{{ arch }}
paths:
- node_modules
- run:
command: bundle install
working_directory: ios
- save_cache:
key: bundle-v1-{{ checksum "ios/Gemfile.lock" }}-{{ arch }}
paths:
- vendor/bundle
- run:
name: Setup MFSDK Configuration
command: echo -e "machine repo.active.ai\nlogin docs#active.ai\npassword docs#123" > ~/.netrc
- run:
name: Uninstall Cocoapods
command: gem uninstall cocoapods
- run:
name: Install Cocoapods
command: gem install -n /usr/local/bin cocoapods
- run:
name: Pod Install
command: pod install
working_directory: ios
- run:
name: update fastlane
command: bundle update fastlane
working_directory: ios
- run:
name: Building IPA
no_output_timeout: 30m
command: bundle exec fastlane beta
working_directory: ios
- store_artifacts:
path: ios/xxx_app
destination: ipa/
workflows:
version: 2
node-android-ios:
jobs:
- node
- ios:
filters:
branches:
only:
- master
requires:
- node
Output from CircleCI -
[07:47:40]: ▸ the transform cache was reset.
[07:49:45]: ▸ Touching xxxApp.app
[07:49:45]: ▸ Signing /Users/distiller/Library/Developer/Xcode/DerivedData/…
It doesn't move ahead and stuck at this for 40 mins

GitLab CI with Docker, Fastlane and Cocoapods not working

Desperate help needed:
Already asked for the case with gitlab-runner register as "shell", I try to ask a very similar question here with gitlab-runner register as "docker".
Since 3 days I try to get Gitlab CI running (using docker, fastlane - all for an iOS-app having Cocoapods dependencies).
Here is the error message that the GitLab CI spits out:
I did the following steps:
install fastlane (link to fastlane page)
create a GitLab project and upload your project repository (link to GitLab)
install gitlab-runner on MacOS, following these steps...
install Docker (for desktop), registering here and downloading the app
register gitlab-runner (i.e. open terminal and type the following):
(your Token can be found under GitLab-->Settings-->CI/CD)
sudo gitlab-runner register \
--non-interactive \
--url "https://gitlab.com/" \
--registration-token "TOKENABCDEFG" \
--description "MyApp runner with ruby-2.6" \
--tag-list ios \
--executor "docker" \
--docker-image ruby:2.6
start docker application on your Mac
run docker image (by typing the following in your terminal:)
docker run -d --name gitlab-runner --restart always \
-v /Users/Shared/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
After all that, any git push to your GitLab project repo will automatically start a Pipeline.
I also tried using a local shell (instead of docker) - but no success either as documented here.
No matter what I try, I always end up with the same error message:
[08:48:04]: Driving the lane 'ios tests' 🚀
[08:48:04]: -----------------------
[08:48:04]: --- Step: cocoapods ---
[08:48:04]: -----------------------
[08:48:04]: Using deprecated option: '--clean' (true)
[08:48:04]: $ cd '.' && bundle exec pod install
[08:48:04]: ▸ WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
[08:48:04]: ▸ Consider adding the following to ~/.profile:
[08:48:04]: ▸ export LANG=en_US.UTF-8
[08:48:04]: ▸
[08:48:04]: ▸ bundler: failed to load command: pod (/usr/local/bundle/bin/pod)
[08:48:04]: ▸ CLAide::Help: [!] You cannot run CocoaPods as root.
Here is my .gitlab-ci.yml file:
stages:
- unit_tests
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
before_script:
- gem install bundler
- bundle install
unit_tests:
dependencies: []
stage: unit_tests
artifacts:
paths:
- fastlane/screenshots
- fastlane/logs
script:
- bundle exec fastlane tests
tags:
- ios
And here the Fastfile:
update_fastlane
default_platform(:ios)
platform :ios do
def install_pods
cocoapods(
clean: true,
podfile: "./Podfile",
try_repo_update_on_error: true
)
end
lane :tests do
install_pods()
gym(configuration: "Release",
workspace: "MyApp.xcworkspace",
scheme: "MyApp",
clean: true,
output_name: "MyApp.ipa")
# increment_build_number
scan(workspace: "MyApp.xcworkspace",
devices: ["iPhone SE", "iPhone XS"],
scheme: "MyAppTests")
end
I finally found the solution:
Your gitlab-runner register is not allowed to have sudo.
For some reason there are many tutorials out there that show differently (i.e. with sudo) - such as this video or others...
Anyway, on a Mac you absolutely need to leave sudo out and absolutely register as "shell" executor for GitLab (i.e. not "docker")
Here is the best tutorial I have found on how to Gitlab CI an iOS project.

How to add plugin fastlane-plugin-appicon in circleci?

I want to install the fastlane plugin fastlane-plugin-appicon, so I add add a command "- run: bundle exec fastlane add_plugin appicon" in the the circleci file, but there is something wrong, the circleci code and error log are as follows, thanks!
beta:
macos:
xcode: "10.1.0"
working_directory: /Users/distiller/project
environment:
FL_OUTPUT_DIR: output
FASTLANE_LANE: ios beta
shell: /bin/bash --login -o pipefail
steps:
- checkout
- run:
name: pre-start simulator
command: xcrun instruments -w "iPhone 8 (12.1)" || true
- run:
name: Set Ruby Version
command: echo "ruby-2.4" > ~/.ruby-version
- run: brew update
- run: brew cask install fastlane --no-quarantine
- run: bundle update fastlane
- run: bundle exec fastlane add_plugin appicon
- run: bundle install --path .bundle
- run:
name: Fastlane
command: bundle exec fastlane $FASTLANE_LANE
- store_artifacts:
path: output
- run:
name: Transition Jira items for deployment
command: .circleci/transition-jira-items.sh

Are Instrumentation tests for Android Espresso available on CircleCi 2.0?

Are Instrumentation tests for Android Espresso available on CircleCI 2.0?
If yes, can anybody, please, help to configure config.yml file for me?
I’ve made thousand attempts and no luck. I can run unit tests, but not Instrumentation.
Thanks
The answer for this question is: yes. Instrumentation tests are possible for CircleCi. This is the configuration I have:
version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-25-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
command: sudo chmod +x ./gradlew
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Setup emulator
command: sdkmanager "system-images;android-25;google_apis;armeabi-v7a" && echo "no" | avdmanager create avd -n test -k "system-images;android-25;google_apis;armeabi-v7a"
- run:
name: Launch emulator
command: export LD_LIBRARY_PATH=${ANDROID_HOME}/emulator/lib64:${ANDROID_HOME}/emulator/lib64/qt/lib && emulator64-arm -avd test -noaudio -no-boot-anim -no-window -accel on
background: true
- run:
name: Wait emulator
command: |
# wait for it to have booted
circle-android wait-for-boot
# unlock the emulator screen
sleep 30
adb shell input keyevent 82
- run:
name: Run Tests
command: ./gradlew connectedAndroidTest
- store_artifacts:
path: app/build/reports
destination: reports
- store_test_results:
path: app/build/test-results
The only problem with this configuration that it doesn't lead to successfull build because of not enough memory error. If somebody has better configuration, please, share.
I am running Android UI tests on CircleCI MacOS executor.
Here is my configuration:
version: 2
reference:
## Constants
gradle_cache_path: &gradle_cache_path
gradle_cache-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
workspace: &workspace
~/src
## Configurations
android_config: &android_config
working_directory: *workspace
macos:
xcode: "9.4.0"
shell: /bin/bash --login -eo pipefail
environment:
TERM: dumb
JVM_OPTS: -Xmx3200m
## Cache
restore_gradle_cache: &restore_gradle_cache
restore_cache:
key: *gradle_cache_path
save_gradle_cache: &save_gradle_cache
save_cache:
key: *gradle_cache_path
paths:
- ~/.gradle
## Dependency Downloads
download_android_dependencies: &download_android_dependencies
run:
name: Download Android Dependencies
command: ./gradlew androidDependencies
jobs:
ui_test:
<<: *android_config
steps:
- checkout
- run:
name: Setup environment variables
command: |
echo 'export PATH="$PATH:/usr/local/opt/node#8/bin:${HOME}/.yarn/bin:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin:/usr/local/share/android-sdk/tools/bin"' >> $BASH_ENV
echo 'export ANDROID_HOME="/usr/local/share/android-sdk"' >> $BASH_ENV
echo 'export ANDROID_SDK_HOME="/usr/local/share/android-sdk"' >> $BASH_ENV
echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"' >> $BASH_ENV
echo 'export QEMU_AUDIO_DRV=none' >> $BASH_ENV
echo 'export JAVA_HOME=/Library/Java/Home' >> $BASH_ENV
- run:
name: Install Android sdk
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/cask
HOMEBREW_NO_AUTO_UPDATE=1 brew cask install android-sdk
- run:
name: Install emulator dependencies
command: (yes | sdkmanager "platform-tools" "platforms;android-26" "extras;intel;Hardware_Accelerated_Execution_Manager" "build-tools;26.0.0" "system-images;android-26;google_apis;x86" "emulator" --verbose) || true
- *restore_gradle_cache
- *download_android_dependencies
- *save_gradle_cache
- run: avdmanager create avd -n Pixel_2_API_26 -k "system-images;android-26;google_apis;x86" -g google_apis -d "Nexus 5"
- run:
name: Run emulator in background
command: /usr/local/share/android-sdk/tools/emulator #Pixel_2_API_26 -skin 1080x2066 -memory 2048 -noaudio
background: true
- run:
name: Run Tests
command: ./gradlew app:connectedAndroidTest
https://gist.github.com/DoguD/58b4b86a5d892130af84074078581b87
I hope it helps

Resources