Search code examples
iosobjective-cshare-extension

Is there a way to get the app group identifier from host app and share extension on iOS?


I have set up App Groups for both my host app and the share extension. The identifier looks like "group.com.abc.xyzApp". Is there a way to get this string out programmatically? Also, how do I detect if app groups are set programmatically? Is trying to initialize a file container or user defaults with the app group identifier enough to know? Eg:

[[NSUserDefaults alloc] initWithSuiteName:@"group.com.abc.xyzApp"].


Solution

  • You cannot detect if you get something programatically, but I think this is not very usefull.

    Why you need to change this? by environment maybe? If so, you can do it by project variables and then add this to your info.plist

    enter image description here

    enter image description here

    Later you can get it with:

    main.object(forInfoDictionaryKey: "AppGroupId") as? String
    

    Hope this helps