Post

Replies

Boosts

Views

Activity

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
325
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
583
Jul ’24
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 &gt;= '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 &lt; 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
516
Jul ’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
447
Jul ’24
Invalid argument error from tcsetattr when setting speed to anything other than predefined
I'm trying to communicate with an RS-485 device using a USB-to-RS-485 adapter based on a CP21012N. It's capable of speeds up to 3 Mbaud. However, when I call tcsetattr() with speed set to anything other than one of the predefined constants (using cfsetspeed()), I get an "Invalid argument" error back from the call. Googling, I found https://github.com/avrdudes/avrdude/issues/771 Seems like macOS really can't accept baud rates outside the predefined set without resorting to ioctl?
5
0
699
Jun ’24
Changing the title in the toolbar of a SwiftData/UI document app?
I just started a little macOS app using SwiftUI and SwiftData. It seems to insist on placing the name of the file (along with the extension) in the title bar. I would prefer to put the name of the selection there instead (i.e. instead of "Untitled.paper", "New Article").. Along with that, I'd like to control the appearance of "Edited" as well. I have the suspicion that this simply isn't possible.
0
0
402
Mar ’24
Simulating cross-device passkey sign in?
It seems cross-device passkey authentication isn't supported by the Simulator, is that right? I can't tell if it's the simulator not supporting it, or my app/server failing. My app, running in the Simulator, presents a QR code during sign-in flow. I scan that with my phone, and it just spins "connecting…". Can anyone confirm that the Simulator just doesn't support this? What are my options for testing this flow? I guess I need another device not sign in to my AppleID.
1
0
781
Mar ’24
Xcode 15 "Missing package product" error when using local package path instead of url
I've got this SwiftPM project. It has a dependency that I needed to edit, so I forked it on github and checked it out locally. Then I referenced the local repo in the Package.swift file with package(path:) instead of package(url:). This caused it to report Package.swift: error: Missing package product 'WebAuthn' (in target 'App' from project 'server') I had to commit my changes, and re-reference the repo, to get it to see my updates. This problem has been around for some time, but seems to be related to how the path name differs from the built target name (it works fine in another project i have where the package directory and target have the same name). I've submitted FB13677717 about it, but is there a workaround?
0
1
2.2k
Mar ’24
Determining if user has passkey for service already?
I'm working my way through adding passkey support to my app. At app launch, I'd like to test to see if the user has already created a passkey for the service, and if not, immediately present the account creation UI. Is there an API call I can make to see if the user already has a credential? From the examples I’ve found, it seems I should just try to sign in, and I’ll get an error callback if there are no stored credentials. Is that right?
4
0
1.4k
Mar ’24
System logging messages disappear after about 90 seconds
I'm having an issue with logging on my system (Sonoma 14.3.1), in that log messages disappear after 60-90 seconds, despite logging being configured to persist. This seems to happen across all subsystems. The symptoms are: • Watching the log stream in Console.app, messages older than 60-90 seconds disappear, even if no new messages are coming in. • log show --last 2d only returns messages from the last couple of minutes. I've filed FB13616761, but wondered if anyone had any other insights or suggestions. TIA
0
0
581
Feb ’24