loading...

Specify XCode version for GitHub workflows

monicag profile image Monica Granbois Originally published at monicagranbois.com ・1 min read

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

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
env:
  DEVELOPER_DIR: /Applications/Xcode_11.4.app/Contents/Developer

jobs:
  build:

    runs-on: macos-latest

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

Discussion

pic
Editor guide
 
Sloan, the sloth mascot 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
github.com/hlc0000/SwiftlyCache