I would like for my app to have a menu bar under certain circumstances, but not most of the time. Is this possible?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Is there a way to play a specific rectangular region of interest of a video in an arbitrarily-sized view?
Let's say I have a 1080p video but I'm only interested in a sub-region of the full frame. Is there a way to specify a source rect to be displayed in an arbitrary view (SwiftUI view, ideally), and have it play that in real time, without having to pre-render the cropped region?
Update: I may have found a solution here: img DOT ly/blog/trim-and-crop-video-in-swift/ (Apple won't allow that URL for some dumb reason)
I spent some time cleaning up my TCC data. During that I learned that some TCC info is cached in “Mac OS X Detached Code Signature” files. Is there a way to dump their contents suitable for human consumption? The codesign tool doesn’t seem to do it (or I can’t figure out how to invoke it).
I’ve got some code that creates an AVPlayerItem from a URL, the creates an AVQueuePlayer from it. If I check the player item's status after that, it's still unknown.
According to the docs, it'll remain unknown until it is associated with an AVPlayer, and then it "immediately begins enqueuing the item’s media and preparing it for playback." But checking the status right after that, I still get unknown, which tells me it’s not quite immediate.
Is there any way to test if the player item will work immediately after creation? In this case, the problem is that my app doesn't have permission, due to it being a bookmark saved in a sandboxed app.
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
}
I've filed FB13497581 on this topic. But Ever since macOS 14 (or perhaps one of the releases that came after), my machine (M1 MacBook Pro) frequently locks up the UI. Sometimes it's so bad the mouse won't move. It only lasts a few seconds, but at its worst it happens every few seconds. It usually manifests as no text appearing as I type (which sucks, since I write code all day).
I'm fairly certain configd is to blame. When this occurs, configd is using nearly 100% CPU, and spams logs with thousands of messages per second.
Killing it does nothing. Rebooting might fix it for a bit, but it eventually comes back.
I'm wondering if there’s some on-disk state I can blow away to start SystemConfiguration from scratch. I hate to do that in case someone from Apple asks me for files to analyze, but I feel like my FB is just going to languish. Meanwhile, this is rendering my machine unusable.
Or if anyone knows how to interpret the log messages.
I wrote a StoreKit unit test and set the renewal rate to .oneRenewalEveryTwoSeconds for the test session. But now my App expires and renews every two seconds when running normally, even though the StoreKit Configuration file is set to "Real Time." Changing it to anything else doesn't change the renewal rate. I've tried cleaning the build folder.
If, however, I set my SKTestSession explicitly to .realTime and run the test again, then my app behaves. However, again, it doesn't matter what I set the Configuration Settings to.
Anyone know where this information is stored?
Because I can't find a way to share StoreKit purchases between two apps (macOS), I was forced to make my LSUIElement application a single app. This is turning out to work reasonably well, except for one issue that I hadn't noticed before (maybe it's new in 14.2?).
The normal flow is this:
User double-clicks app icon
App calls SMAppService.agent(plistName: "com.myagent.plist").register(). The referenced plist points to the same application binary (see attached project) that the user launched in step 1.
System launches a second instance of the application binary
What I want the call to do instead is see that the app is already running, and just adopt it (that is, if it is killed or crashes, relaunch it).
I see two inelegant workarounds:
Wait until the user is done configuring the app after first launch, register the app and then quit. Thing is, I can't be sure when they're done, e.g. if they don't close the window.
Allow both instances of the app to run, but quit if they close the window and it wasn't launched by launchd, or if there are other instances running. This feels fragile (e.g. if the behavior of register() is ever improved as I'd like).
The best solution, of course, would be to share StoreKit context between apps, so I could separate this into the UI app and background agent.
(To Apple: I've filed FB13574819 with my project attached.)
How do I respond to a SpatialTapGesture in my RealityView when the tap is on no entity whatsoever? I tried just doing
RealityView {}
.gesture(SpatialTapGesture().onEnded { print("foo") })
but that doesn't get called.
All I can find searching is advice to add Collision and Input components to entities, but I don't want this on an entity; I want it when the user is not looking at any specific entity.
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
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?
I would very much like to store some additional data in my SwiftData document package, outside of SwiftData. Metadata about the document that doesn't lend itself well to the underlying RDBMS nature of SwiftData. Is that possible?
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.
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
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.
Topic:
Developer Tools & Services
SubTopic:
General