Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build and run an app on simulator using xcodebuild

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.

like image 567
Lorenzo B Avatar asked Nov 30 '15 16:11

Lorenzo B


1 Answers

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

like image 108
Lorenzo B Avatar answered Oct 11 '22 20:10

Lorenzo B