iOS在App和WatchKit Extension中以编程方式从Entitlements中读取AppGroup

时间:2017-01-29 08:37:38

标签: ios objective-c xcode continuous-integration watchkit

有没有办法以编程方式从权利中读取AppGroup。

我已经实现了以编程方式读取AppGroup但无法以编程方式获取Entitlements文件名。您能否建议如何以编程方式从构建设置中读取CODE_SIGN_ENTITLEMENTS的值。

NSString *path = [[NSBundle mainBundle] pathForResource:@"MY_APP_TARGET_NAME"
                                                 ofType:@"entitlements"];
NSDictionary *dict = [[NSDictionary alloc]initWithContentsOfFile:path];
NSArray *appGroups = [dict objectForKey:@"com.apple.security.application-groups"];

for(NSString *appGroupValue in appGroups) {

    if([appGroupValue hasPrefix:@"group.com.xyz.myAppName"]) {
        appGroup = appGroupValue;
    }
}

0 个答案:

没有答案