Does NSOpenPanel cache filenames, why am I getting a security error?

First off, I am rather new a Swift development. I come from a Microsoft C#.Net background.


I wrote this applicaiton some time ago for MacOS 10.11 using some version of Swift. When I opened it in XCode 9.4 and coverted it to Swift 4 and then fixed all the errors I ran it. When the app instatiates NSOpenPanel I see three warnings that files are not found. These files were at one time on my computer. I have not yet found a way to clear these cached filenames.


I would not be concerend about it except I am getting this weird error


error: use of undeclared identifier '$arg'
* thread #9, queue = 'quicklook.pluginload', stop reason = breakpoint 1.2
  * frame #0: 0x00007fff64c7c1f6 libc++abi.dylib`__cxa_throw
    frame #1: 0x00007fff4a909c1f Security`Security::UnixError::throwMeNoLogging(int) + 61
    frame #2: 0x00007fff4a6b7768 Security`Security::safeCopyFile(char const*, unsigned int, char const*, unsigned short) + 1174
    frame #3: 0x00007fff4a6b6531 Security`Security::MDSSession::updateDataBases() + 1863
    frame #4: 0x00007fff4a708865 Security`Security::MDSSession::DbOpen(char const*, cssm_net_address const*, unsigned int, Security::AccessCredentials const*, void const*, long&) + 155
    frame #5: 0x00007fff4a7086e4 Security`mds_DbOpen(long, char const*, cssm_net_address const*, unsigned int, cssm_access_credentials const*, void const*, long*) + 248
    frame #6: 0x00007fff4a6b5a73 Security`Security::MDSClient::Directory::cdsa() const + 97
    frame #7: 0x00007fff4a7c8ec0 Security`Security::MDSClient::Directory::dlGetFirst(cssm_query const&, cssm_db_record_attribute_data&, cssm_data*, cssm_db_unique_record*&) + 38
    frame #8: 0x00007fff4a6b553c Security`Security::CssmClient::Table::startQuery(Security::CssmQuery const&, bool) + 230
    frame #9: 0x00007fff4a6b5231 Security`Security::CssmClient::Table::fetch(Security::CssmClient::Query const&, int) + 121
    frame #10: 0x00007fff4a6b4a0c Security`MdsComponent::MdsComponent(Security::Guid const&) + 204
    frame #11: 0x00007fff4a6b4648 Security`CssmManager::loadModule(Security::Guid const&, unsigned int, Security::ModuleCallback const&) + 446
    frame #12: 0x00007fff4a6b43e7 Security`CSSM_ModuleLoad + 69
    frame #13: 0x00007fff4a707794 Security`SecCspHandleForAlgorithm + 140
    frame #14: 0x00007fff4a7076e6 Security`SecCmsUtilGetHashObjByAlgID + 30
    frame #15: 0x00007fff4a7075ec Security`SecCmsDigestContextStartMultiple + 155
    frame #16: 0x00007fff4a707538 Security`SecCmsSignedDataDecodeBeforeData + 33
    frame #17: 0x00007fff4a706aae Security`nss_cms_decoder_notify + 464
    frame #18: 0x00007fff4a6c27be Security`SEC_ASN1DecoderUpdate + 1388
    frame #19: 0x00007fff4a706895 Security`SecCmsDecoderUpdate + 33
    frame #20: 0x00007fff4a7065ef Security`CMSDecoderUpdateMessage + 73
    frame #21: 0x00007fff4a7ee87b Security`Security::CodeSigning::SecStaticCode::verifySignature() + 185
    frame #22: 0x00007fff4a7ee5d9 Security`Security::CodeSigning::SecStaticCode::validateDirectory() + 85
    frame #23: 0x00007fff4a7ef0ab Security`Security::CodeSigning::SecStaticCode::validateNonResourceComponents() + 15
    frame #24: 0x00007fff4a7f549c Security`Security::CodeSigning::SecStaticCode::staticValidateCore(unsigned int, Security::CodeSigning::SecRequirement const*) + 26
    frame #25: 0x00007fff4a7f334d Security`Security::CodeSigning::SecStaticCode::staticValidate(unsigned int, Security::CodeSigning::SecRequirement const*) + 71
    frame #26: 0x00007fff4a7ebb52 Security`SecStaticCodeCheckValidityWithErrors + 163
    frame #27: 0x00007fff49eb9786 QuickLook`QLCheckAppleSignature + 94
    frame #28: 0x00007fff49e84fc4 QuickLook`_QLLoadPluginAtURL + 1267
    frame #29: 0x00007fff49e8432a QuickLook`___QLLaunchUpdatingThread_block_invoke + 1093
    frame #30: 0x0000000100dbbcfe libdispatch.dylib`_dispatch_call_block_and_release + 12
    frame #31: 0x0000000100db3ddf libdispatch.dylib`_dispatch_client_callout + 8
    frame #32: 0x0000000100dc9c0b libdispatch.dylib`_dispatch_queue_serial_drain + 1169
    frame #33: 0x0000000100dbb851 libdispatch.dylib`_dispatch_queue_invoke + 322
    frame #34: 0x0000000100dcb01a libdispatch.dylib`_dispatch_root_queue_drain_deferred_wlh + 785
    frame #35: 0x0000000100dcfef3 libdispatch.dylib`_dispatch_workloop_worker_thread + 892
    frame #36: 0x0000000100e2ffd6 libsystem_pthread.dylib`_pthread_wqthread + 980
    frame #37: 0x0000000100e2fbed libsystem_pthread.dylib`start_wqthread + 13

I then execute register read in the debugger nd this is what my registers have


General Purpose Registers:
       rax = 0xdb1940d3f79a0095
       rbx = 0x000000010236eb20
       rcx = 0x0000000000000000
       rdx = 0x00007fff4a909bd8  Security`Security::UnixError::~UnixError()
       rdi = 0x000000010236eb20
       rsi = 0x00007fff99fdeac0  Security`typeinfo for Security::UnixError
       rbp = 0x000070000db65460
       rsp = 0x000070000db65448
        r8 = 0x0000000000000018
        r9 = 0x0000000000000000
       r10 = 0x0000000010236ebc
       r11 = 0x0000000000000019
       r12 = 0x000070000db65b20
       r13 = 0x00007fff4a99868f  "/private/var/db/mds/system/mdsObject.db"
       r14 = 0x0000000000000011
       r15 = 0x000070000db65470
       rip = 0x00007fff64c7c1f6  libc++abi.dylib`__cxa_throw
    rflags = 0x0000000000000246
        cs = 0x000000000000002b
        fs = 0x0000000000000000
        gs = 0x0000000000000000


Here is my code


  @IBAction func browse(_ sender: NSButton)
  {
    let open = NSOpenPanel()

    open.canChooseFiles = true
    open.canChooseDirectories = false
    open.allowsMultipleSelection = false
    open.runModal()
   
    if let fileURL = open.url
    {
      let file:String = fileURL.path
      fileField.stringValue = file
      textField.stringValue = ""
    }
  }


The error is thrown when i call open.runModal()


Any ideas?


I am running XCode 9.4

My MacOS deployment target is 10.11

I am running MacOS 10.13.4 on a late 2012 Mac Mini Server with 8gig of RAM


thanks,

Tyson

Turned out this is a system error and it runs fine if I execute from outside the XCode IDE, or from within the IDE on my MBP. Still would like to know how to trap this exception though. I have not found a way to trap it in Swift.

Does NSOpenPanel cache filenames, why am I getting a security error?
 
 
Q