Multiple Apple pay merchant Ids on multiple developer accounts - ios

I have a project with a number of different build configurations, 4 for one developer account and 3 for another, each having production, alpha and beta build configurations and the first having a debug configuration. all 7 have different bundle ids
each developer account has apply pay setup with it’s own set of apple pay merchant ids.
Im getting the error that one build configuration’s provisioning profile is missing support for the other developer account’s merchant id and vice versa, they work fine if i delete the build configurations from the other developer account but when they are both in the project the error comes up.
Is there a workaround for this? am i missing something to tell the build configuration to only use it’s own merchant id?

Since the targets use the same entitlements to modify the capabilities such as Apple Pay, Associated Domain and Push Notifications etc.
My solutions:
Create the .entitlements files individually.
Targets → Build Phases → Copy Bundle Resources and link the correct .entitlements file.
Targets → Build Settings → Signing → Code Signing Entitlements and link the correct .entitlements file.
Back to Signing & Capabilities, now you could set it successfully :)
Hope it works for you!

Related

iOS add targets to existing application with fastlane

I would like to extend an existing application with a production and a test target with more of prod / test target combinations.
The applications are based on the same source code and are configured with different .plist files and config files, so its really just a new target which is needed (along with all the profiles and stuff...)
There is an existing fastlane setup (with environment files .env.App1), but I don't know to which extend this was used to create the app and the portal stuff.
I extended this setup with a new .env.App2 file and added the desired bundle id and started the app creation with
fastlane create_app --env App1
where lane create_app simply calls
create_app_online
This worked fine and the application id was created on the apple side.
Now I have a problem with the signing part.
In the project "automatically manage signing" is active.
When calling sync_code_signing for the same environment everything goes fine, but the signing stuff is not solved in xcode for this target unter signing & capabilities.
I have the certificates in the according git repo (this problem was solved in another question, if somebody struggles with that)
How do I solve these 3 errors?
Failed to register bundle identifier
The app identifier "com.BUNDLE_ID" cannot be registered to your development team because it is not available. Change your bundle identifier to a unique string to try again.
Provisioning profile "iOS Team Provisioning Profile: *" doesn't support the Associated Domains and Push Notifications capability.
Provisioning profile "iOS Team Provisioning Profile: *" doesn't include the aps-environment and com.apple.developer.associated-domains entitlements.
What all these different apps need are
Associated domains
Background modes
Push notifications
So i have a .entitlements file, a .plist file and a target for each app.
How can I find out what the problem is and fix the signing part for all my apps / targets?
thank you

Wrong iOS provisioning profile being chosen

I have followed a tutorial to enable Push Notifications on the App. It's still in development phase and internal testing only.
Using that, I have correctly enable development push notifications on the App ID, and the development provisioning profile accordingly. So much that the first three or so bundles that I have uploaded worked correctly and the Push Notifications went just fine.
Now, with the last update I've done, I've received an Email with an issue and the Push Notifications stopped working:
"Missing Push Notification Entitlement - Your app appears to include API used to register with the Apple Push Notification service, but the app signature's entitlements do not include the "aps-environment" entitlement... etc."
What I realized since then is that when I run "archive" to build the app, after I choose the team (the only one I have and always have used), when I come to chose the Binary and Entitlements, the Provisioning Profile is a DISTRIBUTION one and not the development one I have created.
I've tried countless things from my search on the internet. Including forcing in Code Signing on my target Build Settings the iPhone Developer:MyName and the development profile I've created in the Provisioning Profile row (wich is available to select here).
Still, no-go. I have no idea what changed in the process since I didn't mess with certificates or changed anything in that field, just plain app code.
Thanks for the input.
EDIT: I'll add some screenshots that maybe can shine some light.
The XC:profile is the default distribution provisioning profile that XCode is creating.
Note : without knowing the root cause i can only help you confirm whether you have all the certificates on proper place and using correct one.
Please go this way..
Just check in your Keychain and developer.apple account, if developer certificate is valid, if yes then
Check Provisioning profiles for Development and Distribution with Notification service enable in Provisioning section on developer.apple account.
So far everything is proper then.
Go to Xcode -> Preferences -> account -> refresh all certificate for the same apple account. and hit download.
Now go to Project settings -> general -> confirm you should have selected appropriate team.
finally to to project settings -> build settings -> search "code signing"
now select correct Provisioning profile and developer here.
please let me know if you find any trouble in this.
In my case, I had changed the bundle identifier for the app, but the App ID listed on the provisioning profile was still wrong. Turns out that in the "Packaging" section under build settings, there's another place where the bundle id needs to be changed ("Product Bundle Identifier"), and that's what the code sign-y thing was looking at.
Using Local Signing assets while exporting solved the issue for me

