Post

Replies

Boosts

Views

Activity

NSSharingService with email for 3rd-party apps
I have a couple of questions about NSSharingService, specifically with NSSharingServiceNameComposeEmail:1) I use [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeMessage], then set the correct parameters and call `performWithItems` on it. This works fine if the Mail app is configured to be the "Default email reader" in Mail.app's Preferences. If I change this to some of the other email clients I have, this doesn't work anymore. I have tried MS Outlook, Airmail and Unibox apps, and this doesn't work in any of them. Is this intentional? Does the sharing service with NSSharingServiceNameComposeMessage only work for Mail.app?2) If that isn't the case, and other apps can be responsible for composing emails as well, what does an app have to do to handle this? If I want to set myself as an email client app, and let others call ComposeMessage, what API should I implement? If anyone has an idea on how to do this, would really appreciate the help.Thanks.
Topic: UI Frameworks SubTopic: AppKit Tags:
3
1
2.3k
Feb ’23
Why do we need receipt validation for IAP?
Hi,I'm starting to work on adding a auto-renewable subscription in my app to unlock certain features. I understand the StoreKit and iTC details, but one thing that's not clear to me is *why* we need to do receipt validation for in-app purchases? There seems to be a lot of empasis on doing this, and it gets complicated because you need to either import different libraries to do this client-side (which isn't the recommended option) or do it server-side, which adds a lot of overhead. In my case, I don't have any server running at all, and my whole app relies on CloudKit instead. So I'm wondering why it's so essential in case of IAP. a) if it's for preventing piracy, shouldn't that apply to paid-apps as well? But no one talks about reciept validation for paid-up-front apps.b) when StoreKit's paymentQueue "updatedTransactions" delegate tells us that someone has purchased an IAP, is that something that can be spoofed? I would imagine not, and even so, this would only be possible with jailbroken devices. Is that what people are worried about? How much of a problem is this in the real world? c) is there certain information in the reciept that is essential for subscriptions to work correctly? In my mind, the simplest implementation would be this: display the IAP products, implement the storekit delegate to see when the user purchased the product and mark that user's CloudKit "User" record with the type and date of subscription (this can also be used to restore the IAP on another device) and unlock the features. When the next billing cycle comes, I can wait for StoreKit to tell me whether the user cancelled or continued the subscription, and lock/unlock the feature accordingly. I don't see the necessity of receipt validation in this case. But I might be wrong and misguided about my assumptions. Would love some comments about this.
15
2
12k
Jun ’21
SwiftUI: memory spike when keyboard is presented
I am working with a UIKit app, which has an MKMapView in it, which displays a bunch of MKAnnotationViews. For each annotation view, I'm using a SwiftUI view to draw the detailAccessoryView. This works, but whenever a keyboard is presented (even if it's in another view controller), I see a major memory spike in the app. For e.g., it goes from using 130MB to 600MB+ on an iPhone8 (the exact values don't matter of course). This explains a crash that seems to be happening with the same app in production as well, which I reported in this DevForums Thread From what I can tell, whenever a keyboard is shown, the SwiftUI views seem go repeatedly resize or re-layout themselves, maybe trying to reconfigure their internal layout or something. If I reduce the number of views in my SwiftUI view, it reduces the memory spike; if I remove the SwiftUI view and just use a plain UIView, the spike completely disappears. My question is: how can I get the SwiftUI views to ignore what's happening with the keyboard in some other view? I've read in some other threads that there is a 'keyboard avoidance' issue with iOS14 and above ... though in my SwiftUI view, there isn't any text field in it's own views. I've tried adding the modifier to the top-level SwiftUI view: .ignoresSafeArea(.keyboard) But it doesn't make a difference Can anyone shed some light on this? Is there another way to avoid keyboard changes in a SwiftUI view?
3
1
1.1k
Oct ’21
Using containerBackground with iOS16 deployment
Hi, I need to keep supporting iOS16 for my widgets. I'm having a problem using the iOS17 'containerBackground' API. Ideally I would use a view extension: extension View { func adoptableWidgetBackground(_ color: Color) -> some View { if #available(iOS 17.0, *) { containerBackground(for: .widget) { color } } else { background(color) } } } But this gives an error: Branches have mismatching types 'some View' (result of 'Self.containerBackground(for:alignment:content:)') and 'some View' (result of 'Self.background(_:alignment:)') If I try to use this directly on the 'body' view modifier like this: if #available(iOS 17.0, *) { .containerBackground(for: .widget) { ContainerRelativeShape().fill(Color.init(UIColor.quaternarySystemFill)) } } else { .background(ContainerRelativeShape().fill(Color.init(UIColor.quaternarySystemFill))) } This doesn't work either. Instance member 'containerBackground' cannot be used on type 'View' How do I use this correctly?
3
1
6.7k
Oct ’23
New warning when updating app in macOS Sonoma
Hi, I am testing out an update for my app in macOS Sonoma. I first installed the App Store version of my app on the device running macOS Sonoma, and it ran fine. I then installed an updated version of my app through TestFlight (built with macOS Ventura SDK), but when I run this updated version, I get prompted ”MyApp differs from previously opened versions. Are you sure you want to open it?". Why is this happening? Is this warning only because the app is updated through TestFlight, or do I need to do something to prevent this warning from happening when I update my app through the App Store? I see this mentioned in an Apple security update:: App Sandbox now associates your macOS app with its sandbox container using its code signature. The operating system asks the person using your app to grant permission if it tries to access a sandbox container associated with a different app. For more information, see Accessing files from the macOS App Sandbox. My app is already sandboxed, and I'm not trying to access a different app's sandbox container, just my own. For the TestFlight build, it probably also uses the same Release configuration that the App Store build uses. I might have changed my provisioning profiles recently because they expired. Would that affect this and cause a prompt to be showed? Would love to know more about this prompt and how to avoid it. Thanks.
3
0
4.4k
Mar ’24
EntityPropertyQuery with property from related entity
Hi, I am working on creating a EntityPropertyQuery for my App entity. I want the user to be able to use Shortcuts to search by a property in a related entity, but I'm struggling with how the syntax for that looks. I know the documentation for 'EntityPropertyQuery' suggests that this should be possible with a different initializer for the 'QueryProperty' that takes in a 'entityProvider' but I can't figure out how it works. For e.g. my CJPersonAppEntity has 'emails', which is of type CJEmailAppEntity, which has a property 'emailAddress'. I want the user to be able to find the 'person' by looking up an email address. When I try to provide this as a Property to filter by, inside CJPersonAppEntityQuery, but I get a syntax error: static var properties = QueryProperties { Property(\CJPersonEmailAppEntity.$emailAddress, entityProvider: { person in person.emails // error }) { EqualToComparator { NSPredicate(format: "emailAddress == %@", $0) } ContainsComparator { NSPredicate(format: "emailAddress CONTAINS %@", $0) } } } The error says "Cannot convert value of type '[CJPersonEmailAppEntity]' to closure result type 'CJPersonEmailAppEntity'" So it's not expecting an array, but an individual email item. But how do I provide that without running the predicate query that's specified in the closure? So I tried something like this , just returning something without worrying about correctness: Property(\CJPersonEmailAppEntity.$emailAddress, entityProvider: { person in person.emails.first ?? CJPersonEmailAppEntity() // satisfy compiler }) { EqualToComparator { NSPredicate(format: "emailAddress == %@", $0) } ContainsComparator { NSPredicate(format: "emailAddress CONTAINS %@", $0) } } and it built the app, but failed on another the step 'Extracting app intents metadata': error: Entity CJPersonAppEntity does not contain a property named emailAddress. Ensure that the property is wrapped with an @Property property wrapper So I'm not sure what the correct syntax for handling this case is, and I can't find any other examples of how it's done. Would love some feedback for this.
3
0
1.1k
Aug ’24
SwiftUI 'List' performance issue on macOS
Hi, When using SwiftUI ‘List’ with a large number of elements (4000+), I noticed a significant performance issue if extracting the views inside the ‘ForEach’ block into their own subview class. It affects scrolling performance, and using the scroll handle in the scrollbar causes stutters and beachballs. This seems to happen on macOS only ... the same project works fine on iOS. Here's an example of what I mean: List (selection: $multiSelectedContacts) { ForEach(items) { item in // 1. this subview is the problem ... replace it with the contents of the subview, and it works fine PlainContentItemView(item: item) // 2. Uncomment this part for it to work fine (and comment out PlainContentItemView above) /*HStack { if let timestamp = item.timestamp, let itemNumber = item.itemNumber { Text("\(itemNumber) - \(timestamp, formatter: itemFormatter)") } }*/ } } struct PlainContentItemView: View { let item: Item var body: some View { HStack { if let timestamp = item.timestamp, let itemNumber = item.itemNumber { Text("\(itemNumber) - \(timestamp, formatter: itemFormatter)") } } } } Item is a NSManagedObject subclass, and conforms to Identifiable by using the objectID string value. With this, scrolling up and down using the scrolling handle, causes stuttering scrolling and can beachball on my machine (MacBook Pro M1). If I comment out the ‘PlainContentItemView’ and just use the HStack directly (which is what was extracted to ‘PlainContentItemView’), the performance noticeably improves, and I can scroll up and down smoothly. Is this just a bug with SwiftUI, and/or can I do something to improve this?
3
0
679
Mar ’25
SwiftUI: Major unannounced change in iOS18.4 beta1
Hi, I have noticed a major change to a SwiftUI API behavior in iOS18.4beta1 which breaks my app's functionality, and I've started hearing from users running the new beta that the app doesn't correctly work for them anymore. The problem is with views that contain a List with multiple-selection, and the contextMenu API applied with the ‘primaryAction’ callback that is triggered when the user taps on a row. Previously, if the user tapped on a row, this callback was triggered with the 'selectedItems' showing the tapped item. With iOS18.4beta, the same callback is triggered with ‘selectedItems’ being empty. I have the code to demonstrate the problem: struct ListSelectionTestView: View { @State private var items: [TimedItem] = [ TimedItem(number: 1, timestamp: "2024-11-20 10:00"), TimedItem(number: 2, timestamp: "2024-11-20 11:00"), TimedItem(number: 3, timestamp: "2024-11-20 12:00") ] @State var selectedItems = Set<TimedItem.ID>() var body: some View { NavigationStack { List(selection: $selectedItems) { ForEach(items) { item in Text("Item \(item.number) - \(item.timestamp)") } } .contextMenu(forSelectionType: TimedItem.ID.self, menu: {_ in Button(action: { print("button called - count = \(selectedItems.count)") }) { Label("Add Item", systemImage: "square.and.pencil") } }, primaryAction: {_ in print("primaryAction called - count = \(selectedItems.count)") }) } } } struct TimedItem: Identifiable { let id = UUID() let number: Int let timestamp: String } #Preview { ListSelectionTestView() } Running the same code on iOS18.2, and tapping on a row will print this to the console: primaryAction called - count = 1 Running the same code on iOS18.4 beta1, and tapping on a row will print this to the console: primaryAction called - count = 0 So users who were previously selecting an item from the row, and then seeing expected behavior with the selected item, will now suddenly tap on a row and see nothing. My app's functionality relies on the user selecting an item from a list to see another detailed view with the selected item's contents, and it doesn't work anymore. This is a major regression issue. Please confirm and let me know. I have filed a feedback: FB16593120
3
0
443
Feb ’25
Exceptions thrown with NSTextView and spell checker
I use NSTextView in my app, and I am getting a LOT of crashes when I’m running the app with the debugger attached, and it all points to this spell checker in NSTextView. The crash happens as soon as the textview shows the ‘word completion’ option. If I turn off the “Continuous Spell Checking” option, it works fine, and it doesn’t crash. The exception reason given is: __NSCFString * "NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds" This is what the stack trace looks like in Xcode: Thread 1 Queue : com.apple.main-thread (serial) #0 0x000000018335eb38 in objc_exception_throw () #1 0x0000000184e01910 in -[NSRLEArray objectAtIndex:effectiveRange:] () #2 0x0000000184e519a8 in -[NSMutableAttributedString addAttribute:value:range:] () #3 0x000000018818086c in -[NSText(NSTextAccessibilityPrivate) accessibilityAXAttributedStringForCharacterRange:parent:] () #4 0x0000000187f576b0 in -[NSAccessibilityAttributeAccessorInfo getParameterizedAttributeValue:forObject:withParameter:] () #5 0x0000000187f591a8 in ___NSAccessibilityEntryPointValueForAttributeWithParameter_block_invoke.799 () #6 0x0000000187f5458c in NSAccessibilityPerformEntryPointObject () #7 0x0000000187f56190 in NSAccessibilityEntryPointValueForAttributeWithParameter () #8 0x0000000187cb6a3c in CopyParameterizedAttributeValue () #9 0x00000002327057ac in ___lldb_unnamed_symbol4511 () #10 0x0000000232705854 in ___lldb_unnamed_symbol4512 () #11 0x000000018a5b3670 in _AXXMIGCopyParameterizedAttributeValue () #12 0x000000018a5d4894 in _XCopyParameterizedAttributeValue () #13 0x000000018a592ff8 in mshMIGPerform () #14 0x000000018382a250 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ () #15 0x000000018382a178 in __CFRunLoopDoSource1 () #16 0x0000000183828b78 in __CFRunLoopRun () #17 0x0000000183827c58 in CFRunLoopRunSpecific () #18 0x000000018f2bc27c in RunCurrentEventLoopInMode () #19 0x000000018f2bf4e8 in ReceiveNextEventCommon () #20 0x000000018f44a484 in _BlockUntilNextEventMatchingListInModeWithFilter () #21 0x000000018774fab4 in _DPSNextEvent () #22 0x00000001880ee5b0 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] () #23 0x00000001884b836c in -[NSCorrectionPanel _interceptEvents] () #24 0x00000001884b8f30 in -[NSCorrectionPanel showPanelAtRect:inView:primaryString:alternativeStrings:forType:completionHandler:] () #25 0x00000001880c91ec in -[NSSpellChecker showCorrectionIndicatorOfType:range:primaryString:alternativeStrings:forStringInRect:view:completionHandler:] () #26 0x00000001880ca0c0 in -[NSSpellChecker _showInlinePredictionForReplacingRange:markedRange:string:withString:view:client:lastReplacementRange:completeWordIndexes:resultDictionary:completionHandler:] () #27 0x00000001880cb26c in -[NSSpellChecker showCompletionForCandidate:selectedRange:offset:inString:rect:view:client:completionHandler:] () #28 0x0000000188303a94 in -[NSTextCheckingController handleCompletionFromCandidates:forSelectedRange:offset:inAnnotatedString:rect:view:] () #29 0x00000001882f9054 in -[NSTextCheckingController viewForRange:completionHandler:] () #30 0x00000001883041c8 in __60-[NSTextCheckingController handleCandidates:sequenceNumber:]_block_invoke () #31 0x000000018789105c in -[NSTextCheckingController annotatedSubstringForProposedRange:wrap:completionHandler:failureHandler:] () #32 0x0000000187890da4 in -[NSTextCheckingController annotatedSubstringForProposedRange:completionHandler:] () #33 0x00000001878927d4 in -[NSTextCheckingController annotatedSubstringForSelectedRangeWithCompletionHandler:] () #34 0x0000000188304134 in -[NSTextCheckingController handleCandidates:sequenceNumber:] () #35 0x00000001883067e0 in ___NSRunLoopTimerCreateWithHandler_block_invoke () #36 0x0000000183842e14 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ () #37 0x0000000183842ad4 in __CFRunLoopDoTimer () #38 0x0000000183842610 in __CFRunLoopDoTimers () #39 0x0000000183828a18 in __CFRunLoopRun () #40 0x0000000183827c58 in CFRunLoopRunSpecific () #41 0x000000018f2bc27c in RunCurrentEventLoopInMode () #42 0x000000018f2bf4e8 in ReceiveNextEventCommon () #43 0x000000018f44a484 in _BlockUntilNextEventMatchingListInModeWithFilter () #44 0x000000018774fab4 in _DPSNextEvent () #45 0x00000001880ee5b0 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] () #46 0x0000000187742c64 in -[NSApplication run] () #47 0x000000018771935c in NSApplicationMain () If I run the debug version of the app without the debugger, it works fine as well. In fact, if I run the app without "All Objective-C Exceptions" breakpoint, it also works fine. So it seems like some framework issue, which is making it hard to run and test my app. What’s the reason for this, and is this an issue I should be worried about for when the app is available to my users?
Topic: UI Frameworks SubTopic: AppKit Tags:
3
0
74
Jun ’25
iPadOS: remove system actions from Menu Bar
Hi, I am setting up the iPadOS26 Menu Bar, and it comes with some existing menu items that don't make sense for my app. For example, under "File" menu, there are options for New Window, Duplicate, Move, Rename and Export that I would like to remove (which keeping the Close Window option). What's the best way to do this?
Topic: UI Frameworks SubTopic: UIKit
3
0
173
Sep ’25
CloudKit subscriptions for public databases
I'm deliberating on whether to use CloudKit for an app that requires sharing data amongst self-created groups of users (for e.g. sharing company-wide directories). I would use a public database for this, but I had a couple of questions:- if I create a subscription to listen to record changes for a partcular record type, will all the users get a notification when data changes, or only the logged-in iCloud user amongst his/her multiple devices? can there by 'group' notifications that cross iCloud users?- if there's no way for a 'group' of users to get notifications, I guess polling from the app to CloudKit would work, with the groupID part of the predicate? Or is there another options?Thanks.
8
0
3.9k
May ’21
CNContact identifiers
Hi,I saw the WWDC talk on the new Contacts framework, and I had a couple of questions about the identifier property:When users upgrade from iOS8 to iOS9, will their old AddressBook recordIDs still work if we are using the AddressBook framework in the app (i.e. haven't upgraded to using Contacts framework)?Are the new CNContact identifiers consistent across iOS and Mac devices? i.e. if we have the identifier on one device, we can lookup the contact on another device with the same identifier?Can these identifiers change in the lifetime of that contact? This was a problem with AddressBook recordIDs ... if you removed the account and then synced it back again, all the contacts would get a different identifier. Same with restoring the device. Will the CNGroup and CNContainer identifiers also be consistent across devices?Hope someone in the Apple Contacts frameworks team can answer. Thanks.
6
0
4.6k
Jul ’23
Xcode Build Timing summary not visible
HiI'm trying to use Xcode's "Build With Timing Summary" feature. It kicks off a build, and I can see the new build in the Build Reports navigator, but when I look through All Messages in the build results, there is "Timing Summary" information. It just says "Build Success - &lt;date&gt; - 75 seconds", but there isn't a breakdown of the timing results.My target builds an iOS app with many extensions, so I can't post the whole logs here. But is there any reason why I can't find the timing results? I do have that older Xcode flag 'ShowBuildOperationDuration' which still works, but only gives the same overall build summary time, not a breakdown.
2
2
3.8k
Mar ’23
Volume purchasing with In-app purchases
Hi, My app is free-to-download but with an in-app purchase to unlock all the features. A user wants to buy 15 copies of the "unlock" IAP and distribute it to his team, using MDM to distribute it easily. I don't believe there is a way to do this through business purchases, is that right? You can only download apps through MDM but not in-app purchases. So what's the best way to do this? Are there any standard solutions? Can I upload a new version of the app that's "paid up-front" but not available through the regular App Store, but only through MDM?
2
0
4.9k
May ’22