DEV Community

Monica Granbois
Monica Granbois

Posted on • Originally published at

Specify XCode version for GitHub workflows

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/


    runs-on: macos-latest

    - uses: actions/checkout@v2
    - name: Build
      run: swift build -v
    - name: Run tests
      run: swift test -v

Discussion (1)

hlc0000 profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct

Hello, I'm IOS developer. Recently, when developing applications using swift, I found that there are few caches written in pure swift. So I wrote a cache - swift cache, which is a lightweight general IOS cache library using swift 5. If you are using swift for development and need to use cache, maybe you can try swiftlycache, maybe you will like it, if you can also introduce it to your friends. Thank you