【问题标题】:How to fix error with xcodebuild in GitHub Actions如何修复 GitHub Actions 中的 xcodebuild 错误
【发布时间】:2020-04-15 23:48:32
【问题描述】:

我正在尝试使用 GitHub Actions 在 Github 中为我的私人 Swift 项目设置一个 CI。我使用了 Github 提供的标准 swift.yml 模板,并进行了一些修改。这是文件ci.yml

name: Swift

on: [push]

jobs:
  build:

    runs-on: macOS-latest

    steps:
    - uses: actions/checkout@v1
    - name: Run tests
      run: xcodebuild -project 'MyApp.xcodeproj' -scheme 'MyApp' -destination 'platform=iOS Simulator,name=iPhone 11 Pro Max,OS=13.2' clean test
    - name: Build App
      run: xcodebuild -project 'MyApp.xcodeproj' -scheme 'MyApp' -destination 'generic/platform=iOS' -configuration Release build CODE_SIGNING_ALLOWED=NO

当我将新构建推送到存储库时,操作会触发,但在测试中失败。

xcodebuild -project 'MyApp.xcodeproj' -scheme 'MyApp' -destination 'platform=iOS Simulator,name=iPhone 11 Pro Max,OS=latest' clean test

我在本地运行并且所有测试都通过了。在 GitHub Actions 上,我遇到了这个错误

Set up job                  0s
Run actions/checkout@v1     2s
Run tests                   34s
    ##[error]Process completed with exit code 70.
1     Run xcodebuild -project 'MyApp.xcodeproj' -scheme 'MyApp' -destination 'platform=iOS Simulator,name=iPhone 11 Pro Max,OS=13.2' clean test
4        xcodebuild: error: Unable to find a destination matching the provided destination specifier:
5             { platform:iOS Simulator, OS:13.2, name:iPhone 11 Pro Max }
6
9        Ineligible destinations for the "MyApp" scheme:
10           { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
11           { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }
12    ##[error]Process completed with exit code 70.
Build App                   0s
Complete job

这个测试应该通过了。我不确定如何解决这个问题,以便行动不再失败

【问题讨论】:

  • 在 Github 构建服务器上好像没有安装这个模拟器
  • This project 使用完全相同的构建文件,并且可以正常工作。我是否遗漏了项目中的某些内容或我应该启用的 Github 设置?

标签: ios swift continuous-integration xcodebuild github-actions


【解决方案1】:

我能够通过强制 Xcode 11 修复此错误。我使用以下代码使其工作。现在所有测试都通过了,一切正常。

name: Swift

on: [push]

jobs:
  build:

    runs-on: macOS-latest

    steps:
    - uses: actions/checkout@v1
    - name: Force Xcode 11
      run: sudo xcode-select -switch /Applications/Xcode_11.3.app
    - name: Run tests
      run: xcodebuild clean test -project "MyApp.xcodeproj" -scheme "MyApp" -destination "platform=iOS Simulator,name=iPhone 11 Pro Max,OS=latest"
    - name: Build App
      run: xcodebuild -project "MyApp.xcodeproj" -scheme "MyApp" -destination "generic/platform=iOS" -configuration Release build CODE_SIGNING_ALLOWED=NO

【讨论】:

    猜你喜欢
    • 2020-01-14
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    • 2021-03-05
    • 2012-02-28
    • 2021-06-21
    • 2020-01-11
    • 2020-11-18
    相关资源
    最近更新 更多