How to test capabilities entitlements file?

Since i am managing multiple applications, i always forget to verify capabilities?

like is in-app-purchase turned ON, proper values are set in Associated Domains etc.

Is there any way we can test this file <appName>.entitlements and values in it?

Accepted Reply

You certainly don’t want to look at the

.entitlements
file. That’s one input to the code signing process, but you really want to test the output. That output is baked into the code signature, and you can dump it like so:
$ codesign -d --entitlements :- /path/to/your.app

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

What sort of test are you trying to do? A functionality test (that is, do the entitlements actually work)? Or just a static test of the entitlements? If it’s the latter, you can dump the entitlements with the following command:

$ codesign -d --entitlements :- /path/to/your.app

after which you can verify them however you like.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I want to do a static test, like

1. If Entitlements file is present or not. Most of the time i forget to generate it and ship the product.

2. In Entitlement file if Associated Domine is present or not and what is the value in it.


Here is what i came up with

NSString *contents = [NSString stringWithContentsOfFile:entitlementFilePath encoding:NSUTF8StringEncoding error:nil];

NSLog(@"Path:: %@",entitlementFilePath);

NSLog(@"contents::\n %@",contents);

if(contents==nil){

XCTFail("entitlementFile missing......at location: %@",entitlementFilePath);

}

if(![contents containsString:@"applinks:abc.mywebsite.com"]){

XCTFail("Associated domain not enabled ......>>>>>> abc.mywebsite.com entry missing in the file...");

}

You certainly don’t want to look at the

.entitlements
file. That’s one input to the code signing process, but you really want to test the output. That output is baked into the code signature, and you can dump it like so:
$ codesign -d --entitlements :- /path/to/your.app

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"