NSOpenPanel Swift Warning Message on OSX 10.12
Asked Answered
P

0

6

Recently upgrade to macOS Sierra version 10.12, Xcode version 8.2.1

The following code works on OS Sierra but with a warning message. It works on the previous OS El Capitan 10.11 without warning message.

Anyone can advise how to get rip of this warning message?

warning: <NSRemoteView: 0x618000123200> determined it was necessary to configure <NSVBOpenPanel: 0x102e816d0> to support remote view vibrancy

my code is below:

@IBAction func btnChooseFile(_ sender: Any)
    {
        let dialog = NSOpenPanel()
        dialog.title                   = "Choose a project file"
        dialog.showsResizeIndicator    = true
        dialog.showsHiddenFiles        = false
        dialog.canChooseDirectories    = false
        dialog.canCreateDirectories    = false
        dialog.allowsMultipleSelection = false
        dialog.allowedFileTypes        = ["txt"]

        if (dialog.runModal() == NSModalResponseOK) {
            let result = dialog.url // Pathname of the file
            if (result != nil) {
                let path = result!.path
                txtProject.stringValue = path
            }else{
                // Display error message
            }
        } else {
            return
        }
    }
Potaufeu answered 22/3, 2017 at 20:11 Comment(3)
I'm having the same problem with a project created in Xcode 9 targeting macOS 10.12; projects created with Xcode 8 and compiled with Xcode 9 do not have the same problem under 10.12. (May I also point out that your code sets a lot of properties to their default values; the only setting you need are the title and the allowedFileTypes)Zellers
Ah. Found it. NSVBOpenPanel is the special class connected to sandboxed apps; so unless you turn sandboxing off, it seems you have to live with this problem. (Insights gained from #37120131)Zellers
That's annoying, 'cause there's another bug that means you have to turn Sandboxing ON or it complains about missing iCloud support!Affianced

© 2022 - 2024 — McMap. All rights reserved.