2015-12-14 202 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/