CI

I want to build iOS project on GitHub Actions!

github-actions-ios-build-en

I want to build iOS project on GitHub Actions!

I want to use GitHub Actions as a CI environment!

When developing an app, I wanted to automate the following things.

  • Run builds and tests when pushed.
  • When issuing a pull request, if the build or test fails, make it impossible to merge.
  • Build ipa for development when it is merged into the develop branch.
  • Deploy when merged into the release branch.

So I decided to use the CI environment, and this time I investigated Github Actions.

How to use

1. Open the project on GitHub and open the "Actions" tab. Then, the following screen will be displayed. Select "Set up a workflow yourself" on the right.

2. The workflow yml file template used by GitHub actions is displayed.

By the way, if you test it as it is, it will fail. (Of course, because the swift command is executed, ...)

3. Modify the template yml file. For the time being, I modified it as follows so that it works at least. If you change the scheme name to that of your own project, you can use it as it is.

name: Swift

on: [push]

jobs:
  build:

    runs-on: macOS-latest

    steps:
    - uses: actions/checkout@v1
    # Select Xcode version
    - name: Select Xcode version
      run: sudo xcode-select -s '/Applications/Xcode_11.3.app/Contents/Developer'
    - name: Show Xcode version
      run: xcodebuild -version
      # Run build
    - name: Build
      run: xcodebuild
            -scheme Swift-github-actions
            -sdk iphonesimulator
            -configuration Debug
            build
      # Run unit test
    - name: Run tests
      run: xcodebuild
            -scheme Swift-github-actions
            -sdk iphonesimulator
            -destination 'platform=iOS Simulator,name=iPhone 11 Pro Max'
            clean test

4. Commit when you're done. Commit from "Start commit".

5. Open the "Actions" tab and check the workflow execution result. You must be successful! By the way, by default, Push to repository is the trigger for workflow execution.

Try using Swift Package Manager (SPM).

With the above workflow, even if you install SPM, the build and test should succeed as it is. Below, I installed RxSwift with SPM and then pushed it. It has been successful.

Impressions I tried

I also verified the use of Bitrise, but I thought it would be attractive to be able to complete it within the service of Github that I usually use. Since I have described only the minimum workflow, I would like to add it in the future so that I can do what I wrote at the beginning. If you have any corrections, please let us know.

Repository used for testing

https://github.com/u5-03/Swift-github-actions If you use the Public repository, Github Actions can be used for free, so if you want to use it for verification, use the Public repository!

Reference materials

0

COMMENT

Your email address will not be published.

CAPTCHA