Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command line created and installed iOS .app crashes when booting inside the simulator

I'm in the middle of some proof of concept test of mine, using xcodebuild and xcrun in order to create and deploy an .app onto my ios Simulators (or even to deliver the .app directory to my final client).

Whatever, the thing is I deal sucessfully with all the many needed steps to create from scratch the .app file (well, directory), but then I get an app crash after I execute these next 2 lines, particularly the second one, once I try to upload and then run the .app onto the simulator:

xcrun simctl install booted $(PWD)/build/Debug-iphoneos/APP_NAME.app
xcrun simctl launch booted somebundle.id.from.me    <- CRASH

No matter what I try, that xcrun command yields this error onto system.log:

Error Domain=FBSOpenApplicationErrorDomain Code=1 "(null)"

Apparently my app gets installed onto the simulator (I've erased it many times to create a fresh install), it even boots (the splash screen grows from the icon appearing on the simulator desktop), but the first thing I get when I expect the app to pass the splash screen, is that beforementioned crash line error (in system.log file).

Some people say I might have some phantom empty variable floating around in my schemas definition panel. I've checked it and it's not the case. No variables whatsoever.

Some other people say old versions of the app might be alive in the task scheduler of the Simulator. Indeed, sometimes I have found my task there as an old task from the past, but pressing "home" twice to go to the simulator task manager, killing it, and trying to relaunch my .app file with xcrun again does nothing, the crahs is still there. I even stop old executions of the same app launched from Xcode itself (with the STOP button), but no luck.

So, I'm definitely lost. I can't launch my recently created .app onto the simulator via command line.

It has failed with a 9.3 (iPhone 4s) simulator, and with a 9.3 (iPhone 6plus) simulator. My XCode Tools are the ones included in my XCode 7.3.1. I'm using "El Capitán".

I can't think of anything else.

I'd like to be able to upload AND run my .app via "command line tools". I hope it's possible somehow, or at least it seems I'm really close to success.

Any other hint I might have overlooked?

Greetings and thanks.

like image 395
Isaac Avatar asked Jan 05 '23 20:01

Isaac


1 Answers

Another case of successfully self answered question :)

Short version: I was building a "real ios device" compiled version and then trying to install it onto the Simulator. Changing xcrun and xcodebuild (architecture and path) parameters did the trick and now the app works like a charm when run from the Simulator.


Long version: What was the problem? The architectures and paths I was (wrongly) choosing when invoking xcodebuild One of the parameters to define my compilation architecture was implicitly declaring "ARM" (-sdk iphoneos), but the architecture the Simulator runtime engine uses is i386 (we're in a MAC). As expected, once the "real-device-compiled-.app" got installed onto the Simulator, the Simulator itself wouldn't understand how to launch it and then the cryptic crash happens.

What gave me the clue? 2 other questions I found somewhere else, in Stack Overflow. Look for extra info here:

Apps manually installed in simulator crashes upon load

xcodebuild: simulator or device?

What lead me to check those other 2 threads? One .log file I found somewhere else than the default and dull /var/log/system.log

RANT: There's a problem with the MANY .log files you can find on a modern MAC !! /RANT

Whatever, in the process of discovering which .log file was the useful one for me, I discovered these ones:

  • $HOME/Library/CoreSimulator/CoreSimulator.log (not really useful for my problem, anyway).
  • $HOME/Library/CoreSimulator/[UGLY_HASH_CORRESPONDING_TO_THE_SIMULATOR_YOU_ARE_USING]/system.log

THAT last one was the good one. At the end of this .log file, I found additional info when trying to boot the "badly built .app" file. The log said something like this:

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

And then the word "architectures" gave me the hint to solve my problem and what to look for.


And that's it. In case someone finds him/herself in the same situation in the future I hope all this info I wrote above will be useful.

Greetings.


PS: If you can't find what's the folder where your troublesome Simulator (and its associated .log file) live, (there can be literally dozens of installed Simulators), y̶o̶u̶ ̶c̶a̶n̶ ̶u̶s̶e̶ ̶a̶n̶ ̶A̶l̶c̶a̶t̶r̶a̶z̶ ̶p̶l̶u̶g̶i̶n̶ ̶c̶a̶l̶l̶e̶d̶ ̶X̶C̶o̶d̶e̶W̶a̶y̶.̶ ̶O̶n̶c̶e̶ ̶t̶h̶i̶s̶ ̶p̶l̶u̶g̶i̶n̶ ̶i̶s̶ ̶i̶n̶s̶t̶a̶l̶l̶e̶d̶ ̶a̶n̶d̶ ̶p̶r̶o̶p̶e̶r̶l̶y̶ ̶r̶u̶n̶n̶i̶n̶g̶,̶ ̶y̶o̶u̶ ̶c̶a̶n̶ ̶c̶h̶e̶c̶k̶ ̶t̶h̶e̶ ̶p̶a̶t̶h̶ ̶o̶f̶ ̶y̶o̶u̶r̶ ̶i̶O̶S̶8̶+̶ ̶S̶i̶m̶u̶l̶a̶t̶o̶r̶ ̶d̶o̶i̶n̶g̶ ̶t̶h̶i̶s̶ ̶f̶r̶o̶m̶ ̶X̶C̶o̶d̶e̶:̶

X̶c̶o̶d̶e̶ ̶-̶>̶ ̶W̶i̶n̶d̶o̶w̶s̶ ̶-̶>̶ ̶X̶C̶o̶d̶e̶W̶a̶y̶ ̶-̶>̶ ̶G̶o̶ ̶t̶o̶ ̶i̶O̶S̶8̶+̶ ̶S̶i̶m̶u̶l̶a̶t̶o̶r̶ ̶F̶o̶l̶d̶e̶r̶ ̶F̶i̶n̶d̶e̶r̶ ̶w̶i̶l̶l̶ ̶o̶p̶e̶n̶,̶ ̶a̶n̶d̶ ̶t̶h̶e̶r̶e̶ ̶w̶i̶l̶l̶ ̶b̶e̶ ̶y̶o̶u̶r̶ ̶.̶l̶o̶g̶ ̶f̶i̶l̶e̶ ̶:̶)̶ ̶

you can read the comments below this one and see the short and proper way to do it :)

like image 138
Isaac Avatar answered Feb 14 '23 17:02

Isaac