Sobes.tech
Middle+

What is your experience in developing CI/CD for mobile applications?

sobes.tech AI

Answer from AI

I have experience building CI/CD pipelines for mobile applications (iOS and Android).

Key stages I have worked with:

  • Build: Using Xcodebuild for iOS and Gradle for Android. Integration with build systems (Jenkins, GitLab CI/CD, CircleCI, GitHub Actions).
  • Testing: Running unit tests, integration tests, UI tests on simulators/emulators or real devices (using Firebase Test Lab, BrowserStack, Device Farm).
  • Signing: Automating the app signing process for publication (Code Signing Identities, Provisioning Profiles for iOS; Keystore for Android).
  • Distribution:
    • Internal builds: Using TestFlight for iOS and Firebase App Distribution/Internal Test Tracks for Android.
    • Publishing to stores: Automating artifact uploads to App Store Connect via Fastlane or iTunes Connect Transporter and to Google Play Store via Google Play Developer API or Fastlane.

Tools I have worked with:

  • CI/CD systems: Jenkins, GitLab CI/CD, GitHub Actions.
  • Build/Deployment automation tools: Fastlane, Gradle, Xcodebuild.
  • Dependency management: CocoaPods, Carthage for iOS; Gradle Dependency Management for Android.
  • Testing tools: XCTest, EarlGrey, Appium, Espresso, UI Automator.
  • Cloud testing services: Firebase Test Lab, BrowserStack.
  • Version control systems: Git.

An example pipeline (simplified):

# Example .gitlab-ci.yml for GitLab CI/CD

stages:
  - build
  - test
  - deploy_internal
  - deploy_store

variables:
  ANDROID_BUILD_TOOLS: "30.0.3"
  ANDROID_SDK_ROOT: "$CI_PROJECT_DIR/android-sdk"

cache:
  paths:
    - ~/.gradle/caches
    - ~/.gradle/wrapper
    - Pods/

build_android:
  stage: build
  image: openjdk:11-jdk-slim
  variables:
    GRADLE_OPTS: "-Dorg.gradle.daemon=false"
  before_script:
    - apt-get update && apt-get install -y unzip
    - mkdir $ANDROID_SDK_ROOT
    - wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
    - unzip commandlinetools-linux-7583922_latest.zip -d $ANDROID_SDK_ROOT
    - yes | $ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager --licenses
    - $ANDROID_SDK_ROOT/cmdline-tools/bin/sdkmanager "platforms;android-30" "build-tools;$ANDROID_BUILD_TOOLS"
    - export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/bin:$ANDROID_SDK_ROOT/platform-tools
    - cd android
  script:
    - ./gradlew assembleRelease
  artifacts:
    paths:
      - android/app/build/outputs/apk/release/*.apk

build_ios:
  stage: build
  image: macos_runner # Requires specific macOS/Xcode runner
  before_script:
    - gem install bundler
    - cd ios
    - bundle install
  script:
    - bundle exec fastlane build release
  artifacts:
    paths:
      - ios/*.ipa # Or whatever fastlane output is

test_android_unit:
  stage: test
  image: openjdk:11-jdk-slim
  before_script:
    - cd android
  script:
    - ./gradlew testReleaseUnitTest

test_ios_unit:
  stage: test
  image: macos_runner
  before_script:
    - pod install # if using CocoaPods
    - cd ios
  script:
    - xcodebuild test -project YourApp.xcodeproj -scheme YourApp -destination 'platform=iOS Simulator,name=iPhone 12'

deploy_android_firebase:
  stage: deploy_internal
  image: openjdk:11-jdk-slim
  before_script:
    - apt-get update && apt-get install -y curl
    - curl -sL https://firebase.tools | bash
    - cd android
  script:
    - firebase appdistribution:distribute app/build/outputs/apk/release/*.apk --app <firebase-app-id> --token $FIREBASE_TOKEN --release-notes "Automated build ${CI_PIPELINE_IID}" --testers-file ../testers.txt

deploy_ios_testflight:
  stage: deploy_internal
  image: macos_runner
  before_script:
    - cd ios
  script:
    - bundle exec fastlane pilot upload

deploy_android_play_store:
  stage: deploy_store
  image: openjdk:11-jdk-slim
  before_script:
     - apt-get update && apt-get install -y python3 python3-pip
     - pip3 install google-api-python-client oauth2client
     - cd android
  script:
     - echo "$GOOGLE_PLAY_KEY_JSON" | base64 --decode > service_account_key.json
     # Using fastlane for simplicity or directly with Google Play Developer API
     - bundle exec fastlane supply
  only:
    - tags # Deploy to store only on tags

deploy_ios_app_store:
  stage: deploy_store
  image: macos_runner
  before_script:
    - cd ios
  script:
    - bundle exec fastlane deliver
  only:
    - tags # Deploy to store only on tags

I have worked on optimizing build times, reducing Flaky Tests, setting up pipeline status notifications. I paid special attention to signing security and certificate/key management. I used secret variables in CI/CD systems for sensitive data storage.