0

I'm using xcodebuild to build and install my app on the simulator (by copying the .app to ~/Library/Application Support/iPhone Simulator/6.1/Applications/UUID/) from the command line. I use:

xcodebuild -target MyApp 
           -configuration Debug
           CPU_ARCHITECTURE=iphonesimulator6.1
           install DSTROOT=Products

The .app is produced in /project_root/Products/Applications/MyApp.app However, every time I run the .app on my simulator, it crashes immediately.

I compared the .app that is created from Xcode's Run to xcodebuild's output from above. The two MyApp.apps are pretty much identical, but the MyApp binary inside of MyApp.app differ (the Xcode one is almost twice the memory footprint). I even tried copying the binary from Xcode's MyApp.app to xcodebuild's, and that worked too.

Any ideas why xcodebuild's .app is crashing?

johngraham
  • 6,461
  • 2
  • 16
  • 22
  • Probably you haven't set the right VALID_ARCHS... – Richard J. Ross III May 03 '13 at 18:41
  • Hmm thanks for the tip, can you elaborate on that? I tried adding VALID_ARCHS="armv7 armv7s i386" and variants of those, but the `.app` is still crashing on startup. I also tried following some suggestions to set the `ARCHS` and `ONLY_ACTIVE_ARCH` flags too: http://stackoverflow.com/questions/12889065/no-architectures-to-compile-for-only-active-arch-yes-active-arch-x86-64-valid – johngraham May 03 '13 at 19:00
  • look at all the xcodebuild options - you can set the target, the build configuration, etc - probably one of these is not being specified. – David H May 03 '13 at 19:22
  • Thanks, got it working now. I also had to change `CPU_ARCHITECTURE=` to the `-sdk` flag. – johngraham May 03 '13 at 22:34

2 Answers2

1

Though there was no explicit "answer" to my question that I can mark as correct, here's my solution just in case anybody else has the same problem. Props to Richard for pointing me in the right direction. I played around with different settings for VALID_ARCHS and set it to "i386" (the simulator's architecture). Additionally, the syntax was wrong for CPU_ARCHITECTURE. xcodebuild uses the -sdk option instead. The following worked for me:

xcodebuild -target MyApp
           -configuration Debug
           -sdk iphonesimulator6.1
           VALID_ARCHS="i386"
           install DSTROOT=Products
johngraham
  • 6,461
  • 2
  • 16
  • 22
0

This is my script that makes .app for simulator :

(Replace "MyApp" with your app name)

XCODE_WORKSPACE=/Users/MacBook/iOS/MyApp.xcworkspace
xcrun xcodebuild \
  -scheme MyApp \
  -workspace $XCODE_WORKSPACE \
  -configuration Debug \
  -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.2' \
  -derivedDataPath \
  build
matt
  • 607
  • 7
  • 20