Entitlements / Capabilities per Xcode scheme

The Apple Pay entitlement / capability is only valid in the App Store. I am releasing this app in both the App Store and Enterprise.
If the App Store Release scheme is selected I'd like Xcode to enable the Apple Pay entitlement.
If the Enterprise Release scheme selected I'd like Xcode to disable the Apple Pay entitlement.
You can achieve the desired behaviour by using a different build configuration.
Copy the entitlements file and adjust it to your needs, e.g, remove the Apple Pay entitlement for enterprise distribution
Select the project on the project settings view
Add a new build configuration, e.g., AppStore
Switch to your app target and adjust the value for the new build configuration.
Create a new scheme, e.g., AppStore and select the new build configuration in the "Archive" Section of the scheme settings
In general, it is a good idea to have separate schemes and build configurations. That way you can support several different build configurations depending on your needs, e.g., Enterprise distribution, Hockey Testing, App Store etc. .
If you want to make your project setup more maintainable consider using xcconfig files to organize your build settings.
A possible approach:
Put your different schemes' entitlements files in a folder
Have your project or target's Build Settings > Code Signing Entitlements point to a location such as $(PROJECT_DIR)/AppName/AppName.entitlements
In Edit Scheme > Build > Pre-actions, add a "Run Script" action to copy the entitlements file for that scheme, to the location you specified in step 2. e.g. cp ${PROJECT_DIR}/entitlements/DevScheme.entitlements ${PROJECT_DIR}/AppName/AppName.entitlements
I had done this for some time. My solution was based on git branches. I had four branches: master, app-store, enterprise and feature.
Among these, app-store and enterprise were derived from master with their own variations, and feature was for new features in development.
Every time I finished building a feature and QA people finished verifying it, I would merge it to master , then merge master to app-store and enterprise.
I'm not that proficient with git, but I managed to work smoothly.
I've checked other answers, and realize my solution is a little silly :).

How to become familiar with code signing issues?

