Recompiling old cocoa app without sandbox

这一生的挚爱 提交于 2020-01-15 09:42:12

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/51220531/recompiling-old-cocoa-app-without-sandbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!