1

I'm trying to build an IOS app from the command line instead of through Xcode it's been an uphill struggle. My project builds fine in Xcode by going to Product -> Archive, but when I try to do what I think is the same thing in the Terminal with xcodebuild, it fails due to some missing header files.

How do I find out what actually happens when I click Archive?

Alternatively, if anyone can spot where my error is, the command I think should be working is:

xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Beta -destination 'generic/platform=iOS' -archivePath <path to xcarchive file> archive
Cœur
  • 37,241
  • 25
  • 195
  • 267
Mourndark
  • 2,526
  • 5
  • 28
  • 52

1 Answers1

4

Hi I have a guess because I could not find the actual documentation. I have a small script that works for deployment directly on the App Store using my private keys. I'm sharing with you if it can helps, I'm asking you to accept the answer.

#clean and build
xcodebuild -workspace ./my-app.xcworkspace/ -scheme my-app -sdk iphonesimulator12.0 clean # analyze
xcodebuild -workspace ./my-app.xcworkspace/ -scheme my-app -destination generic/platform=iOS build

#archive
xcodebuild -workspace ./my-app.xcworkspace/ -scheme my-app -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/my-app.xcarchive

# create build ipa
xcodebuild -exportArchive -archivePath $PWD/build/my-app.xcarchive -exportOptionsPlist exportOptions.plist -exportPath $PWD/build

# /Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool
# upload app for testflight
export USERNAME=myusername
export PASSWORD=mypassword
# password is generated at appleid.apple.com
cd build
altool --upload-app -f "my-app.ipa" -u $USERNAME -p $PASSWORD

References

  1. How do I determine the target architecture of static library (.a) on Mac OS X?
  2. https://github.com/fastlane/fastlane/issues/13401

  3. https://medium.com/xcblog/xcodebuild-deploy-ios-app-from-command-line-c6defff0d8b8

You mentioned that your app fails because of header files, I'm suggesting that you check this out because it can be a pain in the ... sometimes. By the way my app has some native headers too.

enter image description here

JBarros35
  • 976
  • 1
  • 12
  • 18
  • 1
    Thanks for the comprehensive answer, that's really useful! Unfortunately your version of the archive command doesn't work either but I'll check out the links you posted. – Mourndark Feb 11 '20 at 09:04