简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM