Search code examples
iospush-notificationprovisioning-profile

How should I ensure the correct info.plist is used when building app with multiple targets


I've got a common codebase from which I want to build multiple applications. Currently I've gotten the test app to build and I can successfully test push notifications.

Having confirmed the initial push notifications work, I've duplicated the target. In the new (duplicate) target's info tab I've modified the bundle identifier, and in the duplicate's info.plist file I've updated the bundle identifier to be the second app which I've authorized for push notifications.

Under Build Settings for the duplicate, under the Packaging section I can see the Info.plist value is set to the duplicate's filename. However when I attempt to build the second target I get the following Xcode error:

Code Sign error: Provisioning profile does not match bundle identifier: The provisioning profile specified in your build settings (“iOS Team Provisioning Profile: app.mine.PushNotificationTest”) has an AppID of “app.mine.PushNotificationTest” which does not match your bundle identifier “app.mine.PushNotificationTest2”.

Is there a method to make sure that the correct app name and info.plist file is used when the app is built?


Solution

  • The problem is not that it is not correctly pulling the Info-plist for the second target - the problem is that it IS pulling the new info.plist. In your second target info.plist, you have changed the bundle identifier. Your provisioning profile, however, is tied to a specific bundle ID, in this case "app.mine.PushNotificationTest". However, for target 2, you are trying to build using bundle ID "app.mine.PushNotificationTest2" using a provisioning profile that's only set up to build to "app.mine.PushNotificationTest". That is why you are getting the error.

    What you will need to do is go into the developer center and create a new provisioning profile for the second bundle id. Then, in your second target settings in Xcode, change target 2 to use the new provisioning profile that has been set up to build for bundle ID app.mine.PushNotificationTest2.

    Note that when you are using special entitlements, like push notifications or iCloud, you cannot use wildcards in you provisioning profiles (e.g. app.mine.*). That is why you will need a different provisioning profile for each bundle ID you plan to use with push notifications.