Specify XCode version for GitHub workflows

16 April 2020

I wrote a unit test that used the XCTUnwrap function. This feature was added in XCode 11 and

“Asserts that an expression is not nil and returns the unwrapped value.”

However, when I pushed my code to GitHub, the build broke with the following error.

error: use of unresolved identifier ‘XCTUnwrap’

To fix this I updated my .github/workflows/swift.yml file to include the XCode version. I found the solution from this GitHub Community Forum Post. You can specify the version in the env using the DEVELOPER_DIR tag. GitHub maintains a list of available XCode versions here.

Here is what my swift.yml file looks like. This is for a swift package that is included in other iOS projects.

name: Swift

    branches: [ master ]
    branches: [ master ]
  DEVELOPER_DIR: /Applications/Xcode_11.4.app/Contents/Developer


    runs-on: macos-latest

    - uses: actions/[email protected]
    - name: Build
      run: swift build -v
    - name: Run tests
      run: swift test -v

The kofi logo of a coffee mugLike this? Please buy me a coffee!