Post

Replies

Boosts

Views

Activity

NSSavePanel crashes on runModal()
Components: macOS 11.6, iMac (Retina 5K, 27-inch, Late 2014), Xcode: Version 13.0 (13A233) Capabilities: User selected & Download folder files Read/Write Language Swift 5 Small App fragment ========= BEGIN ========= import Cocoa @main class AppDelegate: NSObject, NSApplicationDelegate, NSComboBoxDelegate, NSOpenSavePanelDelegate {     let dialog = NSSavePanel()     @IBOutlet var window: NSWindow!     @IBOutlet weak var selectOutFileLabelOutlet: NSTextField!     @IBOutlet weak var selectFileCBOutlet : NSComboBox!     @IBOutlet weak var ouputFileNameOutlet: NSTextField!     @IBOutlet weak var browse4FileOutlet  : NSButton!     @IBOutlet weak var progressBarOutlet  : NSProgressIndicator!     @IBOutlet weak var convertButtonOutlet: NSButton!   @IBAction func convertButtonClicked(_ sender: Any) { // STUB     }     @IBAction func browseButtonClicked(_ sender: Any) {         dialog.title = "Choose output file"         dialog.showsResizeIndicator = true         dialog.showsHiddenFiles = true         dialog.canCreateDirectories    = true         dialog.allowedFileTypes = [".ear", ".mer", ".ven", ".mar", ".jup", ".sat", ".ura", ".nep", ".plu"]         dialog.allowsOtherFileTypes = true         dialog.treatsFilePackagesAsDirectories = true     let answer = dialog.runModal() // ERROR         if answer ==  NSApplication.ModalResponse.OK {             let results = dialog.url             // Do whatever you need with every selected file         print ( results!.path )         } else {             print ( "User clicked on 'Cancel'" )             return         }     }     var sourceFileName     : String = ""     var targetFileName     : String = ""     let resourcePathPrefix : String = "(Bundle.main.resourcePath!)/VSOP87-Files/"     var outputFilePath     : String = ""     func applicationDidFinishLaunching(_ aNotification: Notification) {         // Insert code here to initialize your application         dialog.delegate = self         selectFileCBOutlet.delegate = self         setupComboBox()     } } ==================== When the action: browseButtonClicked(_ sender: Any) is called all the properties of the "dialog" are set then after quite a wait (4 seconds or so) the following error is issued: === ERROR ========== `2021-10-03 15:24:17.110702-0700 ConvertVSOPToDataFile[4887:105883] -[NSSavePanel beginServicePanel]_block_invoke : Could not advance an Open/Save panel to run phase due to error: Error Domain=com.apple.ViewBridge Code=16 "(null)" UserInfo={com.apple.ViewBridge.error.hint=advance to run phase, com.apple.ViewBridge.error.description=NSViewBridgeInvalidError} 2021-10-03 15:24:17.114075-0700 ConvertVSOPToDataFile[4887:105883] -[NSSavePanel beginServicePanel] : an exception occurred during attempt to advance an Open/Save panel to run phase! 2021-10-03 15:24:17.116188-0700 ConvertVSOPToDataFile[4887:105883] -[NSSavePanel runModal] caught non-fatal NSObjectNotAvailableException 'The operation couldn’t be completed. (com.apple.ViewBridge error 16.)' with user dictionary {     error = "Error Domain=com.apple.ViewBridge Code=16 "(null)" UserInfo={com.apple.ViewBridge.error.hint=advance to run phase, com.apple.ViewBridge.error.description=NSViewBridgeInvalidError}"; } and backtrace ( 0   CoreFoundation                      0x00007fff205601db __exceptionPreprocess + 242 1   libobjc.A.dylib                     0x00007fff20299d92 objc_exception_throw + 48 2   AppKit                              0x00007fff237148ab -[NSSavePanel beginServicePanel] + 717 3   AppKit                              0x00007fff23715044 -[NSSavePanel runModal] + 98 4   ConvertVSOPToDataFile               0x000000010334cea1 $s21ConvertVSOPToDataFile11AppDelegateC19browseButtonClickedyyypF + 1313 5   ConvertVSOPToDataFile               0x000000010334d681 $s21ConvertVSOPToDataFile11AppDelegateC19browseButtonClickedyyypFTo + 65 6   AppKit                              0x00007fff22f0e2bb -[NSApplication(NSResponder) sendAction:to:from:] + 288 7   AppKit                              0x00007fff22f0e15f -[NSControl sendAction:to:] + 86 8   AppKit                              0x00007fff22f0e091 __26-[NSCell _sendActionFrom:]_block_invoke + 131 9   AppKit                              0x00007fff22f0df98 -[NSCell _sendActionFrom:] + 171 10  AppKit                              0x00007fff22f0dede -[NSButtonCell _sendActionFrom:] + 96 11  AppKit                              0x00007fff22f0afc7 NSControlTrackMouse + 1820 12  AppKit                              0x00007fff22f0a883 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 130 13  AppKit                              0x00007fff22f0a74a -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 697 14  AppKit                              0x00007fff22f09a72 -[NSControl mouseDown:] + 722 15  AppKit                              0x00007fff22f07e5e -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4961 16  AppKit                              0x00007fff22e77648 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2594 17  AppKit                              0x00007fff22e76a06 -[NSWindow(NSEventRouting) sendEvent:] + 347 18  AppKit                              0x00007fff22e74e14 -[NSApplication(NSEvent) sendEvent:] + 352 19  AppKit                              0x00007fff2314dbe1 -[NSApplication _handleEvent:] + 65 20  AppKit                              0x00007fff22cddc8e -[NSApplication run] + 623 21  AppKit                              0x00007fff22cb1e6c NSApplicationMain + 816 22  ConvertVSOPToDataFile               0x0000000103350064 $sSo21NSApplicationDelegateP6AppKitE4mainyyFZ + 36 23  ConvertVSOPToDataFile               0x0000000103350037 $s21ConvertVSOPToDataFile11AppDelegateC5$mainyyFZ + 39 24  ConvertVSOPToDataFile               0x0000000103350208 main + 24 25  libdyld.dylib                       0x00007fff20409f3d start + 1 26  ???                                 0x0000000000000003 0x0 + 3 ) ==============` END ============= Failure is consistent as is the error output. Any ideas would be appreciated! TIA ClarkW
2
0
1.5k
Oct ’21
How to prevent Metal API from being checked on every new project created
I don't use Metal in most of my projects. I don't want to use Metal in most of my projects. But every new macOS swift project I create has the Metal API Validation checked. This produces the dreaded "Unable to locate MetalPluginName property or is of the wrong type" and one or two other errors. How do I get Metal out of my default builds? I know how to uncheck the Validation API but I don't want it checked in the first place. macOS: 11.6 (20G165) Xcode: Version 13.0 (13A233) Any suggestions appreciated. TIA ClarkW
2
0
1.1k
Oct ’21
Swift, How to write [Any] to file and read back in?
I have some data that I extract some information from/ Generally it consists of a header containing some mixed format data (text and integer) followed by several lines of mixed format (Int, Double) information. EX: Header: " VERSION C3    EARTH     VARIABLE 1 (XYZ)       *T**0   1007 TERMS" from which I parse out ["C3", "EARTH", 1, 0, 1007] this is followed by 1007 lines containing numbers similar to: [3310, 232, 0, 0, 11, -21,  2,  0,  0,  0, -1,  0,  0,  1, -0.00000001572, -0.00000001245, 0.00000002005, 4.16423892775, 6303.67498687370] The input is all textual and to speed things up needs to be saved as binary data for input. That's the easy part -- read it in and parse it into arrays of type Any. Plists are too slow. Here is little code fragment of what I am trying to do: var targetFile: Data = Data() // read source file data (there is a try-catch here ignored in the code fragment)      let inputData = String ( contentsOf:  sourceFileUrl )      sourceFileByLines = inputData.components( separatedBy: "\n" ) // multiple headers followed by multiple lines of data, repeated // header loop starts here getKeyInfomationFromHeaderLine ( line: sourceFileByLines! [ nextline ], theVersion: &version, body: &aBody , currentVariable: &variable, aT0Power: &t0Power, aTermCount: &termCount ) var headerValues: [Any] = [String(version), String(aBody), variable, t0Power, termCount] targetfile += Data ( bytes: &headerValues, count: headerValues.count * MemoryLayout<[Any]>.stride ) // Start loop to process term data line. // Build binary line      for i in 0...13 { nextLineBinary [ i ] = Int ( nextLineSource [ i ] )! } for i in 14...18 {          nextLineBinary [ i ] = Double ( nextLineSource [ i ] )! } targetfile += Data ( bytes: &nextLineBinary, count: nextLineBinary.count * MemoryLayout<[Any]>.stride ) // increment & decrement loop control-variables // End loop for data lines // End loop for headers All the variables are defined and the loops are proper and run to completion. But when I read the data into an [[Any]] array the data is confused (extra data is found, especially in the header values). So the question is how should I be encoding, writing, reading, decoding and storing that data? Any suggestions appreciated. TIA, ClarkW
2
0
906
Oct ’21
Can someone help with this error: Device not configured (in target '<App_name>' from project '<Project_Name>'
I have an App I am converting from Xcode 11 to Xcode 14. I cleaned up several things and fixed deprecated and added new methods, etc. I compiled several times and each time my compiler anomalies were warnings. Mostly debug warnings (print statement commented out but the temp variable was assigned a value which generated an 'assigned but never read' warning; that kind of thing). Time to do the "Settings" cleanup. I did a clean and a reset errors followed by a build. I immediately got this error: `Build target StarParty of project StarParty with configuration Debug CpResource /Users/clarkw/Library/Developer/Xcode/DerivedData/StarParty-cgkfxhebstoajgcwqfevvzggyycn/Build/Products/Debug-iphonesimulator/StarParty.app/Settings.bundle /Volumes/Public/Projects/iOSApps/SIGHApps/Swift/StarParty/StarParty/Settings.bundle (in target 'StarParty' from project 'StarParty') cd /Volumes/Public/Projects/iOSApps/SIGHApps/Swift/StarParty builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /Volumes/Public/Projects/iOSApps/SIGHApps/Swift/StarParty/StarParty/Settings.bundle /Users/clarkw/ /Developer/Xcode/DerivedData/StarParty-cgkfxhebstoajgcwqfevvzggyycn/Build/Products/Debug-iphonesimulator/StarParty.app error: open /Volumes/Public/Projects/iOSApps/SIGHApps/Swift/StarParty/StarParty/Settings.bundle/Root.plist: Device not configured (in target 'StarParty' from project 'StarParty') open /Volumes/Public/Projects/iOSApps/SIGHApps/Swift/StarParty/StarParty/Settings.bundle/Root.plist: Device not configured Build failed 8/3/23, 01:28 7.5 seconds` Mac Studio, Apple M2 Ultra, 128GB RAM, Ventura 13.5, Xcode Version 14.3.1 (14E300c) I have diffed the plist file with my original (prior to error plist) and they are identical. Would anyone Please give me a clue what the error means? I'd appreciate it. TIA ClarkW
0
0
242
Aug ’23