Bill
Bill

Reputation: 1659

Recompiling old cocoa app without sandbox

I have a couple of Cocoa apps that are distributed privately and do not use the app store. They haven't been touched for at least a year. I need to make some changes. They don't work properly with Apple's sandbox. I've tried to turn off sandboxing in Xcode (9.4.1), but the absence of an entitlements file seems to be interpreted as sandboxed. I've noticed that command line applications don't have this problem (yet). How can I get the old behavior back? In the past I signed the apps to minimize user confusion, so I would like to continue signing the apps, if possible.

Update: I created a simple app that only calls NSOpenPanel(), like this -

@IBAction func browseFile(sender: AnyObject) {

        let dialog = NSOpenPanel()

        dialog.title                   = "Choose a .pdf file"
        dialog.showsResizeIndicator    = true
        dialog.showsHiddenFiles        = false
        dialog.canChooseDirectories    = true
        dialog.canCreateDirectories    = false
        dialog.allowsMultipleSelection = false
        dialog.allowedFileTypes        = ["pdf"]

        if (dialog.runModal() == NSApplication.ModalResponse.OK) {
            let result = dialog.url // Pathname of the file

I tried building under Xcode 8 and Xcode 9. It seems something in the signing process has changed. If I enable sandboxing and give the appropriate entitlements, then the app runs without errors. Otherwise, I get the following error:

Faild to get owner UUID for url: file:///Users/david/Public error: Error

Note that this is with an entitlements file containing:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.app-sandbox</key>
    <false/>
</dict>
</plist>

Also, I'm not clear where "david" comes into this.

Upvotes: 1

Views: 327

Answers (1)

Bill
Bill

Reputation: 1659

Apparently this is a bug in NSOpenPanel, per Apple Technical Support. Currently they can not explain the contents of the error message, or why it only occurs when sandboxing is turned off. I filed a bug report with Apple.

Upvotes: 2

Related Questions