2015-12-14 205 views
3

我在一个奇怪的情况,我可以得到xctool来运行我的测试,但我无法弄清楚等效命令行得到xcodebuild和/或fastlane scan来运行我的测试。 我有一个单一的方案和两个目标(奥托和ottoTests)Xcode命令行测试执行问题

工作XCTool命令行

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

xcodebuild联编一个iPad唯一的应用程序 - 故障

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

我得到这个错误

构建专用设备不能用于运行此目标

enter image description here

所以我有点在这里损失究竟什么是xcodebuild和任何xctool运行之间的不同。

回答

7

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

+0

所以-​​d“iPhone模拟器”应该工作...我给它一个镜头 – Jeef

+0

@Jeef,请记住我的答案,因为接受,如果它帮你。提前致谢。 –

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/