Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export shared container of an iOS App with Xcode6.2?

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:

Screenshot from 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?

like image 591
Sagi Iltus Avatar asked Apr 19 '15 08:04

Sagi Iltus


People also ask

How do I download containers in Xcode?

I can download this container using Xcode > Device > Select App > Download Container menu option.

What is container app in IOS?

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.


2 Answers

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.

like image 148
Brian Gerstle Avatar answered Sep 28 '22 12:09

Brian Gerstle


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.

like image 29
Dmih Avatar answered Sep 28 '22 10:09

Dmih