Entitlements / Capabilities per Xcode scheme - ios

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 :).

Related

Multiple Apple pay merchant Ids on multiple developer accounts

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!

iOS XCode: How to create different project settings for the same application

Our iOS mobile app is used by different organisations. Some may belong to a different Development Team and therefore have their own provisioning profiles. Some organisations may wish to change the name of the app or even change the icon. So whenever I build an IPA I have to perform the following changes to the project settings:
Go to the General tab and update the Bundle Identifier and Team.
Then go to Build Settings/Code Signing and change the Code Signing Identity and Provisioning Profile names.
My question is: is it possible to create custom configurations so that I could set the project configuration settings for each organisation and then easily switch between them without having to manually update details in points 1 & 2 every time I did an archive?
Using targets might help you, go to your project settings, open up the project panel on the left. right click on your target, then click duplicate, now you can edit the necessary settings.
click the button next to start / stop to swap between your targets when running.

Instruments stopped working on iPhone apps

I had used Instruments tool (an Xcode developer tool) to analyze iOS applications before with no issues. But now when I try to run it on any iOS app (for instance CNN), it is giving me following error.
"Target failed to run: Permission to debug com.cnn.iphone was denied. The app must be signed with a development identity (e.g. iOS Developer)."
Is there any work around? Is it not supported anymore in new version of Xcode? Few months ago, I was able to use it on all applications including CNN.
Just edit a Profile section in target scheme. Switch Build Configuration to Debug.
Assuming that you are using the Release configuration to run in Instruments (as recommended), you need to review the code signing and make sure that Release is configured to use your Developer identity (instead of Distribution, for example).
First click your target
Choose Edit Scheme...
Select Profile and make sure Build Configuration is what
Here, my Build Configuration of Profile section is AdHoc. Don't change this selection to Debug, cause in Debug mode, it won't be optimized by compiler like AdHoc or Release.
Then come to Build Settings, change the Certificate and Provisioning Profile.
From this picture
To this picture
It's done!
The application (one wants to run Instruments libraries on) has to be in running state and then select from the 'Running Applications' category and not from the 'Installed Apps' category and that should work.

Run release build of iOS app on development device

When I build my iPad app for running on my development iPad, it only builds the debug version. I need to see how fast the real release version is; how do I do this? I'm used to Visual Studio's Debug/Release builds, so this Run/Test/Profile/Analyze/Archive stuff isa bit confusing. I see Schemes are related to this but isn't there a simple switch "I want to test Debug/Release version of my app on my device"?
You want to do a release build using an ad-hoc provisioning profile, which will allow you to install it on your device and any others you have specified.
Test flight app is free and can help with this process as well.
In your scheme settings, you can select to build for debug or release. Make sure you have set up code signing correctly. Xcode 5 can help with that.
You can create a new Build Configuration in the Project View under the Xcode Project. Make it a duplicate of Distribution
Then just choose Edit Schemes and choose the new scheme and run on your device. Make sure you the certificates selected in your Build Settings. However you don't get full Debugging capabilities when running a AdHoc/ Distribution build.
This took me a really long time, but I got it working. I usually use automatic signing and it works great. I switched to using FastLane in order to speed up the test flight distribution process and it required that I switch to manual signing. I had to change my release signing certificate to iOS Distribution.
I then had a bug that was only reproducible in release mode, so I needed to run the app on my device in release mode, but it was a pain to keep re-uploading to test flight.
I tried changing my build system to legacy, but that didn't work. I read up on profiles and certificates and I realized that I need to use iOS development certificates to run on device directly (which is what I was doing in debug mode). However, I needed to use iOS distribution certificates to distribute the app. Automatic signing had been taking care of this for me.
I ended up just turning on automatic signing briefly to test my app and then turned it back off and used git to revert the status of the workspace.
TLDR: turn on automatic signing and then turn it back off when done testing

How do I create a release build in Xcode?

Why is it that when I build an application, Xcode creates a debug build? I want to create a release build. How can I do this?
Product / Scheme / Edit Scheme..
And from the menu that comes up, select Release under "Build Configuration".
Xcode 11
I found this question because I had already finished debugging my app and I wanted to make a release build for the app store. I always forget which menu item to use, though. This answer is a reminder to me and others next time.
Choose the Generic iOS Device from the active scheme menu.
Then go to Product > Archive.
You may have to wait a little while for Xcode to finish archiving your project. After that you will be shown a dialog with your archived project. You can select Distribute app... and follow the prompts.
More Help
This answer is for those who are already all signed up with a developer account and just need to get the archive from Xcode to iTunes Connect. If you need more help signing up for a developer account and getting an app to the app store, read the following links.
How to Submit An App to Apple: From No Account to App Store – Part 1
How to Submit An App to Apple: From No Account to App Store – Part 2
App Distribution Guide (Apple Docs)
Submitting Your App to the Store (Apple Docs)
It is done over building an Archive version.
First connect a iOS device to your Mac. Then select that device as target in Xcode.
Now click on the tab "Product" and click on "Archive"
Leaving the original answer below, but this has not been the recommended method to create a "release" binary for distribution outside of Xcode in a long time — for that you want to Archive: see answers above.
If you are looking to debug/test a Release build in Xcode, this approach is still relevant.
To create a release build, you have to edit your current scheme (⌘<) and highlight "Run [name of application]. On the right, select "Build Configuration" and choose "Release". Build as usual.
If any one needs to go through how to make Adhoc build, here are quick steps
Product > Archive
then
Export > Save for Ad Hoc Deployment ....
See quick video https://jumpshare.com/v/rHLJII2npwyHCgGCabQA
Follow these steps:-
Go to product option
select Scheme option
Edit Scheme option
change Debug to Release
Make sure Through this you can run build in your physical device if you are disconnected to System..
but if you will run the same code o n simulator then you will face some error then that time you need to change the scheme option Release to Debug
Here is my 'more detailed' list of steps for creating a release build > (Working on a team and a project that has many schemes and environments)
checkout a new branch like releases/x.x.x that contains all changes. (x.x.x is the version) (Its more about your team conventions)
Check to make sure your app bundleIdentifier is correct (might differ for each environment)
Team/account/licence: log into correct account that has provisioning profiles. then under signing and capabilities make sure your Team is correctly selected and has all certificates needed
Upgrade the version in project settings to x.x.x
Make sure the scheme you selected is correct
Make sure the URLs of API calls are pointing to your release environment
Its better to select 'Any iOS device' instead of a simulator or actual device
Commit any changes locally if you have any (this step is very important)
Validate to make sure all is good
Create an archive
Distribute your app for AppStore Connect
I use an apple proxy named 'transporter' that is pretty easy for uploading iPA to Appstore
Happy releasing!

Resources