Build and run an app on simulator using xcodebuild

24,453

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

Share:
24,453
Lorenzo B
Author by

Lorenzo B

Software Engineer | PhD in Computer Science

Updated on July 09, 2022

Comments

  • Lorenzo B
    Lorenzo B almost 2 years

    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.