3

I'm in a strange situation where I can get xctool to run my test but I cant figure out the equivalent command line to get xcodebuild and/or fastlane scan to run my tests. I have an iPad only application with a single scheme and two targets (otto and ottoTests)

Working XCTool Commandline

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

Xcodebuild - fail

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

I get this error that

A build only device cannot be used to run this target

enter image description here

So I'm kind of at a loss here exactly what is different between xcodebuild and whatever xctool is running.

Community
  • 1
  • 1
Jeef
  • 26,861
  • 21
  • 78
  • 156

2 Answers2

7

AFAICS, you are missing the -destination argument in the xcodebuild command. Refer to this tutorial for sample code.

Arthur Gevorkyan
  • 2,069
  • 1
  • 18
  • 31
2

You're missing the -destination argument.

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

To list all valid values for destination run instruments -s devices.

e.g.

$ 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)

Unfortunately you can't just copy and paste these lines. You'll need to use your impressive human pattern matching skills to fill in the proper values for the platform=, name=, and OS= parameters to -destination.

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

mkirk
  • 3,965
  • 1
  • 26
  • 37