[SOLVED] Error uploading to TestFlight: 'Invalid IPA: Must specify MinimumOSVersion'

I have switched from PhoneGap Build to using the command line to build my project. I’ve written a bash script to build the app using ionic. Here are some of the commands I’m running:

sudo ionic build --release ios
xcrun -sdk iphoneos PackageApplication -v  "pp.app" -o "pp.ipa" --sign "$CERTIFICATE" --embed "$PROVISION"

These commands work fine without any errors and it produces an ipa file in the directory I’ve specified. When I try to upload the ipa file to TestFlight I get the following error:

'Invalid IPA: Must specify MinimumOSVersion'

I’m trying to avoid using xcode to build if at all possible, but I tried it and couldn’t get that working either. Any ideas on how to resolve this? Thanks!

Adding this row to the Info.plist file fixes the error and uploads the app:

MinimumOSVersion          String          6.0

However, in the Testflight app it says the app is not compatible with my iPhone 5. The deployment target is set in xCode. Any ideas?

Solution

After several different attempts to get this working, I found a solution. I believe it was a combination of issues in my build process that caused this error, so hopefully I cover all of the things that I did to get this working.

Building the app

security unlock-keychain -p "yourkeychainpassword" ~/Library/Keychains/login.keychain
sudo ionic build ios --device --release

First I unlocked the keychain using my keychain password.
Then I added the device flag to the build. When I didn’t add this flag it was trying to build it for an emulator which was causing all sorts of problems. When I did add the device flag I ran into the following error

Code Sign error: No matching provisioning profile found

To solve the above error I ran this in my terminal (credit)

sudo cp -r ~/Library/MobileDevice/ /Library/MobileDevice

And I modified the myApp/platforms/ios/cordova/build-release.xcconfig file to point to my provisioning profile and certificate (credit1 credit2)

PROVISIONING_PROFILE=12345678-9012-3456-7890-123456789012

CODE_SIGN_IDENTITY = iPhone Distribution: Company (ABCD123456)
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Distribution: Company (ABCD123456)

I am going to work on adding this as a hook since the provisioning profile is dynamic. After making these changes I was able to run the build command without errors.

Packaging the app

To package the app I ran the xcrun command, but I removed the embedding and signing since I did that above. Also, I made sure to get the app file from the device folder instead of the emulator folder.

xcrun -sdk iphoneos PackageApplication -v  \
"platforms/ios/build/device/myApp.app" -o \
"platforms/ios/build/device/myApp.ipa"

After this I was able to upload the ipa to Testflight without opening Xcode. Sorry if any of this is blatantly obvious. I’m new to all of this, so hopefully it helps someone. Any feedback on how I could improve it is welcomed. :smile: