I found an issue with Xcode 8 where .entitlements files are not being referenced properly for each scheme. Basically, my Debug .entitlements file is being referenced for my Release scheme. This is causing an issue because we implemented the new Rich push notification logic and that requires the use of App groups.
I am using two different teams (Development and Production), so there will be two specific App Groups.
The configurations that we just created now need to be associated with an XCode scheme. For more information on what a scheme is, check out the apple documentation reference here. To do so, we need to manage the schemes of the project. Open the scheme manager. Select Product -> Scheme -> Manage Schemes … from the toolbar. 2.
If you run your app and you get some build errors, that means Xcode has detected that the syntax of your code is wrong. If Xcode is complaining that a specific identifier doesn’t exist, then check that all of your opening curly braces have corresponding closing curly braces.
After the crash, go to Xcode in the lower right hand pane, scroll all the way to the top. So now that you know how to find the actual error message when your app crashes, the next step is to learn to recognize some of the more common types of messages because they will hint at what’s wrong.
My Xcode Interface Is Different 1. Xcode Simulator Errors My iPhone simulator looks different? If your iPhone simulator doesn’t look like the one you see me using in my videos, it’s because your iOS simulator is at a different zoom level.
I found a solution. Make one .entitlements file add this:
<key>aps-environment</key>
<string>$(APS_ENVIRONMENT)</string>
<key>com.apple.security.application-groups</key>
<array>
<string>$(APP_GROUP)</string>
</array>
Then in Target > Build settings Set the same .entitlements file in Signing > Code Signing Entitlements Add User-Defined Setting for APS_ENVIRONMENT and APP_GROUP setting the correct group for each target.
So, based on the target Xcode will use what you set for APS_ENVIRONMENT and APP_GROUP.
You can do this in plist too...did some amazing clean up today.
Though Tim's solution mostly worked for me, Xcode got all upset and said automatic provisioning couldn't resolve issues with the entitlements file. I don't think it liked the variable.
Our solution was to:
PROJECT_APP_GROUP
for the app group name by going to Project -> Build Settings, clicking the "+" button, and selecting "Add User-Defined Setting."info.plist
file for each target that needs access to your app group. Then access the correct app group at runtime by getting the APP_GROUP
variable from your target's info.plist
file.
+ (NSString *)appGroupIdentifier
{
// this method returns the app group identifier by fetching it from the info.plist file.
// this string is dynamic based on build scheme. for instance group.ourApp vs. group.ourApp-dev
return [[[NSBundle mainBundle] infoDictionary] valueForKey:@"APP_GROUP"];
}
Now that I think of it, if you have preprocessor macros set up for each build, it might be easier to do something like:
+ (NSString *)appGroupIdentifier
{
#ifdef BUILD_DEV
return @"group.myApp-dev";
#elif BUILD_STAGING
return @"group.myApp-staging";
#else
return @"group.myApp";
#endif
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With