Post

Replies

Boosts

Views

Activity

/Users/USER/*/python3.8 is crashing
Every now and again, I see that Python 3.8 crashes. Now, I tried to get rid of all Python 3.8 interpreters on my system. But the crash log for this one gives a Path of /Users/USER/*/python3.8. What does that mean? That's not a real path on my filesystem. The crash is due to Python not finding a dylb it needs: Process: python3.8 [2946] Path: /Users/USER/*/python3.8 Identifier: python3.8 Version: ??? Code Type: X86-64 (Translated) Parent Process: launchd [1] User ID: 501 Date/Time: 2024-09-20 17:03:49.4230 -0700 OS Version: macOS 14.6.1 (23G93) Report Version: 12 Anonymous UUID: <redacted> Sleep/Wake UUID: <redacted> Time Awake Since Boot: 520000 seconds Time Since Wake: 43861 seconds System Integrity Protection: enabled Notes: PC register does not match crashing frame (0x0 vs 0x202E45A78) Crashed Thread: 0 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: Namespace DYLD, Code 1 Library missing Library not loaded: /usr/local/opt/gettext/lib/libintl.8.dylib Referenced from: <redacted> /Users/USER/*/python3.8 Reason: tried: '/usr/local/opt/gettext/lib/libintl.8.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/gettext/lib/libintl.8.dylib' (no such file), '/usr/local/opt/gettext/lib/libintl.8.dylib' (no such file), '/usr/local/lib/libintl.8.dylib' (no such file), '/usr/lib/libintl.8.dylib' (no such file, not in dyld cache) (terminated at launch; ignore backtrace) Now, this only happens (I think) when I'm running VS Code, which I normally hate doing, but I’m trying to develop an Autodesk Fusion plug-in in Python, and that’s how it’s done. I don’t know if this Python was installed by Apple, or if I got via one of the dozens of SDKs I've installed over the years. VS Code has a way to search for Python interpreters, and I used that to delete all the old ones I could find. And I'm pretty sure macOS is on a more recent version.
0
0
404
Sep ’24
Printing to a label printer (from macOS)
Bit of a stream of consciousness below. I discovered after writing all that that I needed to switch width & height when setting values, and print landscape. That gets things to print as expected. But I really need to be able to set the Brother's notion of tape width in the Basic Options portion of the print panel. I've got this Brother QL-800 USB label printer that takes spools of either die-cut labels, or continuous paper of a given width. It can cut between labels or the continuous paper at any point. My app is intended to print small labels for small parts drawers. The app has a DB of parts, and I want to print dozens of unique labels of a specific height and width. Ideally, you'd set things up once, and then print one or more specific part labels without further UI interaction. The NSPrintPanel is far too complex, and allows the user to screw things up, so I'd like to forego it altogether. I've written some simple code that does succeed in printing via the NSPrintPanel, but it’s positioning the text ultimately incorrectly. I can't figure out how to properly size a view to print a label. I can get an NSPrintInfo object that knows the label printer is selected (e.g. it shows the right name for NSPrintInfo.printer.name). But it states the paperSize is (612.0, 792.0), which if I assume 72 ppi, comes out to 8.5" x 11", which this paper clearly is not. func printLabel() { Task { let printInfo = NSPrintInfo() let printer = printInfo.printer print("Paper size: \(printInfo.paperSize)") // printInfo.paperSize = CGSize(width: 47 / 25.4 * 72.0, height: 12.0 / 25.4 * 72.0) printInfo.topMargin = 0.0 printInfo.bottomMargin = 0.0 printInfo.leftMargin = 0.0 printInfo.rightMargin = 0.0 printInfo.orientation = .landscape printInfo.isHorizontallyCentered = false printInfo.isVerticallyCentered = false printInfo.scalingFactor = 1.0 let view = NSHostingView(rootView: createLabelPrintView()) view.frame.size = CGSize(width: 25 / 25.4 * 72.0, height: 12.0 / 25.4 * 72.0) let op = NSPrintOperation(view: view, printInfo: printInfo) op.showsPrintPanel = true op.showsProgressPanel = true op.printPanel.options.insert(.showsPaperSize) op.printPanel.options.insert(.showsOrientation) op.run() } } @ViewBuilder func createLabelPrintView() -> some View { VStack(spacing: 0) { Text("Line 1") Text("Line 2") } .padding(0) } If I set the pageSize explicitly (uncommenting the line above), The printer offers a long list of available sizes (although none I've found corresponds to the 0.47"/12 mm x continuous spool). By the way, it never remembers the size I selected, and always reverts to 8.5 x 11, which it will then refuse to print, hanging in Print Center with an error about mismatched page sizes. I don’t know why the available page sizes have multiple sizes that don’t seem to match. E.g. 0.47" In the printer’s “Basic Options,” it shows the notion of a Width that's "not found," if I use a custom size: I don't really understand where those printer options can be found and set. Hmm, maybe I found a clue: I ran an NSPrintPanel by itself and examined the NSPrintInfo afterward: let panel = NSPrintPanel() panel.options.insert(.showsPaperSize) panel.options.insert(.showsOrientation) let result = await panel.beginSheet(using: printInfo, on: NSApplication.shared.windows.first!) print("Result: \(result)") print("Paper size: \(printInfo.paperSize)") print("Settings: \(printInfo.printSettings)") Paper size: (283.44000244140625, 82.08000183105469) Settings: { "AP_D_InputSlot" = ""; BrAutoTapeCut = ON; BrBiDiPrint = ON; BrBrightness = 0; BrContrast = 0; BrCutAtEnd = ON; BrCutLabel = 1; BrHalftonePattern = BrErrorDiffusion; BrMargin = "3.0"; BrMultiColor = BrMultiColorMonochrome; BrRedLevel = 0; BrRemoveBlkSpace = OFF; BrResolution = BrSpeed300x300dpi; BrTapeLength = "69.1"; ColorModel = Gray; Duplex = None; PaperInfoIsSuggested = 0; Resolution = 300x300dpi; "com_apple_print_DialogDismissedBy" = Print; "com_apple_print_DocumentTicket_PMSpoolFormat" = "application/pdf"; "com_apple_print_PDEsUsed" = "Printer Options"; "com_apple_print_PageToPaperMappingMediaName" = 29mm; "com_apple_print_PageToPaperMappingType" = 1; "com_apple_print_PrintSettings_PMCopies" = 1; "com_apple_print_PrintSettings_PMCopyCollate" = 1; "com_apple_print_PrintSettings_PMDestinationType" = 1; "com_apple_print_PrintSettings_PMDuplexing" = 1; "com_apple_print_PrintSettings_PMFirstPage" = 1; "com_apple_print_PrintSettings_PMLastPage" = 2147483647; "com_apple_print_PrintSettings_PMPageRange" = ( 1, 2147483647 ); "com_apple_print_ticket_type" = "com.apple.print.PrintSettingsTicket"; "com_apple_print_totalPages" = 2147483647; } It has added a bunch of Br-prefixed keys that clearly correspond to some of the options in the UI. But I'm not sure if I can set those programmatically and get things to print the way I expect. And I don't see anything for tape width. How do I get an NSPrintPanel to show the preview without an NSPrintOperation? I want to react to any changes the user might make before things go to print.
Topic: UI Frameworks SubTopic: AppKit
0
0
504
Sep ’24
Printing from a SwiftUI app (on macOS)?
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
4
0
756
Sep ’24
Trouble direct-distributing macOS app
I don't know why we’re up to Xcode 16 and this stuff is still so damn difficult. First of all, I don't know why I can't just send a .app I built for my M1 MacBook Pro to my friend who also has an M1 MacBook Pro. But even after going through the quarantine steps, he gets an alert saying the app can't be opened. So I'm trying to do direct distribution of an archive. But that gives me two errors: There is a problem with the request entity You already have a current Developer ID Application Managed (With Kext) certificate or a pending certificate request. No profiles for 'com.latencyzero.VideoBox' were found Xcode couldn't find any Developer ID provisioning profiles matching 'com.latencyzero.VideoBox'. The signing is managed by Xcode. CloudKit access works.
Topic: Code Signing SubTopic: General
1
0
667
Aug ’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
594
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
936
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
818
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
791
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
1k
Jun ’24