【问题标题】:Xcode command line test execution issuesXcode 命令行测试执行问题
【发布时间】:2016-03-19 22:45:41
【问题描述】:

我处于一种奇怪的情况,我可以让xctool 运行我的测试,但我无法找出等效的命令行来让xcodebuild 和/或fastlane scan 运行我的测试。 我有一个只有 iPad 的应用程序,只有一个方案和两个目标(otto 和 ottoTests)

工作 XCTool 命令行

xctool -scheme otto \
       -sdk iphonesimulator \
        CODE_SIGN_IDENTITY=""\
        CODE_SIGNING_REQUIRED=NO \
       -reporter pretty\
       -reporter junit:./test-reports/otto.xml\
        build test

Xcodebuild - 失败

xcodebuild -sdk iphonesimulator \
           -scheme otto \
      test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

我得到这个错误

只能使用构建设备来运行此目标

所以我有点不知所措,xcodebuildxctool 正在运行的东西之间到底有什么不同。

【问题讨论】:

    标签: ios xcode unit-testing xcodebuild xctool


    【解决方案1】:

    AFAICS,您在 xcodebuild 命令中缺少 -destination 参数。示例代码请参考tutorial

    【讨论】:

    • so -d 'iOS Simulator' 应该可以工作......我会试一试
    【解决方案2】:

    您缺少-destination 参数。

    xcodebuild \
      -workspace MyApp.xcworkspace \
      -scheme MyWatchKitApp
      -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.1' \
      build
    

    列出目标运行instruments -s devices 的所有有效值。

    例如

    $ instruments -s devices
    Known Devices:
    Apple TV 1080p (10.0) [A0DA01A6-CAC6-4562-93B9-749920DCEFAA] (Simulator)
    Apple Watch - 38mm (2.0) [9D6C53FB-0D69-4A0A-83CB-CBB55EE63AA6] (Simulator)
    Apple Watch - 38mm (2.0) [BF24D5AC-8DB5-4D18-A6FD-B92292084B8A] (Simulator)
    Apple Watch - 42mm (2.0) [286C7921-3689-4832-B0C7-52B412C0C2F5] (Simulator)
    Apple Watch - 42mm (2.0) [16144840-5E1B-4934-A82D-E2A49FF79392] (Simulator)
    iPad 2 (8.1) [8D0AD02D-C78F-4D59-BBA5-1E7AB452A852] (Simulator)
    iPad 2 (9.3) [16D6261C-8FBD-4865-8E6A-840800A96C4A] (Simulator)
    iPad Air (10.0) [374DB3F8-65CB-4AD1-919F-808C0C2FCEE1] (Simulator)
    iPad Air (8.1) [E83D1680-C5EE-4E86-B847-16FF8C0B7F98] (Simulator)
    iPad Air (9.3) [82F4AEC6-A778-44D9-88DB-A95126904E1A] (Simulator)
    iPad Air 2 (10.0) [E68ED558-4E83-46A3-892C-93786CF947FC] (Simulator)
    iPad Air 2 (9.3) [F1521496-CA53-41CC-A1DA-F605B961B3E5] (Simulator)
    iPad Pro (12.9 inch) (10.0) [D87A6656-DEB4-41BB-B45A-2A3D85BFED8A] (Simulator)
    iPad Pro (9.3) [968E6D5E-6881-4DB2-B274-2BF0DC0FDE24] (Simulator)
    iPad Pro (9.7 inch) (10.0) [55B31895-0A68-4060-8441-A845F63FA4FB] (Simulator)
    iPad Retina (10.0) [7725C135-7211-43E2-8BB4-9455C3820DB4] (Simulator)
    iPad Retina (8.1) [E4825B7A-5A53-49AF-AD27-62711CA97B66] (Simulator)
    iPad Retina (9.3) [F0523C54-9F37-4209-844C-9CA4A174791A] (Simulator)
    

    很遗憾,您不能只复制和粘贴这些行。您需要使用令人印象深刻的人类模式匹配技能将platform=name=OS= 参数的正确值填入-destination

    来源http://www.mokacoding.com/blog/xcodebuild-destination-options/

    【讨论】:

      猜你喜欢
      • 2012-09-15
      • 1970-01-01
      • 2011-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-18
      • 2013-10-28
      • 2020-12-23
      相关资源
      最近更新 更多