A valid provisioning profile matching the application's identifier could not be found

chris P picture chris P · Apr 22, 2013 · Viewed 40.1k times · Source

This has been asked before, but the answers to previous questions are not solving my issue.

I'm trying to build a simple Hello World app called (CalculatorBrain) from Stanford iTunes U courses. I can run it in the Simulator fine, but I'd like to get it on my iPhone 4S.

I sync my iPhone 4S through iTunes on my Windows machine. Always have. Figured I should list this detail.

Anyway, back to my Macbook (Mountain Lion). I'm running the most recent XCode 4.6.2 (4H1003) and my iPhone is also the most recent at 6.1.3 I believe.

I went to the Provisioning Portal at the Apple developer page. I added my 4S. I called it JohnSmith, and gave it the phones UDID.

In XCode, I opened the Organizer, Devices is highlighted by default. I put the passcode in my iPhone, and plugged it into my Macbook. Devices finds my iPhone. If I click on Provisioning Profiles and try 'Add Device to Provisioning Portal', I get a "A device with number already exists on this team." Great. I know it's added for sure then. All good news so far.

In my Hello World app, CalculatorBrain-Info.plist my Bundle Identifier is "com.JohnSmith.CalculatorBrain". Bundle display name is "${PRODUCT_NAME}" and executable file is "${EXECUTABLE_NAME}" if that matters.

In the Navigator, if I highlight my project, and bring up the Build Settings, under Code Signing Identity I get the options...

Don't Sign Code

Automatic Profile Selector - iPhone Developer - iPhone Distribution

Identities without Provisioning Profiles - iPhone Developer: John Smith (R............K) - iPhone Distribution: John Smith (Y.............5)

Other...

I've tried all of these. I'm assuming I'm supposed to use the iPhone Developer: John Smith one... but it's saying it's an identity without Provisioning Profiles.

What's going on here? What do I need to do to get this to work?

Answer

Bryan Musial picture Bryan Musial · Apr 23, 2013

Based on your description, it sounds like the missing element is that you need to go back to the 'Certificates, Identifiers, and Profiles' tool, generate a Development Provisioning Profile for the AppID of your HelloWorld app, then install that profile on your development machine. At a high level, this is composed of the following steps:

  1. Locate the AppID for your project in Xcode.
  2. Verify that you've setup that AppID in 'Certificates, Identifiers, and Profiles'.
  3. Create a Development Provisioning Profile for that AppId, your development certificate, and one or more registered test devices.
  4. Download and Install the Provisioning Profile in Xcode.
  5. Configure your project to Code Sign using this Profile and Linked Code Signing Identity.
  6. Build to device!

The 'Code Signing Identity' build configuration item you have mentioned is very much dependent on both your project's settings as well as the Provisioning Profiles available on your development machine. I recently answered a tangentially related question 'What are code signing identities?' that may be helpful in seeing what information Code Signing is using and how you can check that you've got your development machine setup to be able to Code Sign your project.

...and now, on to more specific HOWTOs to help work through your Code Signing question:

Locating Project's AppID

The AppID uniquely defines an application in the iOS ecosystem and is one of the things you first create when starting a new Xcode project. This AppID is what you need to register in the 'Certificates, Identifiers, and Profiles' tool to get started with Provisioning.

Xcode AppId Setting

  1. In the Project Navigator (CMD+1), click on your project name (likely 'CalculatorBrain'). This will present the project's settings.
  2. Select [Your Project Name] > Summary Tab as shown in the screen clipping from above (MyiOSApplication).
  3. Your iOS AppID is presented in the 'Bundle Identifier' field. Snag a copy of this string, you'll need it next.

Verify (or Setup) the AppID

  1. Navigate to http://developer.apple.com/ios and access the 'Certificates, Identifiers, and Profiles' tool.
  2. After logging in, select 'Identifiers'.
  3. Check that the AppID you found in the previous section is present in the list of App Identifiers. If so, take note of the App ID Name and skip to the next section, otherwise...
  4. Click the 'Add' (Plus) button in the upper right corner, provide a name for this App ID (can be whatever you want, just so long as it doesn't have special characters.)
  5. Scroll to the bottom of the page, and paste a copy of your App ID from the previous section in the 'Bundle ID' field. under 'Explicit App ID'.
  6. Click 'Continue'.

Do note that the AppID must be unique across the iOS Ecosystem -- you may get an error if the AppID you've selected is already in use. If so, change your 'Bundle ID' to something unique -- just be sure to update the 'Bundle ID' setting in your Xcode project to match whatever you settle on.

Creating a Development Provisioning Profile

Now that the App ID is registered, you are now ready to create a Development Provisioning Profile linking your App ID, Development Certificate, and Test Device ID(s) together.

  1. Within the 'Certificates, Identities, Profiles' tool, navigate to 'Provisioning Profiles'.
  2. Click on the 'Add' (Plus) button in the upper right corner.
  3. Select 'iOS App Development' in the 'Select Type' step and then click 'Continue'.
  4. Select your App ID from the drop down list of App IDs and then click 'Continue'.
  5. Check the box next to your Development Certificate and then click 'Continue'.
  6. Check the box next to the test device(s) you want to authorize to install this app and then click 'Continue'.
  7. Key in a Profile Name (again omitting special characters) then click 'Generate'.

Download and Install Provisioning Profile

Once the Provisioning Profile is generated, the tool will provide you with a link to be able to download

  1. Download the Provisioning Profile by clicking on the 'Download' link.
  2. Drag Provisioning Profile from your Download location and drop it on the Xcode Dock Icon or double-click to open it.

Configure Code Signing Identity

Sounds like you already know where this is located, but just in case:

  1. In the Project Navigator (CMD+1), click on your project name (likely 'CalculatorBrain'). This will present the project's settings.
  2. Select [Your Project Name] > Build Settings Tab.
  3. Scroll to the 'Code Signing Identity' item.

In theory you would like to use the 'Automatic Profile Selector' option which will attempt to match your AppID to an installed Provisioning Profile, but you can also scroll through the list and pick a specific mapping of Bundle ID/AppId to iOS Certificate.

Also, my own Xcode doesn't always seem to catch on to changes to freshly-installed provisioning profiles -- It is unclear if this is just a quirk of my own Xcode install or if there is a bug in Xcode. Either way, quitting and relaunching Xcode seems to trigger a reindex/refresh of profiles.

Anyway, select the option that matches your AppId/BundleId and your Developer Certificate.

Assuming the problem was a missing/incomplete/expired Provisioning Profile, then this should help get you up and running. If not, we'll have to dig into other potential settings or certificates issues that could be tripping up your Code Signature operation.