Automating iOS/WatchKit App Store submission - Code signing issue - ios

I have a rather typical iOS 8 iOS/ObjC/Xcode 6.4 application, which includes a WatchKit extension. I have no trouble manually submitting to the App Store using Xcode using the Archive menu option.
We use a build server (Bamboo but it shouldn't matter). The build server currently automates builds and distributions through HockeyApp, but we manually build and upload to iTunes Connect using Xcode. We would like to automate the builds for the iTunes Connect, so we're certain same codebase is used for both HockeyApp and iTunes Connect (both TestFlight and App Store).
I'm having a heck of a time getting the script working for iTunes Connect, due (I believe) to the three targets that need signing (iOS app, WatchKit Extension, and Watch App).
I found this answer to a related question, which has been very helpful: https://stackoverflow.com/a/29605731. That suggests putting variables into the Provisioning Profile settings for the three targets. This works for building. But that question doesn't involve uploading to iTunes Connect, which is where I'm seeing trouble.
So my script looks like this:
APP_PROFILE="[the hex string]"
WATCHKITEXT_PROFILE="[another hex string]"
WATCHAPP_PROFILE="[one more hex string]"
First I make the xcarchive:
xcodebuild archive -project myProject.xcodeproj -scheme "myScheme" -archivePath myProject.xcarchive APP_PROFILE="${APP_PROFILE}" WATCHKITEXT_PROFILE="${WATCHKITEXT_PROFILE}" WATCHAPP_PROFILE="${WATCHAPP_PROFILE}"
which works fine. Then I export the archive to an .ipa:
xcodebuild -exportArchive -archivePath "myProject.xcarchive" -exportPath "myPath" -exportFormat ipa APP_PROFILE="${APP_PROFILE}" WATCHKITEXT_PROFILE="${WATCHKITEXT_PROFILE}" WATCHAPP_PROFILE="${WATCHAPP_PROFILE}"
which also reports success. Then I need to send the .ipa to iTunes Connect using the Application Loader's command-line tool (here I'm just verifying):
altool --validate-app -f "myProject.ipa" -u myUsername -p myPassword
which spits back this set of error messages:
*** Error: Unable to validate archive 'myProject.ipa': (
"Error Domain=ITunesConnectionOperationErrorDomain Code=1091 \"Invalid Signature. A sealed resource is missing or invalid. Make sure you have signed your application with a distribution certificate, not an ad hoc certificate or a development certificate. Verify that the code signing settings in Xcode are correct at the target level (which override any values at the project level). Additionally, make sure the bundle you are uploading was built using a Release target in Xcode, not a Simulator target. If you are certain your code signing settings are correct, choose \"Clean All\" in Xcode, delete the \"build\" directory in the Finder, and rebuild your release target. For more information, please consult https://developer.apple.com/library/ios/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html\" UserInfo=0x7fec4be78b80 {NSLocalizedRecoverySuggestion=Invalid Signature. A sealed resource is missing or invalid. Make sure you have signed your application with a distribution certificate, not an ad hoc certificate or a development certificate. Verify that the code signing settings in Xcode are correct at the target level (which override any values at the project level). Additionally, make sure the bundle you are uploading was built using a Release target in Xcode, not a Simulator target. If you are certain your code signing settings are correct, choose \"Clean All\" in Xcode, delete the \"build\" directory in the Finder, and rebuild your release target. For more information, please consult https://developer.apple.com/library/ios/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html, NSLocalizedDescription=Invalid Signature. A sealed resource is missing or invalid. Make sure you have signed your application with a distribution certificate, not an ad hoc certificate or a development certificate. Verify that the code signing settings in Xcode are correct at the target level (which override any values at the project level). Additionally, make sure the bundle you are uploading was built using a Release target in Xcode, not a Simulator target. If you are certain your code signing settings are correct, choose \"Clean All\" in Xcode, delete the \"build\" directory in the Finder, and rebuild your release target. For more information, please consult https://developer.apple.com/library/ios/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html, NSLocalizedFailureReason=iTunes Store operation failed.}"
I get the same error if I use the Application Uploader GUI.
I'm confident I'm using the correct profiles in the script, as when I export an archive in Xcode these are the three Xcode selects (that export will validate/submit fine).
I'm at a loss where to look next. Any and all help is appreciated - thanks!

Related

debug version of react-native IOS app builds successfully. Release version fails.

I've been able to successfully build the Debug version of this IOS app. However, I'd like to create an IPA to make sure it works on various iphones. The first thing I did was go product->scheme->edit scheme. I then switched from Debug to Release. After cleaning, and attempting to build the release version of the app. I immediately get an error: "MYapp has conflicting provisioning settings. MYapp is automatically signed, but provisioning profile MYApp Distribution has been manually specified. Set the provisioning profile value to "automatic" in the build settings editor, or switch to manual signing in the project editor(in target MYapp).
The first thing I tried was switching Code Signing Style to manual in build settings. This resulted in a new error:
error: Provisioning profile "MYApp Distribution" doesn't include signing certificate "iPhone Developer: Name here (XXXXXXXX)". (in target 'MYApp')
I went back to the General tab in Targets and clicked on "automatically manage signing". I tried to rebuild and got the same error the first time I tried to build.
I'm not sure where the conflict is coming from. This post indicated that simply clicking the automatic signing would do the trick.
I'm quite new to using Xcode and understanding provisioning profiles.
You simply can not build a release edition. The process of giving a release version is quite different. It goes from Xcode(local) to App Store(testFlight for testing) and then into App Store(Official Release).
I found this link and can relate to this situation.
Your provisioning profile isn't valid. It doesn't have a valid distribution certificate. You have to go to apple developer and it to certificates and profiles. Create it there and install it via keychain on your macbook. Othervise you can't build an ipa. More info here

ERROR ITMS-90046 using xctool / xcodebuild vs XCode Archive's success

I've got a command line script I use to compile, archive and submit my ios builds to ITC for TestFlight deployment. They work great, but I recently ran into an issue when trying to use an embedded framework within my otherwise working project. My script compiles and archives the project successfully but is getting ITC signing errors because of the embedded binary conflict.
xctool -workspace $BASE_DIR/$PROJECT_NAME -scheme $SCHEME -configuration $CONFIG clean archive -archivePath ./$PRODUCT_NAME.xcarchive
xcodebuild -exportArchive -archivePath ./$PRODUCT_NAME.xcarchive -exportPath $PRODUCT_NAME -exportFormat ipa -exportProvisioningProfile "$DIST_PROVISIONING_PROFILE_NAME"
# result is successful, with .ipa file generated
After a successful compilation my script tries to upload to ITC, and fails with the below msg. I get the same message if I try to upload the generated IPA file to ITC myself using Application Loader tool.
ERROR ITMS-90046: "Invalid Code Signing Entitlements. Your application
bundle's signature contains code signing entitlements that are not
supported on iOS. Specifically, value 'XXXXXXXXX.com.domain.Product'
for key 'application-identifier' in
'Payload/Product.app/Frameworks/Charts.framework/Charts' is not
supported. This value should be a string starting with your TEAMID,
followed by a dot '.', followed by the bundle identifier.
There is no application-identifier string used in my project or settings that I can find with a global search.
Extra Info
com.domain.Product would be my project's main bundleIdentifier, which has a distribution certificate and provisioning profile generated for it. Without the embedded binary that works just fine. The "Charts" embedded project has a bundleIdentifier but the team is set to "None" in the Info tab, and signing is set to Automatic. Since it is an embedded binary/framework, I'm assuming it doesn't independently sign it. When using Xcode's Archive, it is listed as a subset of the main Project with no independent identifier or entitlements.
I have also tried creating an independent appId and distribution provisioning profile for the embedded binary called "com.domain.ProductCharts" and setup the project correctly. This does not change the error.
I have further tried setting the embedded binary's project to use the same bundleIdentier and settings as the parent Project, but this does not change the error.
Why is xctool/xcodebuild unable to properly compile and sign this to get through to ITC, while the native Archiver can?
Currently, I encountered what I think is a bug in xcodebuild command similar to this, way I fixed it for me was to setup provisioning profile in the project settings. Try updating your project and run build again.
The investigation into the issue was here: https://forums.developer.apple.com/thread/14378
But others reported problem with associated domains:
SO question: Apple Store submit fails with Error ITMS-90046, but Associated Domains is not among entitlements
What is your OS, XCode ... etc?
Just a guess: Maybe you need to specify an application-identifier in your Entitlements.plist if you use the command line. Here https://developer.apple.com/library/ios/qa/qa1710/_index.html it is stated that in "In modern versions of Xcode.."
You said:
They work great, but I recently ran into an issue...
Have you created a new profile meanwhile and now there are two? Or two certificates? Here is a description on how to check your entitlements. Maybe this helps.
Creating .entitlements for the embedded framework will solve the issue only in Xcode 7.x. In the version 8.x the issue still exists.

Cocoapods/ CrittercismSDK causing App Submission Error: ITMS-90035

I am trying to upload an app to Testflight using XCode 6.3. However, on trying to validate the app, it is giving me the error message below:
I have tried regenerating the certificates and provisioning profiles without having any success.
ERROR: ERROR ITMS-90035: "Invalid Signature. Code object is not signed
at all. The binary at path [VirtualMechanic.app/dsym_upload.sh]
contains an invalid signature. Make sure you have signed your
application with a distribution certificate, not an ad hoc certificate
or a development certificate. Verify that the code signing settings in
Xcode are correct at the target level (which override any values at
the project level). Additionally, make sure the bundle you are
uploading was built using a Release target in Xcode, not a Simulator
target. If you are certain your code signing settings are correct,
choose "Clean All" in Xcode, delete the "build" directory in the
Finder, and rebuild your release target. For more information, please
consult
https://developer.apple.com/library/ios/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html"
That dsym_upload.sh script does not belong in the app bundle as it's the script that is run as part of a Build Phase that is used to upload the debug symbols to Crittercism.
Find the Build Phase that is copying it into the app bundle and remove it, however please note that it will still need to be run within a Build Phase.
Here's the official Crittercism Support Article related to the issue which recommends upgrading the pod to version 5.2.0.

Make Ad-hoc builds in Xcode 6 without signing in to developer account

Before Xcode 6, it was sufficient to provide only a *.p12 certificate and *.mobileprovision file to Xcode in order to export an *.ipa file for Ad Hoc builds.
Xcode 6 opens the Organizer as usual when the archive is ready, but when I press the "Export" button, the Organizer asks to select a Development Team. It does not allow me to proceed without one even though I have *.p12 and *.mobileprovision installed.
To save for Ad Hoc Development, select a Development Team to use for provisioning:
I know that a developer account could be exported from Xcode accounts pane, but there is a problem with that. It exports all certificates and mobileprovision files associated with it. This includes other profiles that I don't want to include (because I want to share the resulting export with a project team and don't want to include non-relevant profiles).
Is there any way to avoid this "helpful" feature and just export the relevant *.p12 and *.mobileprovision?
If you are using Testflight to upload adhoc builds, it's easier. Install the Testflight app for Mac and run it. Whenever you do an archive in Xcode, it auto shows a popup whether to upload it. You need not export the build from Xcode and avoid signing in to developer account.
Alternatively, if you don't want to distribute on Testflight, you can right click (or option click) on the build in Xcode > Organizer and select "Show in Finder" and right click the archived file for "Show package contents" and get the .app. Put the .app inside a directory called Payload and zip up the the file to Payload.zip. Rename Payload.zip to myapp.ipa to distribute manually.
Edit: A long time has passed since this answer. As for now I suggest using Fastlane for building the app from command line - with proper configuration it won't require signing with dev account.
Original answer below:
I don't know how to do it in xcode, however - I've managed to do it using command line tools:
xcodebuild -configuration Release -scheme SCHEME_NAME -workspace Workspace.xcworkspace clean archive -archivePath build/App
xcodebuild -configuration Release -exportArchive -exportFormat ipa -archivePath "build/App.xcarchive" -exportPath "build/App.ipa" -exportProvisioningProfile "PROVISIONING_PROFILE_NAME"
Just select "Use local signing assets" in the accounts drop down.
We were having the same problem. I tried building the project and making the archive using Xcode 6 and after that I go to the Organizer window of XCode 5 and export the adhoc build from there. It works fine.
This solution worked for me.
https://stackoverflow.com/a/26497744/1500634
Xcode Version 6.1
TestFlight Version 1.0 (320)
Download a previous version of Xcode, I just got the version 4.6.3 and it worked fine so far.
https://developer.apple.com/downloads/index.action
In my case, i use Unity 5.0.1p1 with Vuforia 4.2.3.
So, it have a QCARWrapper.bundle on "Build Phases > Copy Bundle Resources"
I delete it, and export. Works!!!
I do this only for EXPORT FOR AD HOC.
Hope this help someone.
In fact, you need to create a new Distribution profile, specific for Ad Hoc Deployment.
This can be found in the classic member center, but it is a new type of certificate.
You can then select which devices can be used to test the app as ou would do with a developer profile.
Alternatively you can use the TestFlight solution provided by Apple with iOS 8 to enable your user to have access to prereleases.

Xcode: Can I set Code Signing Profile from the command line

I have a batch build script that I run to build a common codebase for iOS apps into 100+ unique IPAs. I use Xcode 4.2 on OS X Lion.
The build settings for each app are set using PlistBuddy and the build works by running
PlistBuddy, installing app icons, running xcodebuild, then xcrun. It has been tested and
works correctly when targeting a single app.
Each app has a unique distribution provisioning profile that currently must be manually assigned via Xcode's Project settings -> Code Signing section (for release builds).
My problem is that the build script will not be able to match the App to its profile during the xcodebuild phase. It will simply try to use the most recent app's profile, then generate the error:
[BEROR]Code Sign error: Provisioning profile 'MOST RECENT APP'S PROVISIONING PROFILE ID HERE' can't be found.
Desperately looking for a way to either set this via command line (security, plistbuddy, or xcodebuild?). My batch script is quite useless without it.
I found the answer - it was simple. The problem was that in my Xcode target Code Signing settings, I had set a specific distribution profile for the build (out of 90 or so).
What fixed it was simply selecting the profile under "Automatic Profile selection".
Once that was done, xcodebuild was able to run successfully.

Resources