I have an action extension for Safari that needs to read a file shared in my app's group. The code looks like this:
func doneWithResults(resultsForJavaScriptFinalizeArg: [NSObject: AnyObject]?) {
let fileManager = NSFileManager()
let groupUrl = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.App")
let sharedContainerPathLocation = groupUrl?.path
var text = ""
let textPath = sharedContainerPathLocation! + "/test.txt"
if let content = fileManager.contentsAtPath(textPath) {
text = String(data: content, encoding: NSUTF8StringEncoding)!
}
// Code to tell that we're complete here, not important for showing the bug.
}
Running this on the simulator perfectly works. However, when running it on a real device that also has the file that I'm looking for nothing happens when clicking the action extension and it returns these logs:
Sep 1 13:29:29 iPhone ReportCrash[16049] <Notice>: Formulating report for process[16048] Action
Sep 1 13:29:29 iPhone MobileSafari[15761] <Warning>: plugin App.Action interrupted
Sep 1 13:29:29 iPhone MobileSafari[15761] <Warning>: plugin App.Action invalidated
Sep 1 13:29:29 iPhone ReportCrash[16049] <Warning>: report not saved because it is non-actionable
Is this a known bug? I already reported it to Apple but if there's a workaround I'll gladly use it.