Search code examples
iosxcodexcodebuildxcrun

xcrun error domain=FBSOpenApplicationErrorDomain, code=1


I'm trying to build an app via the command line, using these commands:

xcodebuild PRODUCT_BUNDLE_IDENTIFIER=com.myapp \
PROVISIONING_PROFILE="XXXX-XXXX-XXXX-XXXX-XXXX" \
CUSTOM_URL="http://mycustomurl.com" \
-project AppName.xcodeproj \
-scheme AppName \
-sdk iphoneos \
-configuration AppStoreDistribution archive -archivePath $PWD/build/AppName.xcarchive

then:

xcodebuild -exportArchive \
-archivePath $PWD/build/AppName.xcarchive \
-exportPath AppName.app \
-exportFormat app

Now, I would like to run this app to test using the emulator, so I run these commands to install and launch the app:

xcrun -v simctl install booted AppName.app #Install
xcrun simctl launch booted com.myapp #Launch

The app instantly closes and xcrun comes back:

An error was encountered processing the command (domain=FBSOpenApplicationErrorDomain, code=1):
The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 1.)

Now, if I try to launch my app with xcode (by gui) this starts without any problems.

I've also tried to:

  • Reset the Emulator
  • Check the App Transport Security Settings
  • Close all instance of the app

Solution

  • You're building for iphoneos (I can see a "-sdk iphoneos" parameter in your xcodebuild command line). Then you're trying to install the resulting .app object onto the simulator (!!).

    That will produce an architecture mismatch, and thus that cryptic runtime error.

    Change your compilation commands from "-sdk iphoneos" to something like "-sdk iphonesimulator9.3" (in case this is the version you need). If in doubt, type "xcodebuild -showsdks" and a list of installed SDK's will appear on screen. Choose the one you need.

    You'll probably need to mess with -arch parameter also and change it from ARM to i386 (Remember the Simulator runs onto your intel MAC ).

    Try and tell us if it works.