GitLab CI with Docker, Fastlane and Cocoapods not working

Desperate help needed:

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:

  1. install fastlane (link to fastlane page)

  2. create a GitLab project and upload your project repository (link to GitLab)

  3. install gitlab-runner on MacOS, following these steps…

  4. install Docker (for desktop), registering here and downloading the app

  5. 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
  1. start docker application on your Mac

  2. 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

Hi there
Is this still an issue?
Does your runner run as root?
ps -ef | grep runner

I am off this project, so I cannot tell if still an issue. Thank you for the help suggestion. I have no ressource to test it anymore tough.

1 Like