21

I have the following goal to achieve: build and run an .app application using xcodebuild and ios-sim.

I'm using the following script to build the application.

xcrun xcodebuild \
  -scheme $XCODE_SCHEME \
  -project $XCODE_PROJECT \
  -configuration Debug \
  -destination generic/platform=iOS \
  -derivedDataPath \
  build

Then for running it, I'm using

ios-sim launch MyApp.app/ --devicetypeid "iPhone-6-Plus, 9.1"

Each time I receive the following message:

Program specified by service does not contain one of the requested architectures: ?

What is happening, that the app doesn't run?

Note: if I run the second command (ios-sim...) against the .app built from Xcode (the one contained in derived data) the procedure works fine.

Lorenzo B
  • 33,216
  • 24
  • 116
  • 190

1 Answers1

41

Ok. Figured out the issue.

You need to specify the correct destination. For example.

xcrun xcodebuild \
  -scheme $XCODE_SCHEME \
  -project $XCODE_PROJECT \
  -configuration Debug \
  -destination 'platform=iOS Simulator,name=iPhone 6 Plus,OS=9.1' \
  -derivedDataPath \
  build

In this way Xcode will create the folder (called build) containing your products (in particular look at Debug-iphonesimulator). The build dir is created within the dir you are running the xcodebuild command.

Now you can point that folder in order to run the ios-sim command (see ios-sim for more references) or simctl (see iOS 8: Building custom simulators and Build And Run iOS Apps In Commmand Line for more info).

Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
  • how to pass same simulator with different IDs in the -destination? – Qadir Hussain May 03 '16 at 11:17
  • Like I have 2 simulators of iPADs i) platform:iOS Simulator, id:0F9084E0-4E0D-43F7-AD3D-AB959744BD09, OS:9.3, name:iPad 2 ii) platform:iOS Simulator, id:4E05355C-EF57-4771-96D4-0F9FCF24A0D2, OS:9.3, name:iPad 2 – Qadir Hussain May 03 '16 at 11:17
  • How to run a workspace based project i.e project containing multiple pods projects. Please paste here complete command to run a -workspace – Qadir Hussain May 03 '16 at 11:23
  • 1
    @QadirHussain I used the method above today to build my workspace project. I just replaced `-project $XCODE_PROJECT` with `-workspace $XCODE_WORKSPACE` – Dawson Loudon Sep 15 '16 at 19:37
  • 4
    It build ok but didn't run the simulator – TomSawyer Apr 24 '17 at 05:21
  • Seems the second link in "more info" is dead, just FYI: http://dduan.net/post/2015/02/build-and-run-ios-apps-in-commmand-line/ - do you have an updated link for this reference? I'm curious about it's contents if it still is publicly available. – BHendricks Jul 21 '17 at 11:25
  • @BHendricks I cannot find it anymore. So, sorry. – Lorenzo B Jul 21 '17 at 15:22