Xcode won't recognize my new provisioning profile - iphone

My app's development provisioning profile expired a couple of weeks ago, so I went to the provisioning portal to get a fresh new one. After obtaining it, I visited the Xcode Organizer, removed the expired profile from my devices as well as my Mac, then imported the new profile. Xcode installs the profile onto my devices immediately, and my app runs again on the devices.
The problem is that while the Organizer is able to see the new profile and install it as normal, the IDE gets confused between the old one and the new one. Every time I try to build the app, it fails immediately. The error console tells me that Xcode can't find the old profile, because the GUID listed belongs to the old one. That's strange; I thought Xcode would've been aware of the new profile by now.
I've tried removing the new profile from my devices and my Mac, then reinstalling the profile. Doesn't work, Xcode is still trying to look for the old one. I've also tried selecting a different profile to make Xcode forget the old one, then selecting the new one. I've even tried manually entering the GUID of the new one in the Other choice. Yet Xcode still insists on looking for the old profile, which by now is already gone from my Mac.
How do I convince Xcode that I've generated a new provisioning profile for my app for it to use?

tl;dr: turns out I simply had to edit the project file manually to tell Xcode of the new profile. Now, I don't know why I had to manually update the project file. Perhaps I did something wrong during the process of importing the new profile to Xcode, so it didn't realize my new profile had come in. Or the file system choked midway and Xcode wasn't able to update itself. Oh well.
Now for the fun technical part:
IMPORTANT: As with anything else that involves modifying files you shouldn't be modifying: make sure to back up your .xcodeproj bundle and/or your entire Xcode project, or make sure your Xcode project is kept in proper version control. You don't want to mess up and cause Xcode to stop building your project onto your device, without anything to fall back on.
I peeked into the contents of my app's .xcodeproj bundle (Xcode is not running at this time). To view these, open your project folder in Finder, then Control-click on your .xcodeproj file and choose Show Package Contents:
Breeze.xcodeproj/
Daniel.mode1v3
Daniel.pbxuser
project.pbxproj
Then opened project.pbxproj in a text editor (it's text, not binary), and looked around for build configuration information.
There's a section labeled /* Begin XCBuildConfiguration section */ (which you can find using your editor's search function). It's a list of entries, each of which represents a code-signing configuration for a given profile in a given build configuration.
Here's information about the profile I use to sign my binary for development:
1D6058940D05DD3E006BFB54 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Daniel Tan (XXXXXXXXXX)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Breeze_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvmgcc42;
INFOPLIST_FILE = "Breeze-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
PRODUCT_NAME = "Breeze";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "36F99F3E-805F-47A7-95D4-FF8324711CBE";
SDKROOT = iphoneos;
};
name = Debug;
};
Of note is this line:
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "36F99F3E-805F-47A7-95D4-FF8324711CBE";
That's the GUID reported by the build error; the identifier of my old, expired provisioning profile.
All I had to do was replace it with the GUID of the new profile:
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "E6E6369E-FD58-4886-9C3A-72C9DAE36501";
I open my project in Xcode again, and now my app builds and installs on my devices successfully, using the new provisioning profile.

Here's how I did it in Xcode 4:
Select Don't Code Sign from Project > Build Settings > Code Signing
Clean the build
Build it again - should show an error like "this stuff needs signing"
Choose the new profile from the Code Signing
Rebuild

I was able to fix this error by changing it to "Don't Code Sign" in Code Signing Identity. Build, and you get the error "code signing is required for product type ...blah...". Then go back and select the right profile. Build and all good. This happened to me because my certificate expired and I renewed it. In addition to the above I also had to remove the old certificate from my keychain, and the Organizer.

Close de xcode
edith with texmate, youtproject.xcodeproj
Find this line "PROVISIONING_PROFILE[sdk=iphoneos*]" = "E8DEEBA3-FE0A-419F-9F7E-258572D55807";
Erase
Restart xcode build & archive for enterprise

To add to the solution above, you can use the lovely xcodeproj gem to help with stuff like this. Note, it does convert your OpenStep key = value; -style plist to XML. Note: I have found that Xcode changes it back if you make project file changes in Xcode later. Either style of file builds fine either in Xcode or from the command line. For a sample of how I use it
project = Xcodeproj::Project.new('Foo.xcodeproj')
csi_key = 'CODE_SIGNING_IDEDNTITY'
project.targets.each do |target|
target.build_configurations.each do |conf|
conf.build_settings[csi_key] = 'iPhone Developer: Cool Dood (XYZ123)' unless conf.build_settings[csi_key] == nil
end
end
Here's a gist of how I use it: https://gist.github.com/82times/5594887

