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

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.

Related

I think I have done necessary code signing work but build still failing in Ionic

Building an Ionic app to try and test on my iPhone. I downloaded XCode last night and went in and created a profile with my Apple ID, as well as changing the bundle identified in the "General" and "Signing & Capabilities" tab. However when I run "ionic cordova build ios --prod" I get the error:
error: No profiles for 'io.ionic.starter' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'io.ionic.starter'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'MyApp' from project 'MyApp')
** ARCHIVE FAILED **
xcodebuild: Command failed with exit code 65
[ERROR] An error occurred while running subprocess cordova.
cordova build ios exited with exit code 65.
Re-running this command with the --verbose flag may provide more information.
It seems to me as though I have done the necessary code signing procedures that I read from Ionic's website, so I am unsure why it still isn't working.
To run the app in your iPhone there are several steps, check these:
You have created your app ID in the website.
You have created your provisioning profile in the website, and downloaded to your computer and added to your Mac (web -> download profile -> double-click)
You have created a development certificate (search how to create a certificate using a Certificate Signing Request generated in your Mac ) and then downloaded that certificate and added to your Mac.
There are two certificates. Distribution certificate is used to publish the app, but development certificate is used simply to run the project in your iPhone, you need that.
But honestly, it's all much easier if you use XCode instead of the console. In the console run the command without --prod, to apply ionic changes to the iOS project. Then if you want to run the app, it's easier if you open XCode and just click play.
With XCode there's the option "Automatically manage signing" that will handle most of this for you automatically. You just have to login to your account using XCode (it will prompt you) and let it do it for you.

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

Jenkins, Xcode 8.2.1 can not find the provisioning profile though it exists

I am running an iOS build on Jenkins locally. Using Xcode 8.2.1. Using manual signing (i.e. provisioning profile, Team and Signing Certificate correctly selected in Target-> General section.). When I build the app through Xcode, the app builds and archives fine using my ad-hoc distribution certificates. However, when I try building using Jenkins, I get the following error (I am using my own build script to build the app and not using the Jenkins Xcode build plugin)-
Check dependencies
[BCEROR]No profile matching 'xxx' found: Xcode couldn't find a profile matching 'xxx'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the General tab of the target editor.
Btw, I already tried the following but those did not help-
copying the provisioning profile in question to the /Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profiles location.

Automating iOS/WatchKit App Store submission - Code signing issue

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!

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.

Resources