0

Hello NewYear's people.

I need to access a plist inside an app's group container.

To gain access in the sandboxed system what should I do to get it right. I did read then answer at Create directory in app group container swift but can't find the corresponding entitlement settings in XCode 11.

Is there a corresponding URL or path (String) function to get called? So far as I can see there is no .groupContainerDirectory option available.

Now I try to use the following code...

let appIdentifier = "UBF8T346G9.Office"
    let fileManager = FileManager.default
    let container = fileManager.containerURL(forSecurityApplicationGroupIdentifier: appIdentifier)

    print("Container \(container)")
    do{
        if let container = container {

            let directoryPath  = container.appendingPathComponent("Profile Settings")

            var isDir : ObjCBool = false

            let path = directoryPath.path
            if fileManager.fileExists(atPath: path, isDirectory: &isDir) {
                if isDir.boolValue {
                    print("file exists and is a directory")
                    let plistPath = url.appendingPathComponent( "com.microsoft.visualbasic.plist").path
                    let plistDict = NSDictionary(contentsOfFile: plistPath)
                    if let dict = plistDict {
                       print("Dict: \(dict)") // <<<<<< Never comes here
                    }
                }
            } 
        }
    } catch let error as NSError {
        print(error.description)
    }
}

is of course not working because I need some access app's their "group container"

Thank you.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
iPadawan
  • 898
  • 1
  • 12
  • 23
  • The following topic [Mac App Sandbox Group Container problems](https://stackoverflow.com/questions/15141853/mac-app-sandbox-group-container-problems) should be helpful. – Asperi Jan 03 '20 at 18:39
  • Thank you for your reaction, But I need access to another app's its Group Container folder and Plist. The mentioned link did show some sandbox access how to, but it isn't there in XCode 11. Did add extra info to show that the plist returns empty. – iPadawan Jan 04 '20 at 23:25
  • I should creat a line 'com.apple.security.temporary-exception.files.home-relative-path.read-write' key with the relative path in the projects entitlement file inside the project. Reading stuff: https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AppSandboxTemporaryExceptionEntitlements.html – iPadawan Jan 12 '20 at 21:20

1 Answers1

0

create a

com.apple.security.temporary-exception.files.home-relative-path.read-write

key with the relative path in the projects entitlement file inside the project in Xcode.

Reading stuff: https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AppSandboxTemporaryExceptionEntitlements.html

iPadawan
  • 898
  • 1
  • 12
  • 23