My solution to this problem was:
Download your new provisioning profile
Double click the provisioning profile to install it
Go to the following directory on your mac:
/Users/<your.username>/Library/MobileDevice/Provisioning Profiles
Find the old provisioning profile that you no longer want (but keeps showing up in Xcode). This may come in handy for this step: https://github.com/chockenberry/Provisioning
Delete it
Completely exit Xcode
Reopen Xcode
You should now be able to select your new provisioning profile

Most answers did not work for me as they seem to be for older versions.
For Xcode 8.3.2:
Xcode->Preferences->Accounts
Select Apple ID
Double-click your Team
Click the '+' dropdown in the bottom left to "Create a certificate"
Choose iOS Development
Click 'Done'
After doing this I was able to tell Xcode was using the latest profile by clicking the 'i' info icon next to "Xcode Managed Profile" under Targets->General->Signing and confirming that the 'Created' date reflected the new one.

In my case, with XCode 5, when my developer certificate expired, I ran into this issue. I manually downloaded the new certificate and new provisioning profile. I added the certificate to the keychain and the provisioning profile to the devices in organizer.
However, XCode kept complaining that I cannot sign the app. I figured that in XCode 5 preferences, it still displayed the old provisioning profile and it didn't refresh to the the new one despite numerous reloads that I did there.
Eventually, I used iPhone Configuration Utility to delete the old provisioning profile and add the newly downloaded provisioning profile. After code signing worked as expected.

I thought that double clicking on the downloaded provisioning profile would place it into xCode Organizer Archive, but that just wouldn't work for me. The following steps finally worked for me.
Open xCode
Go to Product -> Destination -> iOS Device
Go to Product -> Archive

Related

Linker error only while archiving

When I build my project with iOS Device, there is no error. I can even run the project on simulator wit debug mode. But when I try to create an ipa using archive, this error comes up.
I just added another device in the profile, downloaded the new profile and added it in organizer. And now it doesn't let me create an ipa. I tried downloading certificate again, restarting Xcode. But it did not work.
EDIT
When I remove the line which calls QuotedPrintable::decode() method, it works fine. How do I set path to quotedPrintable.h in the build settings?
I had given multiple paths in *Library Search Paths * that confused xcode. Removing the unwanted, and wrong ones solved the problem. :)
Seems that you have different architecture-related settings for Debug and Release configurations (by default run on simulator uses Debug and Archive uses Release). Try to make all architecture-related settings you find (ones with armv%x%) be like for Debug and check what happens.

Application Failed Codesign Warning when Archiving [duplicate]

