Github action compile error

‘Task’ is only available in iOS 15.0 or newer

‘init(priority:operation:)’ is only available in iOS 15.0 or newer

‘cancel()’ is only available in iOS 15.0 or newer

It’s because concurrency functions became available after 13.2(including), but GitHub action runs on Xcode 13.1

Now Xcode 13.1 is default on Mac OS 11. You can check this information here https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md

To use 13.2.1 Xcode, change Xcode line

from

run: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

to

run: sudo xcode-select -s "/Applications/Xcode_13.2.1.app"

iOS CI using GitHub action

  1. Start new workflow in github(It creates file .github/workflows/test.yml)
  2. Make script to test

name: Test

on:
  pull_request:
    branches: 
      - develop

jobs:
  test: 
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@v2

      - name: Select Xcode
        run: sudo xcode-select -switch /Applications/Xcode_12.4.app
      - name: setup-cocoapods
        run: gem install cocoapods
      - name: Xcode version
        run: /usr/bin/xcodebuild -version
      - name: cocoapods-acknowledgements
        run: gem install cocoapods-acknowledgements
      - name: pod
        run: pod install --repo-update
      - name: Run Test
        run: xcodebuild -workspace Develop.xcworkspace -scheme "Develop" -destination 'platform=iOS Simulator,name=iPhone 11,OS=14.4' -skip-testing:DevelopUITests test
 

Or for project file use this

xcodebuild -project Malt/MaltSample.xcodeproj -scheme MaltSample -destination 'platform=iOS Simulator,name=iPhone 11,OS=latest'

If I do not specify destination as Simulator, I get profile errors.

I was stuck in this error

Multiple commands produce '/Users/runner/Library/Developer/Xcode/DerivedData/PLAY-/Build/Products/Debug-iphonesimulator/BirdSDK.framework.dSYM':
132
Test session results, code coverage, and logs:
133
1) That command depends on command in Target 'PLAY' (project 'PLAY'): script phase “[CP] Embed Pods Frameworks”
134
2) That command depends on command in Target 'PLAYDevelop' (project 'PLAY'): script phase “[CP] Embed Pods Frameworks”

It was problem of pod

Fixing installing pods from

name: setup-cocoapods
  uses: maxim-lobanov/setup-cocoapods@v1.1
  with:
    version: 1.9.3

to

        run: gem install cocoapods

this just plain command fixed the problem. Cocoapods installed using this command had higher version than before.

3. Make test prerequisite to merge a pull request(admin auth is needed)

test is the test under “jobs:” line in yml file.

https://zeddios.tistory.com/1043 This post explains well.

* Adding destinations of minimum OS version is impossible. Because Xcode on GitHub Action has simulators only of iOS 14.4. https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#xcode

https://velog.io/@devapploper/Command-Line-Tool을-사용하여-Xcode-프로젝트를-빌드-및-테스트-하기

  • I tried to test in parallel. But from log, I could know that Xcode on GitHub Action only use one simulator and just messing up the ordering of the tests which makes hard to reproduce test fail.

How to view log of test fail on Travis

First of all, I should use xcpretty. If not, because the log is too long just the build fails. And even if some tests fails, the log that shown on GitHub only shows which tests failed without reasons.
How to view log of test fail on Travis

  1. Debug build
  2. xcodebuild (because the logs get deleted)
  3. After test finished, cd /Users/travis/Library/Developer/Xcode/DerivedData/[Your Project]-[some code- shown during the process or log]/Logs/Test/Test-[Your Project]-2019.04.11_06-20-41-+0000.xcresult/1_Test/Diagnostics/
  4. You can drill down to [Product_name]Tests folders
  5. and vim StandardOutputAndStandardError.txt or vim Session-[Product_name]-[date]~~.log

 

When test failed only on Travis

  1. increase waiting time
  2. check whether a variable is kept used between tests affecting other test

 

code is under /Users/travis/build/

xcodebuild tips

xcodebuild -- build Xcode projects and workspaces

it’s using terminal

When you want to have multiple parameters to the command & skip certain file testing, use skip-testing. It’s useful when you skip testing  network dependent tests on CI.

xcodebuild -workspace Something.xcworkspace -scheme Something CODE_SIGNING_REQUIRED=NO -sdk iphonesimulator11.3 -destination ‘platform=iOS Simulator,name=iPhone 6,OS=11.3’ -skip-testing:SomethingUITests -skip-testing:SomethingTests/SomethingTests test

When write -skip-testing “File”. Just add the file path under your project. Does not include “group” in project navigator.

And “iPhone 6” means iPhone 6. It’s not code like iPhone8,2

If you get error like below, try deleting “CODE_SIGNING_REQUIRED=NO

â–¸ Signing /Users/travis/Library/Developer/Xcode/DerivedData/Something-gfrkrbrfwqplztgzqocbzyotbmpg/Build/Products/Debug-iphonesimulator/SomethingUITests-Runner.app/PlugIns/SomethingUITests.xctest

2018-08-10 05:51:50.674 xcodebuild[8511:16979] Error Domain=IDETestOperationsObserverErrorDomain Code=6 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}

xcodebuild -workspace Something.xcworkspace -scheme Something -sdk iphonesimulator11.3 -destination ‘platform=iOS Simulator,name=iPhone 6,OS=11.3’ -skip-testing:SomethingUITests -skip-testing:SomethingTests/SomethingTests test

If you want the log to be prettier, try to use xcpretty

  1. download
    1. gem install xcpretty

    2. If you get authority error
    3. sudo gem install xcpretty

  1. xcodebuild -workspace Something.xcworkspace -scheme Something -sdk iphonesimulator11.4 -destination ‘platform=iOS Simulator,name=iPhone 8,OS=11.4’ -skip-testing:SomethingUITests -skip-testing:SomethingTests/ModelInitWithServerTests test | xcpretty

    1. But If you use this script in travis, don’t forget to set pipe fail. If you do not use pipe fail, xcpretty’s result will be the final result of travis showing “pass” everytime.
      1. pipefail: If set, the return value of a pipeline is the value of the last (rightmost)command to exit with a non-zero status, or zero if all commands in the pipelineexit successfully. This option is disabled by default.

      2. set -o pipefail && xcodebuild -workspace Something.xcworkspace -scheme Something -sdk iphonesimulator11.4 -destination ‘platform=iOS Simulator,name=iPhone 8,OS=11.4’ -skip-testing:SomethingUITests -skip-testing:SomethingTests/ModelInitWithServerTests test | xcpretty

         

If xcodebuild does not execute simulator, just run the same simulator before running script.