How can I skip code signing for development builds in Xcode? - xcode

Whenever I build my Xcode project, after compiling all my code, it takes forever to finish "signing product." (I believe it's because the project includes about 200 MB of resources that need signing.) I would like to skip the code signing during development, so the build can finish faster. How can I do this?

As of Xcode 10, here is how to turn off code signing for a macOS app:
Select your project in the project navigator.
Select your app in the list of targets.
Click “Build Settings”.
Click “All”.
Click “Levels”.
Type “identity” into the search field.
Click on the Code Signing Identity row, under the column for your app target (labeled “test” in my example). That cell of the table might appear empty.
In the pop-up menu that appears, choose “Other…”.
In the popover text box that appears, delete all text so the box is empty.
Press return to dismiss the popover.
With this setting, Xcode will not sign your app target.

To turn the code signing off, go to your project and target "Build Settings", search for "Code Signing Identity" change its value to "Don't Code Sign" in both of them.
To make this effective you need to change this value in the Project and all of the Targets separately.

If someone uses CMake (for multi-platform projects) to disable code signing for specific target I used this:
set_target_properties(MyAppTarget PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
OUTPUT_NAME "My nice application name"
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME "My nice application name"
MACOSX_BUNDLE_INFO_PLIST path/to/Info.plist
MACOSX_BUNDLE_BUNDLE_VERSION ${MY_APP_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING "My nice application name v${MY_APP_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${MY_APP_VERSION}"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.my.app"
MACOSX_BUNDLE_COPYRIGHT "(C) 2019 My Company"
MACOSX_RPATH TRUE
MACOSX_FRAMEWORK_IDENTIFIER com.myapp.bundle.id
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "#loader_path/Libraries"
RESOURCE "${RESOURCE_FILES}"
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE
XCODE_ATTRIBUTE_EXECUTABLE_NAME "exec_name"
)

You might try moving your resources to a separate bundle target, then adding the .bundle product of that target to your app’s “copy bundle resources” build phase — ideally the app build should then be able to use the bundle’s signature (which will only need to be regenerated when the bundle’s contents change) instead of having to re-sign the resources individually.

FWIW for iOS builds that you build into your simulator, you don't need code-signing. Hence no need to skip it.
You only need code-signing/Provisioning Profile on physical devices. I'm not aware of how you can skip them.
This other answer that I have not tried suggest that you can build without code-signing if you jailbreak but I'm not sure if it's answer is valid now

Related

How to make Xcode Archive use the right configuration information?

My Mac app has two Targets. When I attempt to Archive the second Target, Xcode always uses the configuration info for the first Target (Bundle ID, Version, and Build) even though I have selected the second Target.
By configuration I mean the "General" options displayed when clicking on the project name in the Project Navigator.
I was using the wrong scheme (whatever that is). To set the right scheme, use the Scheme menu (just to the right of the square Stop button on Xcode's menu bar).

How to prevent Xcode Archive from including my sub projects' Products?

I am trying to build an app with Xcode 10.2.1 and submit it to the Mac App Store.
However, when I archive it, the Organizer does not show my app's version, and the button on the right is titled "Distribute Content" and not "Distribute App" as it should. And I won't get to option to upload the to Store.
When I export to disk, I see that the archive contains a "Products" folder at the top level, and then multiple folders containing all my included sub projects, containing frameworks and helper tools.
As all these are already linked into the app, I don't need to have them also in the Archive as separate items, of course. And I suspect that's the reason why I can't submit the app from the Organizer.
If I make a regular build, the build/Release folder only contains the app, not the other products.
What could I be doing wrong, i.e. how to I prevent the products from the sub projects to be included in the main project's Archive?
I need to keep these other projects inside the main project so that I do not forget to build them when I change code in one of their source files.
Here's some information of how I set this up:
The main project shows the other projects in the left browser when I open its disclosure triangle.
The main project's target's Build Phases also lists these sub project's targets.
The Scheme, under Build, shows the main project's target, with the other targets are children. All checkboxes are ticked.
The Scheme, under Archive, selects the Release build config.
Work-around
For now, I build the app regularly, then use the cmdline tool as follows to create a pkg file that I then upload with Apple's Application Loader:
productbuild --component "MyApp.app" /Applications --sign "3rd Party Mac Developer Installer: My Name" "MyApp.pkg"
The fact that this works suggests that my app is fine. It's just the added products that are causing the trouble for the Organizer.
As suggested in this Tweet, the solution is to set "Skip Install" to YES in every sub project's Build Settings.

Xcode5 "No matching provisioning profiles found issue" (but good at xcode4)

Everything is OK on Xcode4.6. When I try to use Xcode5 dp6 to run app on devices. I got an error of "No matching provisioning profiles found issue". How can I resolve this issue?
Don't forget to change profile in Provision Profile sections:
Ideally you should see Automatic in Code Signing Identity after you choose provision profile you need. If you don't see any option that's mean you don't have private key for current provision profile.
What really confused me was that there are two different sets of build settings:
1) for the Project
2) for the Target
In the sidebar (top left) there is a blue icon that represents your project. Click that:
Then in the main panel to the right, in the top bar, just to the left of the word, "General," there is a small icon of your Project. Click that, and now select the Target in the pop-up menu that appears:
Once you've selected the Target, now the build settings for the target can be changed. They are different than the ones for the Project itself... weird! I'm not sure why there are build settings for the Project as a whole, that are different from the Target, since the Target's settings are what gets used during building. So why even have settings for the Project? Not sure.
But that's how you change them. This solved the issue for me: go into the Target (not the Project!) under Code Signing > Provisioning Profile > and change the settings to the proper profile. For a long time I was just changing them in the Project only, since I didn't know I was supposed to select the Target, and I kept having this issue. This fixes it!
Setting your provisioning profile moved. It confounded me for a while until I found it also.
Select your project file (to open target)
Click on the "Build Settings" tab
Scroll down to "Code Signing" and see the new "Provisioning Profile" section there.
OK - all answers provided above are correct to some extend, but did not resolve this issue for me. I'm using Xcode5.
There are lots of threads around this general error but from what I read this is a bug in Xcode dating back to 3.x versions that can randomly create conflicts with your Keychain.
I was able to resolve this by doing the following:
Open Xcode -> preferences -> Accounts: delete your developer account
Open Keychain: Select Keys, delete all iOS keys; Select My Certificates, delete all iPhone certificates
Navigate to '/Users//Library/MobileDevice/Provisioning Profiles', delete all files (this is where Xcode stores mobile profiles)
Open Xcode -> preferences -> Accounts: re-add your developer account
Navigate to Project properties, Target, General Tab and you should see the following
Click 'Revoke and Request' (I tried this, it may take a few min) or 'Import Developer Profile' (or download from Apple developer portal and import this way, should be faster..)
FINALLY: you can go over to Build Settings and set 'Provisioning Profile' and 'Signing Settings' as described by everyone here..
Doing this and only this resolved this error for me.
Here's a simpler solution that worked for me:
In XCode5, double-click on your app's target. This brings up the Info pane for the target. In the "Build Settings" section, check the "code signing" section for any old profiles and replace with the correct one. update the value of "code signing identity" and "provisioning profile"
Sometimes, especially after generating a new certificate or starting to use a new code signing identity, there seems to be no other way to fix this, other than doing some cleaning the .pbxproj file. This is probably a bug that will be fixed, so if you are reading this long after this post, maybe you should try some other solution.
There is an excellent post about this in the pixeldock blog:
http://www.pixeldock.com/blog/code-sign-error-provisioning-profile-cant-be-found/
In short, mostly quoting from that article, you need to:
Make sure you have fetched all your remote iTunes Connect certificates in xcode5 from Preferences, Accounts, (select your account), View Details, press refresh button. (Normally, I answer no when xcode asks if I want to create certficate signing requests, it's not necessary when you only want to download/refresh your certificates)
Close Xcode
Right click on your project’s .xcodeproj bundle to show it’s contents.
Open the .pbxproj file in a text editor of your choice (make a backup copy first if you feel paranoid)
Find all lines in that file that include the word PROVISIONING_PROFILE and delete them.
Open Xcode
Enter your target and select the provisioning profile that you want to use.
Build your project
Good luck!
In xcode5 from Preferences, Accounts, (select your account), View Details, press refresh button. then select Provision Profile in build settings.
In my case the "Fix Issue" button triggers a spinner for about 20 seconds and fixes nothing.
This works for me (iOS 7 iPhone 5, Xcode 5):
Xcode > Window > Organizer > Devices
Find the connected device(with a green dot) on the left pane.
Select "Provisioning Profiles"
On the right pane, there is a line with warning.
Delete this line.
Now go back to click the "Fix Issue" button and everything is fine - the app runs in the device as expected.
I have 2 targets in my project, Free and Paid.
My mistake was i was looking at my free target while trying to build the paid target, a stupid mistake but possible someone out there might learn from this as well.
I get the same question as you you can click here :
About the question in xcode5 "no matching provisioning profiles found"
(About xcode5 的no matching provisioning profiles found )
When I was fitting with iOS7,I get the warning like this:no matching provisioning profiles found.
the reason may be that your project is in other group.
Do like this:find the file named *.xcodeproj in your protect,show the content of it.
You will see three files:
project.pbxproj
project.xcworkspace
xcuserdata
open the first, search the uuid and delete the row.
All of drop down lists disappeared in Build Settings after running the Fix Issue in Xcode 5. Spent several days trying to figure out what was wrong with my provisioning profiles and code signing. Found a link Xcode 4 missing drop down lists in Build Settings and sure enough I needed to re-enabled "Show Values" under the Editor menu. Hopefully this helps anyone else in this predicament.
Also, I had to clear my derived data, clean the solution and quit and reopen Xcode into for the code signing identities to correctly appear. My distribution provisioning profiles where showing up as signed by my developer certificate which was incorrect.
I had the same error today, with XCode 6.1
What I found was that, no matter what I tried, I couldn't get XCode to stop complaining about this Provisioning Profile with a GUID as its name.
The solution was to search for this GUID in the .pbxproj file, which lives within the XCode .xcodeproj folder.
Just find the line containing your GUID:
PROVISIONING_PROFILE = "A9234343-.....34"
and change it to:
PROVISIONING_PROFILE = ""
One other thing to check: Your XCode PROJECT settings contain your Provisioning Profile & Code Signing settings, but, there is a second set under your project's "TARGETS" tab.
So, if XCode is complaining about a Provisioning Profile which isn't the one quoted in your project settings, then go have have a look at the settings shown under "TARGETS" in your XCode project.
(I wish someone had given me this advice, 4 painful hours ago..)

Xcode: Project and Target, add resources to target?

I'm building my first app and I'm a bit confused about all the project and target settings. So far I understand that a project can have multiple targets, for example a lite and a full version. So first I'm building my full version and later on adjusting it for the lite one.
My question is now about the resources you add to the targets. So far I've never checked the checkbox "Add to target …" while adding images, fonts etc. Still it works fine. So why or why shouldn't I check this box? And if I need to check it, how can I do this for all the images etc. I've added to the project?
And I think in my resource folder are still some resources I don't need anymore and actually deleted in Xcode (correctly, not just deleting the link basically)..how can I get rid of them?
When you add a file/resource in Xcode (either using "New File" or "Add File to "), you will see a checkbox for all the targets in your project. You can check the ones that you want to include the new file/resource. For the existing file/resources in xcode, you have following two options:
For your target->Build Phases->Copy Bundle Resources, you can add resources to the target.
Click on the file/resource in project navigator, under "Utility View"->Target Membership, you can select/deselect the targets that need to include/remove this file/resource.
Regarding deleting resources, when you delete a resource or any file in XCode, it will give you options: "Remove Reference" or "Move to Trash". For both of these options, resource will be removed from all the targets and XCode project file. However, if you choose "Move to Trash" it will also be removed from the folder in your hard disk.

Entitlements are not valid

Recently, I have upgraded my iPhone SDK OS from version 2.2.1 to 3.0 version. After that, while building my application, I get an error that the provisioning profile has expired. So I created a new provisioning profile.
Then I made the distribution of my application with the provisioning profile. But I get an error in iTunes while synchronising my application into an iPhone device. The error message is "The application 'iGVA' was not installed on the iPhone because the entitlements are not valid."
I checked the code signing Entitlements contains the correct entitlement plist file.
How can this be solved?
Michael's answer above is spot on (or the link he points to is). Here are the steps I had to take to get it to work:
Have an ad-hoc certificate for which the device UDID is checked. Install that cert by dragging it onto the XCode icon.
On the project, create a distribution configuration and set your build params to the appropriate device | distribution. Right now, we build for Device 3.0 | Distribution.
My project did not include an Entitlements.plist file - I had to add it by selecting from the menu File | Add File | IPhone OS | Entitlements, and call the new file Entitlements.plist
The new plist file has only one row - set the value of that row to unchecked.
In the project build configuration, in the line for Code Signing Entitlements, enter the Entitlements.plist filename as the value.
In the Code Signing Identity, select the ad-hoc certificate identity (though I have found that you can also use your distribution certificate identity)
NOW BUILD :)
Deliver the resulting app file plus the ad-hoc cert to the person who gave you their UDID. Should work :).
An Entitlements.plist file is required for testers to install ad-hoc builds. The default iOS templates don't include one. In XCode 3.2.4 you create one like this:
From the menu, choose "File > New File…"
Under iOS Templates, there's a Code Signing section. Choose the certificate icon named Entitlements. Name the file "Entitlements.plist"
Select Entitlements.plist in your source tree.
Choose "View > Property List Type > iPhone Entitlements Plist"
Add a new key to the property list (select the top line, press return)
The item will probably be named "Can be debugged". If not, choose that from the available options. This is equivalent to "get-task-allow".
If you don't yet have one, create an 'ad-hoc' build profile:
Select your target in the source tree.
From the menu, choose "File > Get Info"
In the inspector. select the "Build" tab.
Under 'Configuration', choose "Edit Configurations…'
Select your 'Release' configuration, click 'Duplicate' at the bottom of the screen.
Rename the new configuration "Ad-Hoc Distribution"
Now you've created an Entitlements.plist, you need to add it to your build settings.
Select your target in the source tree.
From the menu, choose "File > Get Info"
In the inspector. select the "Build" tab.
Make sure the configuration selector is set to "Ad-Hoc Distribution"
In the "Code Signing" group, change the value of "Code Signing Entitlements" to "Entitlements.plist" - XCode may have put in a relative path for you. If so, change it.
Note - you'll have errors installing the app on your own device if you build & run with "Code Signing Entitlements" set for other build configurations.
Finally, check that the Entitlements.plist has been added to your target.
Select Entitlements.plist in the source tree.
From the menu, choose "File > Get Info".
Select the "Targets" tab.
Make sure the checkbox next to your target is checked.
You should now be able to distribute your ad-hoc builds without this error.
Most of this was gleaned from Apple's Managing Application Entitlements Guide, the rest by trial & error.
I got bit by this as well and found the answer in Ad-Hoc Apps and Entitlements.
You may need to make sure the path to your Entitlements.plist file is entered in your project settings under "Code Signing Entitlements".
I was getting crazy over this. Finally, I guess I got it. In project settings, I was setting entitlements and code signing stuff properly in the correct Adhoc configuration. However, although all seemed OK there, when I checked "Project -> Edit Active Target" my code signing entity was still stuck at "iPhone Developer".
After switching that to the correct "iPhone Distribution" and recompiled, Xcode asked me to allow code signing for the first time. And it all compiled and is transferred to my phone now!
I hope that helps. I seriously believe this problem is a bug or defect on Apple's side. I lost several hours for a simple thing, thanks to their undocumented IDE...
For record's sake, as all these wonderful answers didn't help me, I thought I'd share my Entitlements glitch.
So yes, I added UDIDs, got the provisioning, verified on the phone, in build settings, etc.
My glitch (thanks http://www.musicalgeometry.com/?p=1237) was that the Ad Hoc scheme was set as Ad Hoc configuration only for the Run settings.
For archive settings it was still pointing to the old Release configuration.
(These settings are the left side tabs in the edit scheme window.)
If I save someone my frustration - I've done my bit.
Code signing entitlements are no longer necessary for Ad Hoc builds in Xcode 4 - see details notes in Apple Technical Note TN2250
You also need to make sure that you have an unexpired provisioning profile, which foiled me on this one for a while (Ad Hoc provisioning profiles seem to expire after a year). Error message is the same, but it has nothing to do with not having a valid Entitlements.plist file.
Be sure that when you 'Build and Archive' that you are building for 'Device' and your configuration is not 'Debug'. It will seem to create the archive correctly, but will fail upon installing the .ipa the device if you are set to a Debug profile when you do the 'Build and Archive'.
This problem might not have anything to do with the Entitlements plist per se. I have two iPod Touches I use to test with. When I went to sync the apps with them, one worked perfectly, but for the other I got the 'entitlements are not valid' error. As it turns out, one device (the one that worked) had the mobile provision file on it, while the other one did not. This was an obvious oversight on my part. However, what threw me was I never explicitly added the provision file to the first device either. Not sure how it got onto that device (I'm still new at this - lol) - in the past I always just dragged it into the Organizer with the device attached, but I didn't do that this time.
So the provisioning profile and xcode were all set up perfectly with the correct IDs, etc. but the app still failed to sync. Obviously if the device isn't properly provisioned, you will get the error. Would be nice if the error was more helpful in this case.
I had this in XCode 4. I tried cleaning, deleting and recreating the entitlements file but still no joy. Then I changed the Value for "Can be debugged" from YES to NO .. and it worked. Anyway it seems to work fine now, I hope this helps!
This happened to me as well, and the other answers did not solve it for me.
After spending half a day building, installing, cleaning, clicking to no avail - I finally erased Entitlements.plist from the box under Code Signing Entitlements, saved, and typed it in again - voila! It worked again! I never touched the actual Entitlements file, just the setting.
I had this same problem, using Xcode 4. It turned out to be caused by a wrong selection for Identity in the "Share..." dialog in the (Archives section of the) Organizer.
The correct selection (for me) is: "Don't Re-sign".
I had this issue as well. As it turned out, sure I had edited a configuration to support ad hoc, and sure I was building using the distribution configuration. BUT. I hadn't edited the distribution configuration's properties, but the release's instead (I thought I was editing the distribution).
This might not be it. But even though you're certain, double check you're using the correct configuration, and that this configuration is adjusted properly.
From the docs:
Building an app for Ad Hoc
distribution is similar to building an
app for App Store distribution, with
an exception of two additional steps.
First, you need to create an Ad Hoc
Distribution Provisioning profile and
add the UDIDs of the iOS devices that
you want to distribute to using the
iPhone Developer Program Provisioning
Portal. Second, you need to create a
code-signing Entitlements file. For
information about how to create an
Entitlements file read the Managing
Application Entitlements section of
the iOS Development Guide.
Managing Application Entitlements
iOS provides access to special
resources and capabilities—such as
whether your application can be
debugged—through properties called
entitlements. To specify entitlement
information in your application, you
add an entitlement property-list file
containing entitlement definitions
(key/value pairs) to your project.
When you build your application, Xcode
copies the file to the generated
application bundle.
To add an entitlements property-list
file to your project:
In the Groups & Files list, select the
Resources group. Choose File > New
File. Choose the iOS > Code Signing >
Entitlements template. Name the file
Entitlements.plist. (You can use any
name; just ensure it matches the value
of the Code Signing Entitlements build
setting, as explained later in this
section.) Set the type of the
property-list file to iPhone
Entitlements. With the file selected
in the text editor, choose View >
Property List Type > iPhone
Entitlements plist.
Add your entitlement entries to the
file. For each entitlement property
you need to define:
Click the Add Child or Add Sibling
buttons to the right of the selected
row. The Add Child button has three
lines depicting a hierarchy, the Add
Sibling button has a plus (+) sign on
it. Choose the entitlement property
from the pop-up menu that appears. If
the entitlement you need to add
doesn’t appear in the menu, choose
View > Property List Type > Default
for File Type. Then enter the
entitlement-key name and type.
Enter the value for the property. Set
the Code Signing Entitlements build
setting for the target to the name of
the newly added entitlements
property-list file.
Once you
have created your Entitlements file
and added it to your Code Signing
Entitlements build setting, open the
Entitlements file and add or edit the
get-task-allow key and set it to
false.
In addition to compressing your .app
bundle to distribute your Ad Hoc build
to testers, etc. it is recommended
that you also compress the
provisioning profile before
distributing because certain email
clients and servers may corrupt the
provisioning profile.
For information about Ad Hoc
distribution please read the
Publishing Applications for Testing
section in the iOS Development Guide.
I just found another circumstance that causes this problem. You have to make sure you include the correct provisioning profile. I have an application that has both an iPhone and an iPod version, and an iPad version built from the same project. I apparently sent out the iPad ad hoc profile with the iPad version of the application, and it doesn't work. Worse, I installed the correct profile locally with Xcode, so everything works correctly on my machine.
I experienced a problem whenever I added a new device in the device list, and then made the new profiles by selecting the new devices and drag them to Xcode and prepare the build.
The moment I use that build for device installation I get the error
ENTITLEMENTS ARE NOT VALID
I tried to resolve it by all the ways I could think of but nothing positive came out. Anyhow, I have to make the new App-ID or have to repeat the whole process of creating profiles. Then I can install the build on the device.
make shure to select the Signing Identity in the TARGETS ;)

Resources