Every time when i deal with code signing and provisioning profiles strange things happens. Most times i get the error "no code signing identity found" and if not then something like "no matching provisioning profiles found" and "no provisioning profiles with a valid signing identity".
Although i am quiet familiar with the theory and the things behind code signing and provisioning, there are still lots of pitfalls I everytime ran into and i don't know how to deal with. Sometimes it fails when setting up a new App, sometimes not.
There are 5*2 different ways to select code signing identity. What is the difference between them? And if i select one for debug and one for release, what is the reason for the "Any iOS SDK"?
Also, there are two places giving this dialog: Project-Settings -> Buildsettings is the first place, and also for the Target under Build Settings. Both are not in sync, so if i change the code signing at the first place, i have to change it twice in the second place. Is there a way to keep them in sync?
Which code signing identity would fit best into the various lines (debug, debug -> any ios sdk, release, release -> any ios sdk), since i can choose between developer identities and distribution identities (i could imagine, that the distribution one is for release and the developer one is for debug, but because of everything fails, i don't know.
What I did:
There a valid certificates in the Member Center deposited for each developer of our team and one for ad hoc distribution for the Team.
We also created AppIDs which reflects exactly the same setting in the Project Settings. In between we avoid using Variables and use the exactly appid also in project-settings to reduce risks on this side and to simplify things.
When switching the provisioning profile from "Automatic" to a specific Profile for this App, the code signing identities change to different values, which are also not in sync between the project settings and target build settings:
On the Target->Build Settings we get this result:
On the Project -> Build Settings we get a different result:
Which one would be more accurate?
After "Product" -> "Archive" -> "Validate" we get the following error:
It doesnt matter here if we select different Code signing identities or not. Actually, just for playing 'trail-and-error', we tried out nearly every multiple combinations of code signing identities to learn what XCode would do then.
After this error message from Archive->Validate the previous selected provisioning profile is replaced with another one named by a randomly generated string:
Who can tell me what happens here and how to solve these issues?
I've read a lot of documents regarding this topic. But most tutorials around this topic are outdated since several changes happened between XCode 4 and XCode 6. Even the apple documents offer mostly screenshots based on outdated XCode versions and also outdated versions of Member Developer Center.
Update
As Ian McDonald pointed out correctly, the last question (covered by the last 2 screenshots) is answered. After recreating the Provisioning Profile it won't be replaced by randomly generated strings, but the IPA-creation is still not working with "no code signing identities found".
What it looks like now:
you have a long question , but If you face problem with archive or publish your app there are some steps you should follow
First code signing
If you build your app with Debug , then debug must sign with iPhone developer --> general if you use many or specific one "depend of certificate you have in your key-chain "
but If you build your app with release then you should you certification iPhone distribution ---> general or specific one
Second Provisioning Profile
If you build with Debug then the provision profile Debug should match match your bundle detail and be development
release be distribution one that you create on developer apple site
I hope this help you have a look at this also please
From what I'm reading you have changed your provisioning profile in your target from "xxx.xxx" to "xxx.xxxTests" which is in fact a different bundle identifier making the error valid. You really have two courses of action:
Change your bundle identifier back to just "xxx.xxx". This is the appropriate path of least resistance.
Create a new bundle identifier in the portal as "xxx.xxxTests" as well as a new provisioning profile for "xxx.xxxTests" tied to the same certificate. With XCode closed drag the new provisioning profile onto your XCode app icon then open your project.
You shouldn't have to change your bundle identifier to conduct testing. When you go to deploy you will only have to change which provisioning profile your target is compiling with (development vs distribution).
EDIT:
I have some more tips on provisioning profiles here: How to become familiar with code signing issues?
The quick and dirty side of provisioning works like this:
When you are added to the Apple Provisioning Portal your cert is the keys to the castle. Any code you compile has to be associated with your cert or you won't be able to properly compile/export your code.
Your bundle identifier is essentially the way iOS identifies your application. Conceptually speaking if you want to install your app multiple times on the same device create multiple bundle identifiers.
Your provisioning profile ties all of the pieces together. The prov profile tells XCode that you plan on using your cert to compile your app identified by your bundle identifier. If it's a development build it will only the devices specifically assigned to the prov profile in the portal will be able to install your app.
Within XCode you need to make sure your target bundle identifier matches what bundle identifier is in the provisioning profile. Likewise make sure your code signing identity matches the cert you setup in the portal and tied to the provisioning profile. Lastly select the appropriate provisioning profile from the drop down list below the code signing identity.

Code Signing for AdHoc Beta Testing

I have been working this for past two days, and haven't come up with a solution. I have Created Provision for Distribution in Apple perfectly. I don't know How to Set up Built setting and Code signing process in Xcode 5. Any one who could explain briefly will be appreciated.
Assuming you have created certificate and a distribution profile.
First, download both the profile and certificate from your developer account. Just double click on them and it will get copied to respective locations automatically.
Now open your project settings and under build settings tab look for Code signing section.
Set the certificate and profile which you have just installed.
Do the same under Target-> build settings.
Next, you need to set the bundle identifier with which you have created the app id in developer portal. Note down the Bundle ID, version info and set it in Target -> General
If everything went well archive your code and distribute the ipa file which is now code signed.
Refer here for more details.

Resources