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?

有帮助吗?

解决方案

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

其他提示

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top