4

I want to access container app file in my custom keyboard extension through App Group feature.For That purpose I have create Group ID on my Apple portal and also added it in my both targets(Keyboard and app) I have successfully access data by NSUserDefaults its working fine I can access data. But I am stuck on getting file from container app I have access URL

NSURL *containerURL = [[NSFileManager defaultManager] 
           containerURLForSecurityApplicationGroupIdentifier:@"group.com.company.app"];

NSURL Return URL in following way.

/Users/AxisCyberTech1/Library/Developer/CoreSimulator/Devices/1649BBF4-6615-4E53-BFC9-A3D07F3CA70A/data/Containers/Shared/AppGroup/49A4F24B-30A8-474E-8FFA-072E0DF61CBD/

but this path not access any file from Container source bundle. How can I access container souce file

Andrew
  • 15,357
  • 6
  • 66
  • 101
Shinning River
  • 813
  • 1
  • 10
  • 23

2 Answers2

-2

There's another restriction for keyboard extension. You should set RequestsOpenAccess to YES in Info.plist then it can access the files.

https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html#//apple_ref/doc/uid/TP40014214-CH16-SW2

Chris Truman
  • 913
  • 1
  • 7
  • 25
-2

To get access to containing app bundle is sandboxed and not alloew to access from outside app. Call [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:YOUR_APP_GROUP_ID] to obtain App Group Shared container's URL.

Note that using NSFileCoordinator inside extension to access containing app shared container may cause the deadlock. See this documentation

rm-vanda
  • 3,122
  • 3
  • 23
  • 34