Post

Replies

Boosts

Views

Activity

Menu bar and Help window
by selecting Help under my Help menu item or cmd-h no window appears until the menu bar is touched. myApp.swift file: import SwiftUI import QuickLook @main struct myApp: App { @Environment(\.openWindow) var openWindow @State var helpURL: URL? = nil var body: some Scene { WindowGroup { ContentView() } .commandsReplaced { CommandGroup(before: .appInfo) { Button("Quit") { NSApp.terminate(nil) }.keyboardShortcut("q") } CommandGroup(before: .help) { //FIXME: only shows help if the menu bar is touched again. Button("Help") { helpURL = Bundle.main.url(forResource: "help", withExtension: "txt") } .keyboardShortcut("h") .quickLookPreview($helpURL) } } } } How should this be coded for proper action? Thanks
1
0
81
Jul ’25
swift Process() return values
How do I access a returned value from a Process(), in this case 'which'... var sips_path : String? //MARK: locate sips on local machine let which_sips = Process() which_sips.executableURL = URL(fileURLWithPath: "which") which_sips.arguments = ["sips"] do { sips_path = try which_sips.run() } catch let error as NSError { sips_path = "/usr/bin/sips"; print("Failed to execute which_sips", error) }line 8. gets compiler error "Cannot assign value of type '()' to type 'String?'" I believe, but cannot prove, 'which' returns a string. .run() throws and throws are for errors only, right? So where is the result of calling which?It seems I should use a closure to use $0 but it's already in one...line 9. intends to assign a default path.
13
1
7.8k
Oct ’21
SceneKits future
I have developed an app using SceneKit since Swift came out. Now SwiftUI is out and uses structs rather than classes. SceneKit is a cascade of classes. As a newbie, I am concerned that my code might be obsolete through depreciations soon after publication and I'd rather get ahead of the issues now. So, is SceneKit long-term viable? My first attempts at converting my custom classes to structs seems impossible without Apple leading the way. If I understand correctly, I can make a struct whose only member is an instance of a class, but the benefits of the struct, e.g., minimal memory, processing time, etc., are lost.
13
0
8k
Sep ’21
JSONEncoder has changed
Prior to Sonoma 14.0 and Xcode 15.0.1 my custom class was encoded in a consistent pattern that I exploited to append the file many thousands of times. Now, the encodings are of a seemingly random pattern that cannot be exploited to append. This may be a result of efforts to make the encoding more efficient or virtually any other reason. My questions are: how do I revert to the previous JSONEncoder while using current OS & Xcode versions?, i.e, what files and in what locations do I restore? is it likely to be sustainable if I did so? It has been previously noted that atomic files are not "append able" which is why I used JSON in the first place. Any info or suggestion is appreciated. Thank you.
2
1
853
Nov ’23
Using LAPACK in macOS 13.3
My app complied when “Minimum Deployments” was 12.x but with 13.3 I get the alert: " 'dsyev_' was deprecated in macOS 13.3: The CLAPACK interface is deprecated. Please compile with -DACCELERATE_NEW_LAPACK to access the new lapack headers." Where do I enter this compiler flag? I am using XCode 14.3 Ventura 13.3.1 on an Intel macMini Build Phases:Link Binary With Libraries (3 items) libf77lapack.tbd libclapack.tbd liblapack.tbd each of which is provided by Apple. I have rooted around in “Build Settings”, “ Build Phases”, and “Build Rules” but can’t see where to put the compiler flag. Thanks
5
1
2.1k
Aug ’23