【问题标题】:GithubActions failed with running iOS Test TargetGithub Actions 运行 iOS 测试目标失败
【发布时间】:2021-04-23 03:32:37
【问题描述】:

我是 CI/CD 的新手,正在尝试通过 GithubActions 构建我的应用程序,成功构建后,测试目标出现错误。

Command line invocation:
    /Applications/Xcode_12.2.app/Contents/Developer/usr/bin/xcodebuild " -target" SimpleTestingTests " -sdk" iphonesimulator " -destination" "platform=iOS Simulator,name=iPhone 12,OS=14.3" " test"

Build settings from command line:
    platform = iOS Simulator,name=iPhone 12,OS=14.3

xcodebuild: error: Unknown build action ' -target'.
Error: Process completed with exit code 65.

这些是 Github 操作的日志。

这些是我的 .yml 文件包含的内容;

name: Feature pipeline

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    name: Build
    env:
      # SCHEME: "Actions"
      SCHEME: 'SimpleTesting'
      DEVICE: "iPhone 11"
      DERIVED_DATA_PATH: "DerivedData"
    runs-on: macOS-latest
    steps:
    - name: Checkout project
      uses: actions/checkout@v1
    - name: Build application
      run: |
        xcodebuild SimpleTesting.xcodeproj \
            -scheme SimpleTesting\ iOS \
            -destination platform=iOS\ Simulator,OS=13.3,name=iPhone\ 11 \
            clean test | xcpretty

  unit_test:
    name: Unit test
    env:
      DEVICE: "iPhone 11"
      DERIVED_DATA_PATH: "DerivedData"
      UNIT_TEST_TARGET: "SimpleTestingTests"
    runs-on: macOS-latest
    needs: build
    steps:
    - name: Run unit tests
      run: xcodebuild \
          -target SimpleTestingTests \
          -sdk iphonesimulator \
          -destination 'platform=iOS Simulator,name=iPhone 12,OS=14.3' \
          test

然后我认为问题可能出在-target 上,并用-scheme 进行了尝试,但没有出现完全相同的错误。

我从 Gist 中获取了 yml 文件,您可以看到文件中有不必要的变量,但我想了解如何成功运行我的代码?错误在哪里?如何解决此问题以成功运行部署环境文件?

提前致谢

【问题讨论】:

    标签: swift continuous-integration github-actions


    【解决方案1】:

    也许没有告诉命令将在多行中(在开头使用|)?
    -target 参数无效,但我认为它应该使用 -scheme 参数工作。 尝试在您的unit_test 任务的run 步骤上使用它:

          run: |
            xcodebuild SimpleTesting.xcodeproj \
                -scheme SimpleTesting \
                -sdk iphonesimulator \
                -destination 'platform=iOS Simulator,name=iPhone 12,OS=14.3' \
                test
    

    【讨论】:

    • 当我运行 xcodebuild test -scheme SimpleTesting -destination "platform=iOS Simulator,name=iPhone 11,OS=14.3" 这适用于我的终端,但在 Github 的机器上,我猜路径不正确,如 The directory /Users/runner/work/SimpleTesting/SimpleTesting does not contain an Xcode project
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-25
    • 2021-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-29
    • 2022-07-26
    相关资源
    最近更新 更多