I am very new to iOS development, I have an app all set and ready to be distributed, but I seem to get this error every single time I run the application on my DEVICE only, the iOS simulator works just fine. Heres the full error:
Application failed codesign verification. The signature was invalid, contains disallowed entitlements, or it was not signed with an iPhone Distribution Certificate. (-19011)
Here's the entire log:
Validate "/Users/masonsocha/Library/Developer/Xcode/DerivedData/Multibrowser-brgeiknbjgrywwehhohafjwxjqnk/Build/Products/App Store-iphoneos/Multibrowser.app"
cd /Users/masonsocha/Desktop/Apps/MultiBrowser
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
setenv PRODUCT_TYPE com.apple.product-type.application
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation "/Users/masonsocha/Library/Developer/Xcode/DerivedData/Multibrowser-brgeiknbjgrywwehhohafjwxjqnk/Build/Products/App Store-iphoneos/Multibrowser.app"
warning: Application failed codesign verification. The signature was invalid, contains disallowed entitlements, or it was not signed with an iPhone Distribution Certificate. (-19011)
Executable=/Users/masonsocha/Library/Developer/Xcode/DerivedData/Multibrowser-brgeiknbjgrywwehhohafjwxjqnk/Build/Products/App Store-iphoneos/Multibrowser.app/Multibrowser
codesign_wrapper-0.7.10: using Apple CA for profile evaluation
AssertMacros: trust_result == kSecTrustResultUnspecified, file: codesign_wrapper.c, line: 594
AssertMacros: profile, file: codesign_wrapper.c, line: 918
codesign_wrapper-0.7.10: Failed to load provision profile from: /Users/masonsocha/Library/Developer/Xcode/DerivedData/Multibrowser-brgeiknbjgrywwehhohafjwxjqnk/Build/Products/App Store-iphoneos/Multibrowser.app/embedded.mobileprovision
- (null)
I have already tried shortening the length of the project name, that did not help, I am currently using OSX Lion, on Xcode 4.3.2. I have spent all night pulling my hair out, please help!
May be xcode selects one of the development profile to sign the code with it.
Make sure it uses the distribution profile
press the project, in the Build Settings -> Code Signing section expand Code Signing Identity -> Release - > make sure that Any iOS SDK is referring to distribution profile.
I had the exact same issue..
Go to Keychain Access
Verify that you have your Public and Private keys set up correctly. This is a good reference https://developer.apple.com/legacy/library/technotes/tn2250/_index.html
I had previously adjusted my Keychain Certificate Preferences to make Outlook work but that pretty much screwed up XCode code signing..
After I set these to the "best attempt" setting (see screenshot) validation worked fine
You could solve it is not leaving the profile selection to xcode. Manually select the correct release profile in the project settings and it will go through.
I had same issue even after checking all signing stuff. I had the old "Can be debugged" setting in my entitlements file. Switching it to get-task-allowed fixed the problem. Apple has instructions on how to debug signing issues.
I had this problem but found that none of the above issues solved it. Eventually I found the solution by working through Apple's Technical Note (https://developer.apple.com/legacy/library/technotes/tn2250/_index.html) on the subject.
The specific problem in my case was an asset that was either missing or was hidden (I didn't find out which), but that wasn't flagged as a problem file anywhere else in the build process. I've outlined the steps I took to discover this below.
Archive the build, save for adhoc deployment.
Navigate to the ipa in finder, rename to .zip.
Double-click to unarchive, open the 'Payload' folder
Open a Terminal, and enter the following:
codesign --verify -vvvv -R='anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)' /Path/to/your/app.app
Instead of entering /Path/to/your/app.app, drag and drop the *.app file from the Payload folder into the terminal, ensure there's a space between the end of the command and the filename, and hit return.
I got an error in the output saying 'a sealed resource is missing or invalid', with the name of the file causing the problem (it began with a dot, which may have been the problem). When I searched for the filename in the XCode project browser I found the file, but when I looked in the Finder, it wasn't on disk.
The fix was simply to remove the file from the XCode project browser, and the error went away. I would definitely say to anyone getting a similar problem - work through Apple's tech notes. They're a bit badly worded but the solution is likely to be in there somewhere.
I had the same problem and solved it by:
Changing the Automatic Profile Selector value from "iPhone Developer" to "iPhone Distribution" according to section Assigning Provisioning Profiles to Build Configurations.
Download the Distribution Provisioning Profile and double-click on it in order to add it.

Error while archieving the project

Things I have done:
Changed the build configuration in archive to release
Added the developer certificates in code signing identity
Then Product--->Archive
I found the following error:
Command /usr/bin/codesign failed with exit code 1
Finally I removed all my certificates in the keychain access and I once again downloaded my certificates from the developer sites and added ,even after I'm getting the same error...
I don't know what I'm missing here???
Any suggestions plz...
Before selecting the profile, remove the old reference made in the build configurations for both Project and Target Settings.
Choose Project Settings -> Build Settings -> Code Signing Identity-> (Release/Distribution) -> Other, clear the old entry. And now select your new profile.
Do the same thing for Target Settings.
Also, when you add or replace new profile in the Provisioning Profile folder, restart your xcode to get the updated profile. Else XCode will be referring the old profile which leds to the code sign failed error.

"Attaching to <product_name>"

After create a distribution version, uploaded successfully to the AppStore through the Application Loader. And when I try to restart the development for the new version on XCode.
I edited the Scheme to the debug profile but some has been broken on the project, and after hours of reading and trying ... I'm completelly frustraded ...
I follow this instrucctions https://devforums.apple.com/message/396965#396965
And already try to edit the scheme and select manually the .app file as you can check in this explanation
XCode 4 hangs at "Attaching to (app name)"
but still doesn't works and the "Attaching to" message is still showed ...
Any suggestion?
Thank you!
Finally work it out ... removing the temporal data on organizer and removing the xuserdata on the xcodeproj element ...

How to fix "failed codesign verification" of an iPhone project?

Last night, the iPhone project was built perfectly.
This morning, I installed XCode 3.2.3 in a separate folder. When I open the same project in the old XCode 3.2.2 and re-built the project. I got this warning:
Application failed codesign
verification. The signature was
invalid, or it was not signed with an
Apple submission certificate. (-19011)
How can I fix it? Thanks!
For me the following steps resolved the issue:
Go to Product > Edit Scheme.
Open the Archive Profile.
Set Build configuration to Distribution.
I've encountered the same problem too. It showed that I had a duplicate certificate registration in my keychains. Removing one of them (I removed the one from my system keychain) fixed the problem.
Steps that helped me to resolve my problem:
Open KeyChain Access application
Select the 'login' keychain, and select in the bottom pane 'Certificates'
Switch to the 'system' keychain and see if there are certificates registered in both chains.
Remove one of them
Rebuild the application
I had the same problem, seems 3.2.3 messes with codesigning. I fixed it by re-running the 3.2.2 installer, no need to uninstall anything.
The parallel XCode problem can be addressed using the command line tool "xcode-select"
I found a similar problem caused by having XCode 4.2 beta installed. One of the embedded entitlements files was being placed in a different directory and was causing a file not found error.
The solution was to use xcode-select to verify and fix the XCode path.
Besides googling for possible solutions to this problem and trying them out (hoping that they help), here is an advice how to diagnose what causes this. The steps below apply to Xcode 4.2.
In menu, select View > Navigators > Show Log Navigator. The Log Navigator should be displayed on the left side.
In the list of builds, select the one that causes troubles. The log from the build will be shown in the main view.
Scroll to the very bottom. The last two steps should be CodeSign and Validate, where the Validate step contains the warning.
Expand CodeSign and inspect the parameters used to perform the code signing.
Expand Validate to learn more about the errors/warnings.
Also scroll up and inspect the heading for the build target:
Build Target (your build target)
Project (your project) | Configuration (selected configuration) | Destination ...
In my case, I found out that while doing the Archive build, the app was signed with the developer certificate. Inspecting the heading for the build target revealed that the Release configuration was used to build the archive. The remedy was to:
In the menu, select Product > Edit Scheme
In the Edit Scheme dialog, select the Archive build item (list on the left)
Change Build Configuration to Distribution
I had this issue after duplicating a build target. The original target was signed by the distribution certificate. However, when copying the target, Xcode decided to assign the Release configuration to the Archive build.
This happened to me today as I was moving an existing project into a new Git repository structure, while simultaneously using a development certificate obtained via being added to my client's team as a "Member". So lots of opportunity for things to screw up.
In my case, the issue turned out to be the "Build Products Path". I had it set to the relative path "../../../build" instead of an absolute path. This was causing the Validate tool to screw up since the actual path wasn't being collapsed properly. I changed it to an absolute path and the Validate tool then began to run successfully once more.
I submitted this as a bug to Radar as #8946204.
This is kind of an old post but I wanted to share what I learned (really remembered because I forgot this part.) I was trying to build my project against an ad-hock profile. I had forgotten that I needed to create a separate App Store profile (Provisioning Portal -> Provisioning -> Distribution). This was my first app I've submitted and the documentation is overwhelming so I missed/forgot about this part. Once I created the App Store profile and installed in XCode everything worked fine. Just wanted to throw this out there in case anyone else has this same issue.
Due to what hiroshi said you can change it there:
I just do is:
Open the Organizer
Go to Devices
Provisioning Profile
Click on the Profile you want to use. There you will see the profile identifier key.
Open the xcode project via textfile (the file in the xcodepj bundle)
Go to those lines and put the key in here
## -325,6 +325,7 ##
PREBINDING = NO;
+ "PROVISIONING_PROFILE[sdk=iphoneos*]" = "key goes here";
SDKROOT = iphoneos;
## -361,6 +362,7 ##
PREBINDING = NO;
+ "PROVISIONING_PROFILE[sdk=iphoneos*]" = "and also here";
SDKROOT = iphoneos;
Save changes and restart the Project
!!!That's what worked for me in XCODE 4!!!
If you go to the Organizer and select Provisioning Profiles, is the profile listed there? If so, have you checked that it's setting in the Project Settings/Build/Code Signing section?
I'm not sure, but reverting those changes in the project.pbxproj rescues me from failing to start my app in devices. The warning subject of the question remain though.
## -325,6 +325,7 ##
PREBINDING = NO;
+ "PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
## -361,6 +362,7 ##
PREBINDING = NO;
+ "PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
I fixed this simply by deleting my distribution certificate from keychain then downloading it again from the provisional profile
For the build warning or archive validation error "Application failed codesign verification", see Apple's complete list of potential causes at the following URL "How do I resolve the error: Application failed codesign verification?"
Best,
Simple Solution: Build your app using a DISTRIBUTION certificate and not a Developer cert.