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?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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
There are a couple of questions in here.
I want to do a basic master-detail split view, as so many SwiftUI apps do. But I want to let the user select an arbitrary subset of items in the list, select them all, and delete them (or do other operations).
Select All, by default, is excruciatingly slow. I have a List view with a selection binding to a Set<PersistentIdentifier>. A ForEach inside renders the items from a SwiftData @Query. I have a couple hundred items, each with a String and Date property. The list item renders the String and nothing else.
I click on an item, hit Command-A, and the app locks up for several seconds while it messes with the selection. It never highlights all the items, but sometimes highlights one (usually different from the one I clicked on).I have an .onChange(of: self.selection) in there to debug the selection. It is called many, many times (2-3 times per second, very slowly), and print the selection count, which starts at 135, and goes down by one, to about 103. If I scroll the list, the selection onChange gets called a bunch more times. Sometimes you see the selection highlights change.
My SwiftUI view hierarchy looks like this:
NavigationSplitView
OrdersList
struct
OrdersList : View
{
var
body: some View
{
List(selection: self.$selection)
{
ForEach(self.orders)
{ order in
NavigationLink
{
Text("Order ID: \(order.vendorOrderID ?? "<none>")")
}
label:
{
Text("Order ID: \(order.vendorOrderID ?? "<none>")")
}
}
.onDelete(perform: self.deleteOrders)
.onChange(of: self.selection)
{
print("Selection changed: \(self.selection.count)")
}
}
}
func
deleteOrders(offsets: IndexSet)
{
withAnimation
{
for index in offsets
{
self.modelContext.delete(self.orders[index])
}
}
}
@State var selection = Set<PersistentIdentifier>()
@Query var orders : [Order]
@Environment(\.modelContext) var modelContext
}
If I use the mouse to select a single item, it behaves as expected. The item is selected, the onChange gets called, and if I choose Edit->Delete, the onDelete handler is called.
If I use the mouse to shift-select multiple items, the behavior is similar to Select All above, but the selection Set count starts at the number of items I selected, and then is slowly whittled down to 0 or 1, with some random item being selected.
I’d like for the Edit->Delete command to work with a keystroke (delete). How can I set the shortcut on an existing menu item without having to reimplement its behavior?
Topic:
UI Frameworks
SubTopic:
SwiftUI
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?
I'm working on a little light and sound controller in Swift, driving DMX lights and audio.
For the audio portion, I need to play a bunch of looping sounds (long-duration MP3s), and occasionally play sound effects (short-duration sounds, varying formats). I want all of this mixed into selected channels on specific devices. That is, I might have one audio stream going to the left channel, and a completely different one going to the right channel.
What's the right API to do this from Swift? Core Audio? AVPlayer stuff?
Topic:
Media Technologies
SubTopic:
Audio
For years (since I got my M1 MacBook Pro) I've experienced this weird performance degradation. I've tried posting about it to numerous channels, always without a reply. I figured I'd try here.
The symptom is: video playback (of visual frames, not audio; audio is unaffected) stutters if I just let the player play. I'll start a video playing, it will play normally, but if I leave the computer alone to play back, the frame rate will drop dramatically (one or two frames per second, even slower). If I wiggle the mouse (generating events), playback resumes normally. After a few seconds, it will stutter again.
It's as if the computer were throttling back on system clocks or something because there’s no user input.
As you can imagine, this is a frustrating user experience when trying to watch videos.
It doesn't matter if it's a YouTube video playing in Safari, or a WWDC video playing in the WWDC.app or Developer.app, or any other video in QuickTime Player.app.
And it doesn't always happen. I have my own video playback app that doesn't seem to suffer from this, even though it plays multiple videos simultaneously.
I'm on power adapter, and settings are generally set to maximum performance when on power adapter.
Any ideas?
Topic:
Community
SubTopic:
Apple Developers
When you share records, they get put into a new zone. Creating a zone for the share makes sense to me, but I thought I read that there was a limit to the number of zones one could have (something like 1024). Does this mean a user can’t share more than 1024 separate items with 1024 different people? I assume any other items shared with the same group end up in an existing zone.
Topic:
App & System Services
SubTopic:
iCloud & Data
My app plays videos. At first I used SwiftUI’s VideoPlayer, but that didn't give me enough control over the underlying AVPlayerView, so I created my own NSViewRepresentable. That works well, and I can adjust the AVPlayerView as I see fit.
But it seems to have a contextual menu that still appears instead of the one I try to apply using SwiftUI. If I put a non-opaque color over the AVPlayerView in a ZStack, I'm able to then add a .contextMenu that works, but only if the color is non-opaque (e.g. Color(red: 0, green: 0, blue: 0, opacity: 0.00001)). This feels like a pretty hacky solution, and doesn’t work if I set opacity: to 0.
Is there a better way to keep AVPlayerView from handling events? It also gets scroll events (which scrubs through the movie) that I'd like to suppress.
Topic:
UI Frameworks
SubTopic:
SwiftUI