Delve into the world of built-in app and system services available to developers. Discuss leveraging these services to enhance your app's functionality and user experience.

Post

Replies

Boosts

Views

Activity

Disable Smart Selection feature on PKCanvasView
I've been trying to disable the "Smart Selection" feature introduced in https://developer.apple.com/wwdc20/10107 from a PKCanvasView. This feature could be very useful for some apps but if you want to start from a clean state canvas it might get in your way as you add gestures and interactions. Is there any way to opt out from it? The #WWDC20-10107 video demonstrates the "Smart Selection" feature at around 1:27.
2
2
1.3k
Jun ’23
UnwantedCommunicationReportingExtension API calling failing
I have followed every step to make sure UnwantedCommunicationReportingExtension will work with my app. Let me list here Adding a new target UnwantedCommunicationReportingExtension to my project Adding API endpoint to Info.plist <dict> <key>NSExtension</key> <dict> <key>NSExtensionAttributes</key> <dict> <key>ILClassificationExtensionNetworkReportDestination</key> <string>https://api.mycompany.net/call/v2/main/report</string> </dict> <key>NSExtensionMainStoryboard</key> <string>MainInterface</string> <key>NSExtensionPointIdentifier</key> <string>com.apple.identitylookup.classification-ui</string> </dict> </dict> </plist> Added classificationreport to Associate domain in Capability section. classificationreport:api.mycompany.net Created an apple-app-site-association file without json extension and returned this when api.mycompany.net called. I don't know whether to add app's bundle id or extension's bundle id. So added both. Complete apple-app-site-association below { "classificationreport": { "apps": [ "XXXXXX.com.company.appname.CallReport", "XXXXXX.com.company.appname" ] } } Checked the following website to ensure the file can be accessed. Both are displaying the file https://app-site-association.cdn-apple.com/a/v1/api.mycompany.net https://api.mycompany.net/.well-known/apple-app-site-association But I cannot call API https://api.mycompany.net/call/v2/main/report. It always fails with the following error Can anyone tell me what I'm missing? I tried for a week and was exhausted .
2
0
1k
Jun ’23
NFCTagReaderSession - Missing required entitlement
Hi there, I am using Core NFC and I established the connection with the card, (it means that the info.plist is correct and the entitlement should be correct as well). The app detects the card, but after sending the command 'tag.sendCommand()' I receive this message: [CoreNFC] -[NFCTagReaderSession transceive:tagUpdate:error:]:879 Error Domain=NFCError Code=2 "Missing required entitlement" UserInfo={NSLocalizedDescription=Missing required entitlement} So, what is missing or what am I doing wrong? Here is the code: func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) { guard !tags.isEmpty else { return } let hexString = //... if case let .iso7816(tag) = tags[0] { session.connect(to: tags[0]) { error in if let error = error { print("Error: \(error.localizedDescription)") return } let apdu = hexString.convertToAPDU() tag.sendCommand(apdu: apdu) { (response: Data, sw1: UInt8, sw2: UInt8, error: Error?) in // -> here is when the error appears, in the completion print([UInt8](response)) // print -> [] } } } }
5
1
1.7k
Jun ’23
Using the same widget extension for both iOS and WatchOS
Isn't it possible to use the same widgetkit extension for both iOS and WatchOS? In the WWDC's BackyarBirds project from Apple, I can see the widget extension is added to both the multiplatform (including iOS) and the watch targets. I can also see that the SwiftUI code even uses macros to check which platform the code is running on. However, I'm having several issues with adding the same extension to both targets. When I add it to the watch target, I get a build error that I'm trying to embed an application that also builds for iOS and that is not allowed for the watch app. Not sure if any code here is helpful, but this is my widget UI code: struct AkvaWidget: Widget { private let kind = "Akva Widget" var families: [WidgetFamily] { #if os(iOS) return [.accessoryCircular, .accessoryRectangular, .systemSmall] #elseif os(watchOS) return [.accessoryCircular, .accessoryRectangular, .accessoryInline, .accessoryCorner] #endif } var body: some WidgetConfiguration { StaticConfiguration( kind: kind, provider: AkvaSnapshotTimelineProvider() ) { entry in AkvaWidgetView(entry: entry) } .configurationDisplayName("Akva") .description("Keep track of your water intake.") .supportedFamilies(families) } }
2
1
1.5k
Jun ’23
AppIntentsPackage protocol with SPM package not working
Hi, I am trying to integrate the new AppIntentsPackage protocol into my application. Especially what I want to do is to create a dedicate SPM package which holds all my app intents and then share that with my widget extension for Widget intents as well as the main iOS app for powering an AppShortcutProvider. Unfortunately I run into an issue here. I have the following explanatory setup: SPM package called ProjectAppIntents iOS target My AppIntents SPM package //Package: ProjectAppIntents public struct TestAppIntent: AppIntent { public static var title: LocalizedStringResource = "TestAppIntent" @Parameter(title: "Parameter1", optionsProvider: ParameterOptionProvider()) public var parameter: String public init(parameter: String) { self.parameter = parameter } public init() { } public func perform() async throws -> some IntentResult & ReturnsValue { .result(value: 5) } } struct ParameterOptionProvider: DynamicOptionsProvider { func results() async throws -> [String] { return ["Hello", "World"] } } public struct ProjectAppIntentsPackage: AppIntentsPackage { } My iOS app // Target: iOS import ProjectAppIntents struct ProjectApp: App { var body: some Scene { WindowGroup { ContentView() } } } extension ProjectApp: AppIntentsPackage { static var includedPackages: [AppIntentsPackage.Type] = [ ProjectAppIntentsPackage.self ] } struct ProjectShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: TestAppIntent(), phrases: ["Start a \(.applicationName)"], shortTitle: "Hello World", systemImageName: "house" ) } } When I now try to compile my app, I get the following build error: 2023-06-25 09:53:47.853 appintentsnltrainingprocessor[44848:2059163] Parsing options for appintentsnltrainingprocessor 2023-06-25 09:53:47.854 appintentsnltrainingprocessor[44848:2059163] Starting AppIntents SSU YAML Generation 2023-06-25 09:53:47.868 appintentsnltrainingprocessor[44848:2059163] error: The action TestAppIntent referenced in App Shortcut does not exist Command AppIntentsSSUTraining failed with a nonzero exit code So for me it seems like the compiler cannot find the AppIntent defined in an SPM package. Am I doing something wrong here or does the AppIntentsPackage protocol not work with SPM packages ? Thanks a lot for helping !
13
3
3.6k
Jun ’23
questions about Carplay driving task
Hi, I have a couple of doubts. Can information layout be used for driving task? In the guidelines is stated "The information template can be used by communication, EV charging, parking, navigation, and quick food ordering apps." (hence, driving task is not part of this list) correct? in the Apple guidelines is stated "driving task and quick food ordering apps are limited to 2 templates". Then, it also says that the tab bar layout "allows up to 4 tabs for audio apps and up to 5 tabs for all other app types". What does this mean? Is it possible to use the tab bar layout with more than two levels of hierarchy within the driving task, or should I use it with a limit of two? Moreover, if the limit is two, do I have to also count the tab bar as one and, therefore, use just one other layout in addition as the maximum allowed number? thanks
1
0
964
Jun ’23
Migrating to WidgetKit, issues with editing Watch Faces on iPhone
Anyone who has successfully migrated to using WidgetKit for their Apple Watch complications, your help would be greatly appreciated! I've migrated to WidgetKit for my Watch app. On the Apple Watch Face Editor, the new Widget names and options appear correctly. However, on the iPhone Apple Watch app, it offers both WidgetKit and old ClockKit complications... this should not be. I also have found rendering issues where Watch Faces on the main My Watch tab have blank gaps for WidgetKit complications, when selecting the Watch Face they then render (see photos) I've put in a feedback FB12460375 Have tried a full clear and reinstall of my app on both devices, no change. This issue occurs on WatchOS 9.5.2 / iOS 16.5.1 and WatchOS 10 Beta 2 / iOS 17 Beta 2 Any other ideas?
7
0
1.7k
Jun ’23
ApplicationTokens changing
We persist ApplicationTokens in a storage container that ShieldConfigurationExtension has access to. In rare, cases all the ApplicationTokens for a user seem to change. We know this because the Application parameter passed into configuration(shielding application: Application) -> ShieldConfiguration function has a Token that does not match (using == ) any of the ones we are persisting in storage. Interestingly, the persisted ones still work, so I don't believe storage has gotten corrupted or anything. We can use them to add or remove shields, we can use them to display labels of the apps they represent, etc. But they don’t match what’s passed into the ShieldConfiguration extension. If the user goes into the FamilyPicker at this point and selects an app of a token that we are already persisting, the FamilyPickerSelection will have a token matching the new one that is passed into ShieldConfigurationExtension, not the one we persisted when they last selected that app. This leads me to believe the tokens are updated/rotated in some cases. When and why does this happen, and how can we handle it gracefully?
4
4
1.2k
Jun ’23
Strange behavior and log entries for Mac Catalyst Action
I have a text based action for iPhone and Mac Catalyst I am developing in Xcode 14.3.1 on macOS 13.4.1. I have the container app, an action and an AppGroup defined. I have confirmed that I can read the necessary shared defaults when the action launches. At this point the UI for the action is a simple textview in which I hope to display a modified version of the text passed to the action in the NSExtensionItems. I am not using a simulator. I am running the action directly using Xcode. What is happening is that the ActionViewController viewDidLoad runs but no visible window opens. In the console I see this as the action launches: 2023-07-05 18:27:23.692277-0700 XYZ[4634:279295] [ViewBridge] ViewBridge attempted to look up a hosted window with identifier 8E816BD5-67D3-402D-ADEB-AC59EDFA1F3B, but it was never registered. 2023-07-05 18:27:23.692408-0700 XYZ[4634:279295] [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set. .... The last line above is repeated 12 times.... Any helpful ideas would be deeply appreciated! Steve
1
0
1k
Jul ’23
Individual App Usage using Screen Time API
Hey everyone. My friend and I have an idea of creating an app that allows you to compete against others by seeing who can use certain apps the least. To do this, we need to get the statistics of every app's screen time usage. I looked at doing this through the Screen Time API. However, it isn't very clear to me what app developers can access. Can we access a time breakdown of all apps' screen time usage (similar to the information in the Screen Time Settings screen)? If not, would the best route to manually implement our own tracking system? Thanks!
3
2
1.7k
Jul ’23
Is it possible for EventKit Framework to trigger the Permission Alert of the Contacts?
We use Eventkit Framework to synchronize the meeting calendar to the system calendar, read the System Calendar with -[EKEventStore calendarsForEntityType:], Use - [EKEventStore saveEvent: span: commit: error:] wrote system calendar. This usage currently triggers the Contacts Permission Alert on a user. Through the log, we identified no use - [CNContactStore requestAccessForEntityType: completionHandler:] and Contacts API.
1
0
1.1k
Jul ’23
Why does NSAttributedString's NSItemProviderWriting implementation not transfer custom attributes that implement Codable?
I am working on supporting some formatted text editing in my app, and I've been experimenting with copy and paste support for formatted text. I discovered that NSAttributedString implements NSItemProviderWriting, which means I can give it to UIPasteboard via setObjects and all the built-in attributes transfer perfectly if I then paste it into another text view, or even another app that behaves itself. But if I have custom attributes in my attributed string, having their values implement Codable doesn't let them transfer across the clipboard. In my implementation of textPasteConfigurationSupporting(_: transform:), I try to get an attributed string like this: let attr = item.itemProvider.loadObject(ofClass: NSAttributedString.self) { val, err in //...handle here } I get an error like this: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type com.apple.uikit.attributedstring" UserInfo={NSLocalizedDescription=Cannot load representation of type com.apple.uikit.attributedstring, NSUnderlyingError=0x600003e7bea0 {Error Domain=NSCocoaErrorDomain Code=260 "The file “b036c42113e34c2f9d9af14d6fefcbd534f627d6” couldn’t be opened because there is no such file." UserInfo={NSURL=file:///Users/username/Library/Developer/CoreSimulator/Devices/86E8BDD4-B6AA-4170-B0EB-57C74EC7DDF0/data/Library/Caches/com.apple.Pasteboard/eb77e5f8f043896faf63b5041f0fbd121db984dd/b036c42113e34c2f9d9af14d6fefcbd534f627d6, NSFilePath=/Users/username/Library/Developer/CoreSimulator/Devices/86E8BDD4-B6AA-4170-B0EB-57C74EC7DDF0/data/Library/Caches/com.apple.Pasteboard/eb77e5f8f043896faf63b5041f0fbd121db984dd/b036c42113e34c2f9d9af14d6fefcbd534f627d6, NSUnderlyingError=0x600003e7ac70 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}} But I tried making my custom attribute values implement NSSecureCoding, and then it worked. Why is Codable conformance not enough here? Is it because the code that serializes and deserializes is still in Objective-C and isn't aware of Codable? Will this change as the open-source Foundation in Swift work continues?
1
0
849
Jul ’23
Issues with iOS 16 AppIntents after building app with iOS 17 SDK
I'm running into a couple of breaking issues with AppIntents for which I just submitted feedbacks. I figured I'd post them on the forum too for good measure. FB12701143 - @IntentParameterDependency causing crashes in all AppIntents with Entity Queries on iOS 16 I have a pre-existing AppIntent with its own EntityQuery that works just fine on iOS 16. I've built a totally separate intent only available in iOS 17 that makes use of a new entity and a new query using @IntentParameterDependency, but now the original intent crashes after building and running the app on an iOS 16 device with the latest Xcode beta. The line it crashes on is the initializer of the iOS 17-only EntityQuery, even though 1) it shouldn't be able to see it and 2) that EntityQuery isn't involved in the crashing intent. This breaks significant functionality in my AppIntents, and I'm hoping this is a bug rather than a framework limitation. The feedback includes a sample project, crash log, and sysdiagnose. FB12701491 - iOS 17-only CustomIntentMigratedAppIntent stops SiriKit intent equivalent from working on iOS 16 I have a SiriKit intent in my app that I was not able to convert to an AppIntent until iOS 17 because it makes use of an @IntentParameterDependency. However, even though the new AppIntent version is marked as only available in iOS 17 and above, once I conform it to CustomIntentMigratedAppIntent and provide the old intent’s class name, it stops working on iOS 16 devices with an error that the shortcut is unavailable on that device. The CustomIntentMigratedAppIntent should respect the iOS 17 availability annotation and leave the SiriKit intent alone since its migrated replacement isn’t available on iOS 16. The feedback includes a sample project illustrating the issue.
3
0
1.2k
Jul ’23
Allow specifying regex to match an e-mail address to a contact.
Is your feature request related to a problem? Please describe. Everywhere where Apple offers it, I use Apple's Private Relay e-mail addresses. However, they can't be manually generated, so for the rest, I use https://anonaddy.me. Because it offers infinite aliases, I use a different alias every time I give my e-mail address to someone. However, I ensure that they're all under the @rokejulianlockhart.anonaddy.com (.com and .me are equivalent in this case) domain so that they can be identified as me by a human. I use different aliases to combat spam, not be anonymous. Additionally, when messaging others, I ensure that I add a sub-address with my name to their e-mail address so that they can filter all messages from me (even if I'm using a different alias for my own filtering purposes). Others use the same when communicating with me, especially family. The current identification system doesn't take sub-addresses into account whatsoever. Describe the solution you'd like I should therefore be able to set RY7I0I+RY7I0R@rokejulianlockhart.anonaddy.com as an e-mail address, and beneath it add, for instance [A-Za-z0-9]+\+[A-Za-z0-9]+@rokejulianlockhart\.anonaddy\.com in another input form to ensure that Nextcloud identifies any (in this case sub-addressed) alias as me. Describe alternatives you've considered The sole current alternative is to list literal tens of thousands of aliases as myself, which is insane. It also wouldn't work, because https://anonaddy.me generates a new alias when someone else uses one, so I'd have to retroactively add those whenever someone else uses one. It also wouldn't account for sub-addresses. Additional context Like most more powerful features of Nextcloud, this only need be visible when clicked on. Adding a button beside each e-mail address to show a form which allows the user to enter custom regex is enough. Additionally requested at: https://feedbackportal.microsoft.com/feedback/idea/ed4261f8-af28-ee11-a81c-6045bd8534ad. https://discussions.apple.com/thread/255016441. https://github.com/nextcloud/contacts/issues/3530#issue-1816825315.
2
1
745
Jul ’23
Screen Time API features iOS 15 / iOS 16
My app using Screen Time API to block app and hide app. When I upload to Apple Store. The reviewer rejected it because of "Your app uses public APIs in an unapproved manner, which does not comply with guideline 2.5.1 of the App Store Review Guidelines. Specifically, “hide” apps are referenced for ScreenTime API use. Since there is no accurate way of predicting how an API may be modified and what effects those modifications may have, Apple does not permit unapproved uses of public APIs in App Store apps. Next Steps Please revise your app to ensure that documented APIs are used in the manner prescribed by Apple. If there are no alternatives for providing the functionality your app requires, you can use Feedback Assistant to submit an enhancement request." So, How the app can be available on Apple Store like other apps such as Cloak ? Anybody can help my team to upload app to Apple Store. Thank you !
1
0
743
Jul ’23
App cannot upgrade to http/3 when running on iOS 16
My team are now testing http/3 support in our app and backend. It looks strange to me how the behaviour is different between iOS 15.7.3 and 16.x (now 16.6). It is a default URLSession config and just a regular URLRequest, with no assumesHTTP3Capable flag set. I observe the protocol in use with both collecting URLSessionTaskMetrics and the Network instrument. On 15.7.3 the 1st request is done using h2, the network subsystem caches the Alt-Svc header (per host I suppose). Several seconds pass and then when I issue the same 2nd request a new connection is established and the protocol is upgraded to h3. This is all fine and as described in the documentation or wwdc videos. However, when I take the same steps with a device running e.g. iOS 16.5.1 I see that the protocol is never upgraded to h3. Neither a longer timeout nor an app relaunch make any difference. Interestingly, on my Ventura desktop the same url is also handled differently: h3 by Chrome but always h2 by Safari. In the mobile Safari on iOS 16, I'm also always shown HTTP/2 on e.g. the cloudflare status page for QUIC. What can be the reason for such behaviour on iOS 16 and Apple platforms in general? PS. I've tried running the app with CFNETWORK_DIAGNOSTICS but found no useful log messages to clarify problems with QUIC. Is there still a way to better diagnose such a problem?
3
1
1.6k
Jul ’23
iOS 17 beta/Sonoma HomeKit "stuck" adding accessory
I had an issue a few days ago with a Schlage Encode Plus lock. Apparently, it had tried to update the firmware and encountered an issue. It dropped off the network with "not responding." I factory reset the lock and reset it back up, but when I try to add it to HomeKit, nothing works. It seems the "add accessory" piece of HomeKit is "stuck." The camera will no longer scan the QR code and when I try to add the device manually, I just get a spinning circle and I'm never given the opportunity to add it. I do see some data in console.log regarding HomeKit: cannot add handler to 3 from 3 - dropping There is another error message but it just says so I'm not sure what that could be. This has been reported in Feedback Manager. Any tips on how to clear this apparent logjam?
2
1
845
Aug ’23
How to start a hands-free Nearby Interaction (UWB) session using Bluetooth?
Hello, Our team is working on a mobile app that uses Nearby Interaction framework (UWB technology) to get real-time high-accuracy ranging information with our third-party UWB-enabled device. So far everything works fine, background sessions included as explained in wwdc2022/10008 video. We are using Bluetooth LE to exchange the UWB parameters as recommended by Apple. Our next goal is to go for a full hands-free configuration of the UWB session. Let's think of an access control use case where UWB is used to measure the distance between the user and the door (credentials exchanged via Bluetooth). What we want to achieve is to start the UWB session without requiring the user to take the phone out of his wallet and open the access control app. What it works for us today is if the user starts the app, then switches off the screen and puts the phone into his pocket. The app is still running in background, so the Bluetooth Scan keeps working, the Bluetooth session starts, the UWB parameters exchanged and the UWB session started in the background, all good. But what if the user killed the app or never started it after reboot? How can we force the app to start from killed state when the BLE / UWB third-party accessory comes into proximity? iBeacon seems like a promising approach, but according to the forums, in iOS 16 the app will not be restarted from killed state. Is this correct? Any idea / suggestion about how to let the OS start our app when the user approaches the BLE / UWB accessory and the app is in killed state? Thanks in advance for your time. Regards.
2
0
1.2k
Aug ’23
WidgetKit complications won't update
We are migrating ClockKit complications to WidgetKit in our watch app (watchOS 9+). The migration went smoothly, UI part works just fine. However, we've hit the wall with widgets not updating when requested by the watch app. I believe we are missing something very simple and fundamental, but couldn't find what exactly so far. Advice and tips would be very welcome! 🙇‍♂️ Our implementation details: Whenever data is changed in the main app, the updated data is submitted to the watch app via WatchConnectivity framework using WCSession.default.transferCurrentComplicationUserInfo(_:). According to documentation, this method should be used to transfer complication-related data, since it will wake the watch app even if it is in the background or not opened at all. Watch app receives updated data and stores it in UserDefaults shared with Watch Widget Extension hosting WidgetKit complications via App Group. Watch app then request widget timeline reload via WidgetCenter.shared.reloadAllTimelines(). According to documentation, it reloads the timelines for all configured widgets belonging to the containing app, so it seems the appropriate way to reload WidgetKit complications. Widget Timeline Provider class in Watch Widget Extension reads updated data from shared UserDefaults and uses it to provide the updated snapshot for widget views to render. We believe our implementation logic is correct, but it doesn't work, for some reason. Widgets sometimes update when the watch app is opened, but not always. The most definitive way to force widgets to update is to switch to a different watch face, which confirms that the Widget Timeline Provider has access to properly updated data. P.S. We are aware of the daily reload budget imposed on widgets, so we use widgets reload trigger sparingly. Anyway, according to documentation, reload budget is not effective when in DEBUG mode, but widgets won't reload even in DEBUG mode. Thank you!
18
9
5.4k
Aug ’23
More control of TipKit arrow locations
Hello! Based on the lack of forum posts, I think I'm one of the first people to really be diving into TipKit. :) I'm trying to use a tip to coax users toward a button in the toolbar of a NavigationView. The docs say to put the TipView "close to the content", but the best I can do for the NavigationView toolbar is to put it in one of the views inside the Navigation View itself. I'm using a TipView with an arrowEdge: .top parameter, which results in this: I'd love to be able to move the arrow tip under the plus button. Is that possible in this early beta stage? Do I need to restructure my view hierarchy somehow?
6
2
1.6k
Aug ’23