In our iOS app we utilize a shared container to share files between our main iOS app and its extension (specifically WatchKit Extension), using [NSFileManager containerURLForSecurityApplicationGroupIdentifier:]
method. For debugging purposes we need to access the content of this shared container, so we've tried to export the whole App container using the Devices window in Xcode:
But, the Shared storage is not included in the container, probably because it sits in a different path on the Device itself.
The question is how can we get the shared container, if this is even possible?
I can download this container using Xcode > Device > Select App > Download Container menu option.
A container app is a single app that can be individualized by the user for their particular use. So if your app is an app for Nancy Drew books you don't make an app for each Nancy Drew book. You make one app and you sell each Nancy Drew books one at a time into that app.
I've been told by Xcode team members at WWDC that this is not possible (at time of writing, Xcode 7.3 & 8 beta 1). I've filed a radar, which I recommend everyone dupe or comment on so we can get this functionality.
For Swift 4 - 5 add this to applicationDidEnterBackground(_ application: UIApplication)
var appGroupIdentifier = "XXXXXXX"
let fromURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)
let docURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
let toURL = docURL.appendingPathComponent(appGroupIdentifier)
try? FileManager.default.removeItem(at: toURL)
try? FileManager.default.copyItem(at: fromURL, to: toURL)
Then download the app container using xcode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With