David
David

Reputation: 339

Return nil when finding path for App Group

I have enabled App Group and created a group called "group.com.classData" enter image description here

And my code looks like this:

let plistPath3 = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.classData")
print(plistPath3) //returns "nil"

And it returns nil. Why does that happen?

Upvotes: 5

Views: 2444

Answers (2)

user9510567
user9510567

Reputation: 11

it take my 4 hour to solve it.. in my post pic

  1. clips and clipsKeyBoard must both add
  2. Capability must choose "All" , first time i just chose Release... it's a sad story enter image description here

Upvotes: 1

bdesham
bdesham

Reputation: 16089

I ran into this error while developing a share extension. It turned out that while I had added the App Group entitlement to the app’s target, I hadn’t added it to the extension’s target. I needed to select the extension from the project/target dropdown list:

A screenshot of Xcode that shows the location of the dropdown list with the projects and targets.

Then I clicked on the Capabilities tab and enabled App Groups. The App Group I had created for the application was already in the list; I just needed to check its checkbox. When I ran the app again, containerURL(forSecurityApplicationGroupIdentifier:) returned a non-nil value.

Upvotes: 3

Related Questions