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?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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?
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.
In Ivory, there are custom menu items in the ShareLink sheet that pops up.
How can I customize my own ShareLink?
Topic:
UI Frameworks
SubTopic:
SwiftUI
AVKit provides the SwiftUI view VideoPlayer, and allows you to add an interactive overlay. But that overlay is normally placed behind the system-provided playback controls.
Is there any way to suppress those controls, without resorting to wrapping AVPlayerView?
I recently started a new app that supports universal links. I noticed an error in the apple-app-site-association (AASA) file and updated it. I used mode=developer in the applinks configuration, and it works well on Simulator, but for the life of me I can't get my device to load the new file, and the CDN hasn't updated in days.
Any suggestions for how to get it to update, or get iOS to load the file directly? mode=developer is supposed to do this, but it simply won't on device.
I've tried touching the file, and I can see its reported HTTP last modification date and eTag have changed.
I've tried deleting and reinstalling the app; I've tried restarting the phone; I've tried clean builds; I've tried changing the applinks: to something else and reinstalling; I've tried installing via TestFlight.
Has anyone else run into this and found a workaround? Xcode 13b1, 3, and 4 are unable to prepare my device for development after I updated it today to 14.7.1. Xcode 12.5.1 is able to.
After churning for several minutes, it always ends up saying
Failed to prepare device for development.
I've rebooted the device and my Mac a few times each now.
There's at least one other report of this issue:
https://stackoverflow.com/questions/68549513/xcode-doesn-t-support-phone-s-ios-14-7-1
I've got macOS SwiftUI app that displays an image, currently using Image. I need to display information about the pixel under the mouse pointer (its position, color, etc.) in some text fields at the bottom of the window.
I can't find an appropriate event handler to attach to Image. Traditionally I would have used mouseEntered, mouseExited, and mouseMoved. These are available for an NSHostingView, but that's for wrapping native views.
I found onHover(), which takes the place of mouseEntered and mouseExited, but it neither works (the perform method is never called for me), nor does it provide movement and position.
I've got the following code that updates a @Published var messages: OrderedSetMessage property:
swift
public
func
add(messages inMsgs: [IncomingMessage])
{
for msg in inMsgs
{
let msg = Message(fromIncoming: msg, user: user)
self.messages.append(msg)
}
self.messages.sort()
}
In my SwiftUI view, however, .onChanged(self.stream.messages) gets called three times each time a single message is added.
I tried operating on a local copy of self.messages, and then just setting self.messages = local, but that didn't change anything.
Maybe the issue is on the SwftUI side?
In any case, how are published updates to a property coalesced?
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.
I managed to get a macOS 13.3 beta install running in Parallels on my M1 VM, but it was really hard to get my app (built on my 13.2.1 M1 native macOS) installed on it, because so many features are unsupported in the VM (e.g. I can't drop files onto it like I can with other OSes, or on Intel; I can't log in with my Apple ID because Apple doesn't allow that, etc.).
I finally copied it over using File Sharing from the VM, but the virtual OS won't launch it. It throws up a vague alert saying "The application can’t be opened." If I try to launch it from the command line, I get
The application cannot be opened for an unexpected reason, error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x600000f2da10 {Error Domain=NSPOSIXErrorDomain Code=153 "Unknown error: 153" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}
I assume it's some kind of code signing/gatekeeper issue, but I don't really know.
I also tried this using the Apple virtualization framework and sample virtual machine tools (neat that those exist). I'm pretty sure this is exactly what Parallels is using internally, btw. It lacks a LOT.
Is there any way to make running macOS betas in a VM a viable way of testing?
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?
Topic:
App & System Services
SubTopic:
Core OS
Tags:
Authentication Services
Passkeys in iCloud Keychain
How does one print from a SwiftUI app (on macOS)? Is there any SwiftUI or Swift API for this, or do I just use the old AppKit APIs (https://developer.apple.com/documentation/appkit/printing)? What if I wanted to print from iOS?
Topic:
UI Frameworks
SubTopic:
SwiftUI
I'm trying to write a SwiftUI iOS/macOS app that allows users to collaborate, but I keep running into limitations. The latest is that I can't figure out what the UICloudSharingContainer equivalent is on macOS. It doesn't seem like there’s a SwiftUI version of this, so I have to write a lot of platform-specific code to handle it, but it's not clear what the AppKit equivalent is.
Topic:
App & System Services
SubTopic:
iCloud & Data
This was working a few days ago, but it has since stopped and I can't figure out why. I've tried resetting TCC, double-checking my entitlements, restarting, deleting and rebuilding, and nothing works.
My app is a sandboxed macOS SwiftUI LSUIElement app that, when invoked, checks to see if the frontmost process is Terminal, then tries to get the frontmost window’s title.
func
getFrontmostWindowTitle()
throws
-> String?
{
let trusted = AXIsProcessTrusted()
print("getFrontmostWindowTitle AX trusted: \(trusted)")
guard let app = NSWorkspace.shared.frontmostApplication else { return nil }
let appElement = AXUIElementCreateApplication(app.processIdentifier)
var focusedWindow: AnyObject?
let status = AXUIElementCopyAttributeValue(appElement, kAXFocusedWindowAttribute as CFString, &focusedWindow)
guard
status == .success,
let window = focusedWindow
else
{
if status == .cannotComplete
{
throw Errors.needAccessibilityPermission
}
return nil
}
var title: AnyObject?
let titleStatus = AXUIElementCopyAttributeValue(window as! AXUIElement, kAXTitleAttribute as CFString, &title)
guard titleStatus == .success else { return nil }
return title as? String
}
I recently renamed the app, but the Bundle ID has not yet changed. I have com.apple.security.accessibility set to YES in the Entitlements file (although i had to add it manually), and a NSAccessibilityUsageDescription string set in Info.plist.
The first time I ran this, macOS nicely prompted for permission. Now it won't do that, even when I use AXIsProcessTrustedWithOptions() to try to force it.
If I use tccutil to reset accessibility and apple events, it still doesn't prompt. If I drag my app from the build products folder to System Settings, it gets added to the system TCC DB (not the user DB). It shows an auth value of 2 for my app:
% sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "SELECT client,auth_value FROM access WHERE service='kTCCServiceAccessibility' OR service='kTCCServiceAppleEvents';"
com.latencyzero.<redacted>|2
<redactd>
I'm at a loss as to what went wrong. I proved out the concept earlier and it worked, and have since spent a lot of time enhancing and polishing the app, and now things aren't working and I'm starting to worry.