Post

Replies

Boosts

Views

Activity

Configuring a LaunchDaemon for a server process
I've developed a specialized web server in Swift using Vapor. I want to set it up to run reliably on macOS using a LaunchDaemon. It should start at boot and be restarted if it crashes. I'm having trouble finding a good guide to the latest flavor of launchctl, and how to use system domains. This is my plist: <?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>Debug</key> <true/> <key>Label</key> <string>com.latencyzero.FurnaceController</string> <key>Program</key> <string>/Users/rmann/Desktop/Run</string> <key>ProgramArguments</key> <array> <string>serve</string> <string>--hostname</string> <string>0.0.0.0</string> <string>--port</string> <string>80</string> </array> <key>KeepAlive</key> <true/> <key>Listeners</key> <dict> <key>SockServiceName</key> <string>http</string> <key>SockType</key> <string>tcp</string> <key>SockFamily</key> <string>IPv4</string> </dict> </dict> </plist> And I'm trying to invoke it like this: $ sudo enable system/com.latencyzero.FurnaceController But nothing happens. If I try kickstart, I get an error: $ sudo launchctl kickstart -p system/com.latencyzero.FurnaceController Could not find service "com.latencyzero.FurnaceController" in domain for system $ sudo launchctl kickstart -p uid/501/com.latencyzero.FurnaceController Unrecognized target specifier. Usage: launchctl kickstart [-k] [-p] <service-target>         -k      Terminates the service if it is already running.         -p      Prints the PID of the service that was started.         -s      Starts the service suspended so that a debugger may attach. <service-target> takes a form of <domain-target>/<service-id>. Please refer to `man launchctl` for explanation of the <domain-target> specifiers. Bootstrap also doesn't work as I'd expect: $ sudo launchctl bootstrap system/com.latencyzero.FurnaceController Usage: launchctl bootstrap <domain-target> [service-path, service-path2, ...] <service-target> takes a form of <domain-target>/<service-id>. Please refer to `man launchctl` for explanation of the <domain-target> specifiers. The plist is in /Library/LaunchDaemons/com.latencyzero.FurnaceController.plist I'd rather not have to launch this in a user domain, as I'm handing this app off to my client, and the fewer customization needed, the better.
1
0
2.1k
Aug ’22
SCNSceneRendererDelegate example in SwiftUI?
I've got a Game @StateObject in my app that's passed to my main ContentView. I'm trying to figure out how best create a SCNSceneRendererDelegate instance that has a reference to the Game state, and then pass that to the SceneView inside my ContentView. I'm trying to do it like this, but obviously this doesn't work because self isn't available at init time: struct ContentView : View { let game : Game var scene = SCNScene(named: "art.scnassets/ship.scn") var cameraNode : SCNNode? { self.scene?.rootNode.childNode(withName: "camera", recursively: false) } var rendererDelegate = RendererDelegate(game: self.game) // Cannot find 'self' in scope var body: some View { SceneView(scene: self.scene, pointOfView: self.cameraNode, delegate: self.rendererDelegate) } } The intent is that in my renderer delegate, I'll update my game's simulation state. Because my game state is an ObservableObject, everything else (I have a bunch of SwiftUI) should update.
1
0
754
Sep ’22
building for macOS-x86_64 but attempting to link with file built for macOS-arm64 on M1 Mac with "build for active arch only" set
I'm not sure why, but it seems my Xcode project is trying to build for x86 (on my M1 Mac), even though both Debug and Release configurations have ONLY_ACTIVE_ARCH = YES. It's clearly trying to build for x86, as evidenced by the -target x86_64-apple-macos13.0 in the invocation. But I can't figure out why. The full link stage output: Ld /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Products/Debug/MyProject.app/Contents/MacOS/MyProject normal (in target 'MyProject' from project 'MyProject')     cd /Users/me/Projects/MyProject     /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk -L/Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/EagerLinkingTBDs -L/Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Products/Debug -L/opt/homebrew/opt/llvm/lib -F/Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/EagerLinkingTBDs -F/Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Products/Debug -filelist /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/MyProject.build/Debug/MyProject.build/Objects-normal/x86_64/MyProject.LinkFileList -dead_strip -Xlinker -object_path_lto -Xlinker /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/MyProject.build/Debug/MyProject.build/Objects-normal/x86_64/MyProject_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime -framework Cocoa -lcurses -lLLVMAnalysis -lLLVMBitReader -lLLVMCodeGen -lLLVMCore -lLLVMExecutionEngine -lLLVMMC -lLLVMObject -lLLVMRuntimeDyld -lLLVMScalarOpts -lLLVMSelectionDAG -lLLVMSupport -lLLVMTarget -lLLVMTransformUtils -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lz -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/MyProject.build/Debug/MyProject.build/Objects-normal/x86_64/MyProject_dependency_info.dat -o /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Products/Debug/MyProject.app/Contents/MacOS/MyProject ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMAnalysis.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMBitReader.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMCore.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMExecutionEngine.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMCodeGen.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMMC.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMRuntimeDyld.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMObject.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMX86Info.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMTarget.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMSupport.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMScalarOpts.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMSelectionDAG.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMTransformUtils.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMX86CodeGen.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMX86Desc.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: in '/opt/homebrew/opt/llvm/lib/libunwind.dylib', building for macOS-x86_64 but attempting to link with file built for macOS-arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) If I change the ARCHS to just arm64, then it builds fine.
1
0
3.4k
Nov ’22
What is BUNDLE_EXECUTABLE_FOLDER_PATH?
What is BUNDLE_EXECUTABLE_FOLDER_PATH? I came across this in a freshly-created iOS project (Xcode 14.2). In the unit tests target it created, it set TEST_HOST to $(BUILT_PRODUCTS_DIR)/MyApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/MyApp As far as I can tell, nothing sets BUNDLE_EXECUTABLE_FOLDER_PATH, and I can’t find it in any of the existing Xcode build settings. It's not set for Run Scripts, either, although these are close (and yes, this is an iOS project, not sure why one is MacOS): export BUNDLE_EXECUTABLE_FOLDER_NAME_deep\=MacOS export BUNDLE_EXTENSIONS_FOLDER_PATH\=Extensions A project I created several years ago does not have the TEST_HOST predefined that way.
1
0
1.3k
May ’23
Customizing option-close Window in SwiftUI?
I have a SwiftUI app made up of two types of window. If I hold the option key while clicking in the close box of one window, it closes all the app windows. I want to change that behavior to just close all the windows of a particular type (or use any other criteria, for that matter). Is this even possible?
0
0
449
Feb ’23
Previewing macOS Settings view?
I'm using Settings to implement the preferences in macOS, with a TabView. Runs fine, but in Xcode preview, it renders the buttons differently. Clearly Settings is applying some kind of button style (or TabView knows it needs to change), but how can I get this to work in a preview? I can't preview Settings directly.
0
0
524
Feb ’23
How do I sign and export a macOS app? Xcode says it can't communicate with Apple
I'm trying to sign and export my macOS app. I do: Archive Distribute App Developer ID -> Export -> Automatically Manage Signing -> FAIL Communication with Apple failed You are not allowed to perform this operation. Please check with one of your Team Admins, or, if you need further assistance, please contact Apple Developer Program Support. https://developer.apple.com/support No profiles for '' were found Xcode couldn't find any Developer ID provisioning profiles matching ''. It should create those for me. I tried to create them via the website, but that ends up making me create a certificate (although it is not clear what kind of certificate). So I do my best to choose the right kind, and then it still doesn't create a profile. I try again, and it says there's no certificate available, so it prompts me to do that again. WHY IS THIS STUFF STILL SO HARD TO DO?
11
0
1.6k
Mar ’23
Best way to update asynchronous model property in SwiftUI?
I'm working on a SwiftUI client app for my web service. A logged-in user can belong to one or more Organizations, and in the app's settings UI, the user can change which organization is the current selectedOrg. The selected org is displayed using a Picker view in the settings UI. The Model is made available to the UI primarily through @EnvironmentObject. When the user changes the selectedOrg, the app has to fetch some data (a set of Machine records) and set the result in the model. I see at least two ways to do this. A) Use @State in the SwiftUI view, initialized with the current selectedOrg in the model, and .onChange(of:) that state to then call a method that sets the new org and starts the relevant data fetch. B) Bind to the selectedOrg in the model, and use willSet/didSet inside the model to initiate the network request. The latter option feels better, because it pulls a lot of the logic out of the views and into the model/business logic. What are your thoughts on this?
0
0
588
Mar ’23
Preventing macOS from moving my window out of menu bar or notch area?
I have a multi-timezone clock displayed in a very thin window I like to put up on top of my menu bar or in the empty space to the left or right of the notch (when my laptop is not the primary display). There's no issue moving it there, but every time the screens reconfigure, macOS moves my window down out of that area. Is there any way to exempt an NSWindow (or a SwitUI window) from this repositioning behavior?
0
0
615
Apr ’23
When importing app with @testable, get “Missing required module 'CTrueTime'” using SPM
I have an old project Objective-C iOS app I've been updating to Swift. It used to use Carthage, but now uses only SPM for dependencies. One such dependency is TrueTime (which was updated to support SPM by that author). It has two products, TrueTime, a Swift library, and CTrueTime a header-only C library with some packed, byte-aligned structs used when parsing NTP responses. I’m adding unit tests to my project, and when I import the app module with @testable import MyApp, the build fails on that line with @testable import MyApp ^ <unknown>:0: error: missing required module 'CTrueTime' The app itself builds and runs just fine. If I don’t import the app, then I have to expressly add code I want to test to the test target, which is not the right way to do these things. The other dependencies I have all work fine, but none have a C library product. I get a warning about implicitly including a bridging header, but I don’t think that has anything to do with this. Update: I also just tried adding TrueTime to a modern, pure SwiftUI iOS app, and I get the same issue. Is there something more I need to add to my test target config? (I've also posted this to stack overflow https://stackoverflow.com/questions/76284838/when-importing-app-with-testable-get-missing-required-module-ctruetime-usi)
0
0
1.5k
May ’23
Does BGAppRefreshTask get called when your app is foreground or connected to the debugger?
I have yet to see iOS call my background task. I can get it to call it with the debug support (_simulateLaunchForTaskWithIdentifier), but not on its own. Does being foreground suppress the task call? Does being connected to the debugger (but in the background) suppress the call? Does an Xcode-installed app get its background task called? What is the Xcode scheme Run Info option “Launch due to a background fetch event"? Xcode 15b1 and iOS 17b1.
0
0
1.1k
Jun ’23
How does SwiftUI decide what default menu items to show on macOS?
I'm trying to write a simple image converter app. I want it to open any image file, and export that image as another type. I started with the multiplatform document app template in Xcode 15b2, and suppressed the New command with .commands { CommandGroup(replacing: CommandGroupPlacement.newItem) {} } I also changed the document readable types: static var readableContentTypes: [UTType] { [.image] } So far, so good. Then I tried modifying the document type declaration to be public.image, and removed the Imported UTI (reasoning that it’s a standard type and shouldn’t need to be redundantly declared, and how can I possibly list all the possible image filename extensions?), but I’m not at all sure I did that right. And somewhere in all that, I noticed that my File menu no longer has an Open command. Does SwiftUI look at the declared document type or imported UTIs to decide what the File menu should look like? UPDATE: Ah, suppressing the New menu also suppressed the Open/Open Recent menu items. That's frustrating.
0
0
607
Jun ’23
Sample code for wwdc21 Actors talk?
In this talk , at 12:00, the speaker refers to code associated with this talk. But I can't find it anywhere. Is it available?
Replies
1
Boosts
0
Views
897
Activity
Jan ’22
Handle URL in macOS SwiftUI app?
How do I handle URLs in a SwiftUI app? The only thing I can find is to put onOpenURL in my App's WindowGroup view content, but that makes a new window for every URL that gets handled.
Replies
0
Boosts
0
Views
821
Activity
Jan ’22
Configuring a LaunchDaemon for a server process
I've developed a specialized web server in Swift using Vapor. I want to set it up to run reliably on macOS using a LaunchDaemon. It should start at boot and be restarted if it crashes. I'm having trouble finding a good guide to the latest flavor of launchctl, and how to use system domains. This is my plist: <?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>Debug</key> <true/> <key>Label</key> <string>com.latencyzero.FurnaceController</string> <key>Program</key> <string>/Users/rmann/Desktop/Run</string> <key>ProgramArguments</key> <array> <string>serve</string> <string>--hostname</string> <string>0.0.0.0</string> <string>--port</string> <string>80</string> </array> <key>KeepAlive</key> <true/> <key>Listeners</key> <dict> <key>SockServiceName</key> <string>http</string> <key>SockType</key> <string>tcp</string> <key>SockFamily</key> <string>IPv4</string> </dict> </dict> </plist> And I'm trying to invoke it like this: $ sudo enable system/com.latencyzero.FurnaceController But nothing happens. If I try kickstart, I get an error: $ sudo launchctl kickstart -p system/com.latencyzero.FurnaceController Could not find service "com.latencyzero.FurnaceController" in domain for system $ sudo launchctl kickstart -p uid/501/com.latencyzero.FurnaceController Unrecognized target specifier. Usage: launchctl kickstart [-k] [-p] <service-target>         -k      Terminates the service if it is already running.         -p      Prints the PID of the service that was started.         -s      Starts the service suspended so that a debugger may attach. <service-target> takes a form of <domain-target>/<service-id>. Please refer to `man launchctl` for explanation of the <domain-target> specifiers. Bootstrap also doesn't work as I'd expect: $ sudo launchctl bootstrap system/com.latencyzero.FurnaceController Usage: launchctl bootstrap <domain-target> [service-path, service-path2, ...] <service-target> takes a form of <domain-target>/<service-id>. Please refer to `man launchctl` for explanation of the <domain-target> specifiers. The plist is in /Library/LaunchDaemons/com.latencyzero.FurnaceController.plist I'd rather not have to launch this in a user domain, as I'm handing this app off to my client, and the fewer customization needed, the better.
Replies
1
Boosts
0
Views
2.1k
Activity
Aug ’22
SCNSceneRendererDelegate example in SwiftUI?
I've got a Game @StateObject in my app that's passed to my main ContentView. I'm trying to figure out how best create a SCNSceneRendererDelegate instance that has a reference to the Game state, and then pass that to the SceneView inside my ContentView. I'm trying to do it like this, but obviously this doesn't work because self isn't available at init time: struct ContentView : View { let game : Game var scene = SCNScene(named: "art.scnassets/ship.scn") var cameraNode : SCNNode? { self.scene?.rootNode.childNode(withName: "camera", recursively: false) } var rendererDelegate = RendererDelegate(game: self.game) // Cannot find 'self' in scope var body: some View { SceneView(scene: self.scene, pointOfView: self.cameraNode, delegate: self.rendererDelegate) } } The intent is that in my renderer delegate, I'll update my game's simulation state. Because my game state is an ObservableObject, everything else (I have a bunch of SwiftUI) should update.
Replies
1
Boosts
0
Views
754
Activity
Sep ’22
building for macOS-x86_64 but attempting to link with file built for macOS-arm64 on M1 Mac with "build for active arch only" set
I'm not sure why, but it seems my Xcode project is trying to build for x86 (on my M1 Mac), even though both Debug and Release configurations have ONLY_ACTIVE_ARCH = YES. It's clearly trying to build for x86, as evidenced by the -target x86_64-apple-macos13.0 in the invocation. But I can't figure out why. The full link stage output: Ld /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Products/Debug/MyProject.app/Contents/MacOS/MyProject normal (in target 'MyProject' from project 'MyProject')     cd /Users/me/Projects/MyProject     /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk -L/Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/EagerLinkingTBDs -L/Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Products/Debug -L/opt/homebrew/opt/llvm/lib -F/Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/EagerLinkingTBDs -F/Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Products/Debug -filelist /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/MyProject.build/Debug/MyProject.build/Objects-normal/x86_64/MyProject.LinkFileList -dead_strip -Xlinker -object_path_lto -Xlinker /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/MyProject.build/Debug/MyProject.build/Objects-normal/x86_64/MyProject_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime -framework Cocoa -lcurses -lLLVMAnalysis -lLLVMBitReader -lLLVMCodeGen -lLLVMCore -lLLVMExecutionEngine -lLLVMMC -lLLVMObject -lLLVMRuntimeDyld -lLLVMScalarOpts -lLLVMSelectionDAG -lLLVMSupport -lLLVMTarget -lLLVMTransformUtils -lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lz -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Intermediates.noindex/MyProject.build/Debug/MyProject.build/Objects-normal/x86_64/MyProject_dependency_info.dat -o /Users/me/Library/Developer/Xcode/DerivedData/MyProject-fbzxsemlztqkmsgdutlriortdmmd/Build/Products/Debug/MyProject.app/Contents/MacOS/MyProject ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMAnalysis.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMBitReader.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMCore.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMExecutionEngine.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMCodeGen.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMMC.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMRuntimeDyld.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMObject.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMX86Info.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMTarget.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMSupport.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMScalarOpts.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMSelectionDAG.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMTransformUtils.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMX86CodeGen.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /opt/homebrew/opt/llvm/lib/libLLVMX86Desc.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: in '/opt/homebrew/opt/llvm/lib/libunwind.dylib', building for macOS-x86_64 but attempting to link with file built for macOS-arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) If I change the ARCHS to just arm64, then it builds fine.
Replies
1
Boosts
0
Views
3.4k
Activity
Nov ’22
Any way to disable the Xcode debugger's display-value-on-hover feature?
When stepping through code in the Xcode debugger, hovering over a variable in the context causes a little popover to appear, displaying the value of that variable. Is there any way to disable this behavior? I find it gets in the way and I never use it.
Replies
0
Boosts
0
Views
964
Activity
Dec ’22
What is BUNDLE_EXECUTABLE_FOLDER_PATH?
What is BUNDLE_EXECUTABLE_FOLDER_PATH? I came across this in a freshly-created iOS project (Xcode 14.2). In the unit tests target it created, it set TEST_HOST to $(BUILT_PRODUCTS_DIR)/MyApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/MyApp As far as I can tell, nothing sets BUNDLE_EXECUTABLE_FOLDER_PATH, and I can’t find it in any of the existing Xcode build settings. It's not set for Run Scripts, either, although these are close (and yes, this is an iOS project, not sure why one is MacOS): export BUNDLE_EXECUTABLE_FOLDER_NAME_deep\=MacOS export BUNDLE_EXTENSIONS_FOLDER_PATH\=Extensions A project I created several years ago does not have the TEST_HOST predefined that way.
Replies
1
Boosts
0
Views
1.3k
Activity
May ’23
Customizing option-close Window in SwiftUI?
I have a SwiftUI app made up of two types of window. If I hold the option key while clicking in the close box of one window, it closes all the app windows. I want to change that behavior to just close all the windows of a particular type (or use any other criteria, for that matter). Is this even possible?
Replies
0
Boosts
0
Views
449
Activity
Feb ’23
Previewing macOS Settings view?
I'm using Settings to implement the preferences in macOS, with a TabView. Runs fine, but in Xcode preview, it renders the buttons differently. Clearly Settings is applying some kind of button style (or TabView knows it needs to change), but how can I get this to work in a preview? I can't preview Settings directly.
Replies
0
Boosts
0
Views
524
Activity
Feb ’23
How do I sign and export a macOS app? Xcode says it can't communicate with Apple
I'm trying to sign and export my macOS app. I do: Archive Distribute App Developer ID -> Export -> Automatically Manage Signing -> FAIL Communication with Apple failed You are not allowed to perform this operation. Please check with one of your Team Admins, or, if you need further assistance, please contact Apple Developer Program Support. https://developer.apple.com/support No profiles for '' were found Xcode couldn't find any Developer ID provisioning profiles matching ''. It should create those for me. I tried to create them via the website, but that ends up making me create a certificate (although it is not clear what kind of certificate). So I do my best to choose the right kind, and then it still doesn't create a profile. I try again, and it says there's no certificate available, so it prompts me to do that again. WHY IS THIS STUFF STILL SO HARD TO DO?
Replies
11
Boosts
0
Views
1.6k
Activity
Mar ’23
Best way to update asynchronous model property in SwiftUI?
I'm working on a SwiftUI client app for my web service. A logged-in user can belong to one or more Organizations, and in the app's settings UI, the user can change which organization is the current selectedOrg. The selected org is displayed using a Picker view in the settings UI. The Model is made available to the UI primarily through @EnvironmentObject. When the user changes the selectedOrg, the app has to fetch some data (a set of Machine records) and set the result in the model. I see at least two ways to do this. A) Use @State in the SwiftUI view, initialized with the current selectedOrg in the model, and .onChange(of:) that state to then call a method that sets the new org and starts the relevant data fetch. B) Bind to the selectedOrg in the model, and use willSet/didSet inside the model to initiate the network request. The latter option feels better, because it pulls a lot of the logic out of the views and into the model/business logic. What are your thoughts on this?
Replies
0
Boosts
0
Views
588
Activity
Mar ’23
Preventing macOS from moving my window out of menu bar or notch area?
I have a multi-timezone clock displayed in a very thin window I like to put up on top of my menu bar or in the empty space to the left or right of the notch (when my laptop is not the primary display). There's no issue moving it there, but every time the screens reconfigure, macOS moves my window down out of that area. Is there any way to exempt an NSWindow (or a SwitUI window) from this repositioning behavior?
Replies
0
Boosts
0
Views
615
Activity
Apr ’23
When importing app with @testable, get “Missing required module 'CTrueTime'” using SPM
I have an old project Objective-C iOS app I've been updating to Swift. It used to use Carthage, but now uses only SPM for dependencies. One such dependency is TrueTime (which was updated to support SPM by that author). It has two products, TrueTime, a Swift library, and CTrueTime a header-only C library with some packed, byte-aligned structs used when parsing NTP responses. I’m adding unit tests to my project, and when I import the app module with @testable import MyApp, the build fails on that line with @testable import MyApp ^ <unknown>:0: error: missing required module 'CTrueTime' The app itself builds and runs just fine. If I don’t import the app, then I have to expressly add code I want to test to the test target, which is not the right way to do these things. The other dependencies I have all work fine, but none have a C library product. I get a warning about implicitly including a bridging header, but I don’t think that has anything to do with this. Update: I also just tried adding TrueTime to a modern, pure SwiftUI iOS app, and I get the same issue. Is there something more I need to add to my test target config? (I've also posted this to stack overflow https://stackoverflow.com/questions/76284838/when-importing-app-with-testable-get-missing-required-module-ctruetime-usi)
Replies
0
Boosts
0
Views
1.5k
Activity
May ’23
Does BGAppRefreshTask get called when your app is foreground or connected to the debugger?
I have yet to see iOS call my background task. I can get it to call it with the debug support (_simulateLaunchForTaskWithIdentifier), but not on its own. Does being foreground suppress the task call? Does being connected to the debugger (but in the background) suppress the call? Does an Xcode-installed app get its background task called? What is the Xcode scheme Run Info option “Launch due to a background fetch event"? Xcode 15b1 and iOS 17b1.
Replies
0
Boosts
0
Views
1.1k
Activity
Jun ’23
How does SwiftUI decide what default menu items to show on macOS?
I'm trying to write a simple image converter app. I want it to open any image file, and export that image as another type. I started with the multiplatform document app template in Xcode 15b2, and suppressed the New command with .commands { CommandGroup(replacing: CommandGroupPlacement.newItem) {} } I also changed the document readable types: static var readableContentTypes: [UTType] { [.image] } So far, so good. Then I tried modifying the document type declaration to be public.image, and removed the Imported UTI (reasoning that it’s a standard type and shouldn’t need to be redundantly declared, and how can I possibly list all the possible image filename extensions?), but I’m not at all sure I did that right. And somewhere in all that, I noticed that my File menu no longer has an Open command. Does SwiftUI look at the declared document type or imported UTIs to decide what the File menu should look like? UPDATE: Ah, suppressing the New menu also suppressed the Open/Open Recent menu items. That's frustrating.
Replies
0
Boosts
0
Views
607
Activity
Jun ’23