Post

Replies

Boosts

Views

Activity

Xcode 16 can't target RealityKitContent on macOS 14?
I'm working on a multi-platform app (macOS and visionOS for now). In these early stages it’s easier to target the Mac, but I started with a visionOS project. One of the things the template creates is a RealityKitContent package dependency. I can target macOS 14.5 in Xcode, but when it goes to build the RealiityKitContent, I get this error: error: Building for 'macosx', but '14.0' must be >= '15.0' [macosx] info: realitytool ["/Applications/Xcode-beta.app/Contents/Developer/usr/bin/realitytool" "compile" "--platform" "macosx" "--deployment-target" "14.0" … Unfortunately, I'm unwilling to update this machine to macOS 15, as it's too risky. Running macOS 15 in a VM is not possible (Apple Silicon). This strikes me as a bug, or severe shortcoming, of realitytool. This was introduced with visionOS 1.0, and should be able to target macOS < 15. It's not really reasonable to use Xcode 15, since soon enough Apple will require I build with Xcode 16 for submission to the App Store. Is this a bug, or intentional?
2
1
895
Jul ’24
Suddenly getting "Trailing closure passed to parameter of type 'Visibility' that does not accept a closure" for toolbars
Not sure exactly what’s going on here. I’ve been building out this little app for the past couple of weeks using Xcode 16 betas, and in a couple of places I have code like this: EditItemView(item: inItem) .toolbar { ToolbarItem { Button(action: { self.printLabel(item: inItem) }) { Label("Print Label", systemImage: "printer.filled.and.paper") } } } Now all of a sudden I'm getting an error on .toolbar: “Trailing closure passed to parameter of type 'Visibility' that does not accept a closure.” Looking at the comment for toolbar, it says this method "specifies the visibility," which is a weird thing for it to do with a name like that. But it also has a deprecation tag that I don't quite understand: @available(macOS, introduced: 13.0, deprecated: 100000.0, renamed: "toolbarVisibility(_:for:)"). The name change makes sense, given the description. But what is the huge deprecation version number? Just a hack? And why is this code no longer compiling? As I'm commenting out instances of this, all my toolbars are failing in this way. ETA: yeah, I finally found the right declaration of .toolbar: func toolbar<Content>(@ViewBuilder content: () -> Content) -> some View where Content : View. It's no longer choosing that one. I hate Swift sometimes. ETA2: I finally whittled it down to it not liking Label for some reason. Replacing that with Image works. But of course, the compiler won't tell me why. ETA3: It's worse than I thought: I tried to make a small test case for a bug, and Label works just fine. Why does my code not?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
1
721
Oct ’24
Can't get forum notifications to work in Safari
Every time I visit these forums, a banner is displayed at the top asking me to opt-in to notifications. I click "opt-in," the banner disappears, and no notifications are sent. If I visit my forum profile, it says my browser isn't allowing notifications: If I look in Settings-&gt;Websites, in the list of "These websites have asked for permission to show alerts in Notification Center," there are no apple.com websites whatsoever, including developer.apple.com. "Allow websites to ask for permission to send notifications" is checked, and I have many other websites in that list. I consider this to be a bug in Safari, but maybe it’s an issue with the forum itself (although I doubt it). I've submitted a Radar for it, but haven't heard anything back (I never do). EDIT: I realize I should've put this in another category, but it won't let me change that now.
1
1
607
Jan ’25
"Duplicate output file"/"Unable to build node" for localized folders
We have some HTML content embedded in our app. These live in two top-level folders. These folders have been localized, and so live in Resources/en.lproj/HelpContent and Resources/fr.lproj/HelpContent (for example). Similarly, we have a bunch of localized .storyboard files.Xcode 8 builds this just fine. Xcode 9b6 complains:duplicate output file '/Users/me/Library/Developer/Xcode/DerivedData/MyApp- fdskkibuvbsubudkmqtgsjxmyqme/Build/Products/Debug-iphoneos/MyApp.app/ HelpContent' on task: CpResource /Users/me/Projects/Clients/MyCompany/repo/mp_vision/iOS/Controller/MyApp /Resources/fr.lproj/HelpContent /Users/me/Library/Developer/Xcode/DerivedData/MyApp- fdskkibuvbsubudkmqtgsjxmyqme/Build/Products/Debug-iphoneos/MyApp.app/ HelpContent (in target 'MyApp')unable to build node: '/Users/me/Library/Developer/Xcode/DerivedData/MyApp- fdskkibuvbsubudkmqtgsjxmyqme/Build/Products/Debug-iphoneos/MyApp.app/ HelpContent' (node is produced by multiple commands; e.g., 'b1132708c20f997e752faabcee01d49c82a500833121dcd848c3954357d9f7b1: CpResource /Users/me/Projects/Clients/MyCompany/repo/mp_vision/iOS/Controller/MyApp /Resources/en.lproj/HelpContent /Users/me/Library/Developer/Xcode/DerivedData/MyApp- fdskkibuvbsubudkmqtgsjxmyqme/Build/Products/Debug-iphoneos/MyApp.app/ HelpContent' and 'b1132708c20f997e752faabcee01d49c82a500833121dcd848c3954357d9f7b1: CpResource /Users/me/Projects/Clients/MyCompany/repo/mp_vision/iOS/Controller/MyApp /Resources/fr.lproj/HelpContent /Users/me/Library/Developer/Xcode/DerivedData/MyApp- fdskkibuvbsubudkmqtgsjxmyqme/Build/Products/Debug-iphoneos/MyApp.app/ HelpContent')The Files &amp; Groups list shows it correctly (e.g. "HelpContent" with "HelpContent (English)" and "HelpContent (French)" as sub-folders. The folders only show up once in the Copy Bundle Resources phase.But the build stops almost immediately on this error.
12
0
18k
Jan ’22
Getting the current queue and thread name?
The Xcode console logs an identifier indicating the current thread that's running when a message is print()ed from Swift. Some more complex logging systems (e.g. swift-log and console-kit) don't provide that information, and I'm trying to write a logging back-end for swift-log that will. Thing is, I don't see any way to get the current queue name in Swift. I tried dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) But I get "cannot convert value of type '()' to expected argument type 'DispatchQueue?'". Passing nil instead results in "'dispatch_queue_get_label' has been replaced by property 'DispatchQueue.label'". This is not an unreasonable thing to want to do, and it poses no safety concerns.
4
0
5.6k
Nov ’22
Ignoring Command-Q in LSUIElement app (macOS, SwiftUI)?
I've got this LSUIElement app (no menu bar/dock icon). It puts up a window in certain circumstances to give the user control, but otherwise just runs in the background. Today I noticed that with its window frontmost, you can type Command-Q and it will quit. Is there a way to suppress that? I have explicit controls for quitting the app, but normally the user wants it to run in the background always, and I don't want it to be so easy to accidentally quit.
2
0
751
Dec ’23
How can I detect if my SwiftUI Window has been closed?
My macOS SwiftUI app has a single Window scene. .onAppear() is called when it is created, but if it is closed, .onDisappear() is not called. How can I detect when the window is closed? Note, I need to distinguish between closed and inactive or background. scenePhase is not updated for the window or any of its subviews when the window is deactivated. controlPhase is, however. Note that my app delegate implements: func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return false }
0
0
908
Dec ’23
Determining if Accessibility (for CGEventTap) access was revoked?
My app depends on the user granting Accessibility access (Allow this application to control your computer). There’s no formal permissions API (that I know of) for this, it just happens implicitly when I use the API for the first time. I get an error if the user hasn’t granted permission. If the user grants permission and I'm able to successfully register my CGEventTap (a modifier key event tap), but then later revokes it, key responsiveness goes awry. I don’t get any kind of error to my callback, but I do get tapDisabledByTimeout events periodically. I believe something is causing significant delays (but not preventing) in delivering events to my tap. Upon receiving this, I'm considering attempting to register another tap as a way to test permission, and disabling the real one if I no longer have permission. Does anyone have any better ideas? For Apple: see FB13533901.
2
0
1.2k
Jan ’24
Xcode commit color meaning?
In the abominable new commit line diff view, I have no idea what the colors mean. Some text is highlighted in a cream color, other text in purple. Googling just turns up people hating the view, as I do. I haven't found anything in the Xcode docs that explains the coloring. Looking at my files, I think cream is a deleted line and purple is added lines. Is that right? Light mode.
1
0
916
Jan ’24
Using a Brew-installed library on visionOS?
I've been working on a Swift PM wrapper for the libtiff library, which I installed on my Mac via Brew. So far so good. But I just tried adding it to my visionOS project. and it complained that it was trying to link against a library built for macOS: building for 'visionOS-simulator', but linking in dylib (/opt/homebrew/Cellar/libtiff/4.6.0/lib/libtiff.6.dylib) built for 'macOS' I wish Brew would build universal libraries, but it doesn’t, and they have no interest in doing so. What are my options? If I build libtiff from sources, it’s still a bit of a pain to build against a different SDK. libtiff has its own Makefile I’d rather not try to edit. Can I make an xcframework out of it? Can I statically link it into my Swit wrapper library? Do I need to hack together a C build target in my Package and copy the source files over to it?
2
0
836
Jul ’24
Any way to get arbitrary TIFF tags from a file?
It seems that there’s still no way to get all TIFF tags from a TIFF image, is that right? I've got these GeoTIFF images that have a handful of specialized TIFF tags in them. Calling CGImageSourceCopyPropertiesAtIndex(), I can see basic properties common to all TIFF images, like dimensions and color/pixel information, but no others. Short of including libtiff, is there another way to get at the metadata? I've tried all of the options in CGImageSourceCopyAuxiliaryDataInfoAtIndex. I've written a few bugs about this since 2020, all ignored.
6
0
976
Jul ’24
Can't get compression_decode_buffer() to work
I've got a Data of deflate (zlib)-compressed data that decompresses properly using NSData.decompressed(), but does not decompress properly using compression_decode_buffer(). The working code looks like this: let compressedData = Data(bytesNoCopy: buf.baseAddress!, count: readCount, deallocator: .none) let dataWithoutHeader = compressedData[2...] let ucData = try (dataWithoutHeader as NSData).decompressed(using: .zlib) as Data The non-working code looks like this: let samples = try [Float](unsafeUninitializedCapacity: sampleCount) { buffer, initializedCount in print("Count: \(initializedCount)") try compressedData.withUnsafeBytes<UInt8> { (inCompressedBytes: UnsafeRawBufferPointer) -> Void in let destBufferSize = buffer.count * MemoryLayout<Float>.size let scratchBuffer = UnsafeMutableRawBufferPointer.allocate(byteCount: compression_decode_scratch_buffer_size(COMPRESSION_ZLIB), alignment: MemoryLayout<Int>.alignment) defer { scratchBuffer.deallocate() } let decompressedSize = compression_decode_buffer(buffer.baseAddress!, destBufferSize, inCompressedBytes.baseAddress!, inCompressedBytes.count, scratchBuffer.baseAddress!, COMPRESSION_ZLIB) print("Actual decompressed size: \(decompressedSize), destBufferSize: \(destBufferSize)") } initializedCount = sampleCount } It ends up printing: Actual decompressed size: 46510, destBufferSize: 1048576 (1048576 is the correct size. What data is returned does not appear to be correct.) I have tried it both with and without the first two bytes of the compressed data buffer, and with and without providing a scratch buffer.
2
0
621
Aug ’24