Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get App Groups name programmatically?

I am using extensions in my application. For sharing data between app and extension using app Groups. How Can I read App Group name programmatically so no need create extra configuration file for storing App Group name.

like image 256
Sadasiba Sahoo Avatar asked Mar 17 '17 08:03

Sadasiba Sahoo


1 Answers

You'll only be able to use this in development (Debug mode), the entitlements are written into the embedded.mobileprovision file in the app bundle.

The embedded.mobileprovision will not be included when you archive an .ipa file or deliver your app to the AppStore.

When in Debug you can try this:

/* Swift 3 */

if let path = Bundle.main.path(forResource: "YourProjectName", ofType: "entitlements") {
    let dict = NSDictionary(contentsOfFile: path)
    let appGroups: NSArray = dict?.object(forKey: "com.apple.security.application-groups") as! NSArray
}
like image 198
Oleh Zayats Avatar answered Oct 11 '22 02:10

Oleh Zayats