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.

Posts under General subtopic

Post

Replies

Boosts

Views

Activity

The enterprise app crashes.
I created a new project, packaged it with my own enterprise certificate, installed and used it. There were no problems on most devices. However, on some devices with system versions of 18.3 and 18.4, the app crashes when opened after trusting the certificate. It seems that there is something wrong with the certificate, but I have confirmed that the certificate is fine. May I ask what the cause of this issue is?
3
1
62
May ’25
WeatherKit request fail
Hello, I have an app on the App Store built around WeatherKit and it was working fine, up until this morning when I started seeing errors when using the app. When debugging using Xcode I see the familiar error Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)" which, according to what I've read on the forums looks like an authentication error. Attaching a network debugger to the Simulator, I saw this error: This I have tried: Verify that WeatherKit is enabled on both Capabilities and App Services tabs on the Dev Portal. Toggle on/off this value and regenerate Provisioning Profiles Uninstall/reinstall Checking that I have API available calls. Nothing. If I create a new Bundle ID and sign with that, it works correctly. But this is not an option since that will force all my customers to download everything from scratch. I am getting emails from customers demanding money back and I can't figure out what has happened. The only thing I can think of, is that I started developing an Apple Watch app to complement the iOS app, but that was last week and everything was working fine.
6
1
558
Jan ’25
Running a Child Process with Standard Input and Output
IMPORTANT Rather than use the code below, I recommend that you adopt Swift’s shiny-new Subprocess package. That’s what I’m doing! (-: Running a child process using Process (or NSTask in Objective-C) is easy, but piping data to and from the child’s stdin and stdout is surprisingly tricky. I regularly see folks confused by this. Moreover, it’s easy to come up with a solution that works most of the time, but suffers from weird problems that only show up in the field [1]. I recently had a couple of DTS incidents from folks struggling with this, so I sat down and worked through the details. Pasted below is the results of that effort, namely, a single function that will start a child process, pass it some data on stdin, read the data from the child’s stdout, and call a completion handler when everything is done. There are some things to note here, some obvious, some not so much: I’ve included Swift and Objective-C versions of the code. Both versions work the same way. The Swift version has all the comments. If you decide to base your code on the Objective-C version, copy the comments from there. I didn’t bother collecting stderr. That’s not necessary in many cases and, if you need it, it’s not hard to extend the code to handle that case. I use Dispatch I/O rather than FileHandle to manage the I/O channels. Dispatch I/O is well suited to this task. In contrast, FileHandle has numerous problems working with pipes. For the details, see Whither FileHandle?. This single function is way longer than I’d normally tolerate. This is partly due to the extensive comments and party due to my desire to maintain focus. When wrapping Process it’s very easy to run afoul of architecture astronaut-ism. Indeed, I have a much more full-featured Process wrapper sitting on my hard disk, but that’s going to stay there in favour of this approach (-: Handling a child process correctly involves some gnarly race conditions. The code has extensive comments explaining how I deal with those. If you have any questions or comments about this, put them in a new thread. Make sure to tag that thread with Foundation and Inter-process communication so that I see it. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" [1] Indeed, this post shows that I’ve made this sort of mistake myself )-:
2
0
7.7k
Apr ’25
Universal links: Open in "MyApp" doesn't launch my app
I've a strange problem which is only occurring on 2 client devices. We have enabled Universal links, and have it fully tested and working. On one client device, the link never opens our app; but here's the strange thing: If I long-press on our link (in Messages), it gives a preview (as expected), and the context menu offers "Open in ", as well as "Open in Safari". Tapping on "Open in " does nothing. I've tried the following: Checked I could access the site-association file over https with no redirects Enabled developer mode and used universal link debug feature: pasted the same link - Developer mode says it will open the app. I've carried out the sysdiagnose; And there are entries in there for our app in swcutil_show.txt. Snipped below: Service: applinks App ID: <my fully qualified app bundle id> App Version: 760.0 App PI: <LSPersistentIdentifier 0x6b8008930> { v = 0, t = 0x8, u = 0x45c, db = DC8D18A2-430D-4AD4-A5BE-B7A003CF9A6F, {length = 8, bytes = 0x5c04000000000000} } Domain: www.<mydomain>.com Patterns: {"/":"/cc/*"}, {"?":{"t":"*"},"/":"/md/"} User Approval: unspecified Site/Fmwk Approval: approved Flags: Last Checked: 2025-04-29 09:10:21 +0000 Next Check: 2025-05-04 08:42:50 +0000 -------------------------------------------------------------------------------- Service: applinks App ID: <my fully qualified app bundle id> App Version: 760.0 App PI: <LSPersistentIdentifier 0x6b8008930> { v = 0, t = 0x8, u = 0x45c, db = DC8D18A2-430D-4AD4-A5BE-B7A003CF9A6F, {length = 8, bytes = 0x5c04000000000000} } Domain: <mydomain>.com Patterns: {"/":"/cc/*"}, {"?":{"t":"*"},"/":"/md/"} User Approval: unspecified Site/Fmwk Approval: approved Flags: Last Checked: 2025-04-29 09:10:21 +0000 Next Check: 2025-05-04 08:42:50 +0000 -------------------------------------------------------------------------------- Service: applinks App ID: <my fully qualified app bundle id> App Version: 760.0 App PI: <LSPersistentIdentifier 0x6b8008930> { v = 0, t = 0x8, u = 0x45c, db = DC8D18A2-430D-4AD4-A5BE-B7A003CF9A6F, {length = 8, bytes = 0x5c04000000000000} } Domain: *.<mydomain>.com Patterns: {"/":"/cc/*"}, {"?":{"t":"*"},"/":"/md/"} User Approval: unspecified Site/Fmwk Approval: approved Flags: Last Checked: 2025-04-29 09:10:21 +0000 Next Check: 2025-05-04 08:42:50 +0000 -------------------------------------------------------------------------------- The version numbers match the installed version of my app I've tried running logging and just capturing logs before and after I press the "open in ", but there's nothing suspicious in there. And the kicker - it's only happening on a single device. No other devices are experiencing this.
7
1
192
May ’25
In Core Spotlight, it requires four consecutive characters to index the content. Only through title or displayName can the content be indexed.
In Core Spotlight, one can only index content by using title or displayName, and it requires four consecutive characters for indexing. These situations occurred in iOS 17 and 18. In iOS 16, I could not only index content by title or displayName, but also by keyword. Moreover, there was no restriction of requiring four consecutive characters. I could index my app content by simply inputting one character. Here is my code.https://github.com/kritto1/corespotlight-bug-test/tree/main @available(iOS 14, *) func addItemToIndex(_ item: QSpotlightItem) { let attributeSet = CSSearchableItemAttributeSet(contentType: .item) attributeSet.title = item.title attributeSet.displayName = item.title attributeSet.contentDescription = item.contentDescription attributeSet.keywords = item.keywords attributeSet.thumbnailData = item.thumbnailImage attributeSet.contactKeywords = item.keywords attributeSet.supportsNavigation = true let searchableItem = CSSearchableItem(uniqueIdentifier: item.id, domainIdentifier: "com.qunar.iphone.spotlight", attributeSet: attributeSet) searchableItem.expirationDate = .distantFuture CSSearchableIndex.default().indexSearchableItems([searchableItem]) { error in if let error = error { } else { } } } @available(iOS 14, *) func addToSpotlightIndex() { let spotlightHotel = QSpotlightItem( id: "corespotlight_1", title: "查询酒店住宿", contentDescription: "", thumbnailImage: UIImage(named: "img2")?.pngData(), keywords: ["酒店", "住宿"] ) addItemToIndex(spotlightHotel) let spotlightFlight = QSpotlightItem( id: "corespotlight_2", title: "查询和预订机票", contentDescription: "", thumbnailImage: UIImage(named: "img2")?.pngData(), keywords: ["查询", "预订", "机票"] ) addItemToIndex(spotlightFlight) let spotlightSight = QSpotlightItem( id: "corespotlight_3", title: "查询预订门票", contentDescription: "", thumbnailImage: UIImage(named: "img2")?.pngData(), keywords: ["查询", "预订", "门票"] ) addItemToIndex(spotlightSight) }
1
1
130
Apr ’25
DeviceActivityMonitor - Callbacks not trigger
Bellow I created Manager to be easier for me to handle app limits, but for some reason It never reached callbacks function, I have permission for screen time, I added the capabilities for it also, I'm sure, I send correctly the appTokens, categoriesTokens ... and the time limit and it also reach ✅ Monitoring started for..., I don't know what to do anymore: import SwiftUI import DeviceActivity import FamilyControls import ManagedSettings @MainActor class AppUsageManager: DeviceActivityMonitor, ObservableObject { static let shared = AppUsageManager() private let deviceActivityCenter = DeviceActivityCenter() private var monitoringSelections: [DeviceActivityName: (selection: FamilyActivitySelection, timeLimit: DateComponents)] = [:] private var resetTimer: Timer? private override init() { super.init() print("🟢 AppUsageManager initialized.") } // MARK: - Public Methods /// Configures monitoring for a selection with a specific event name and time limit. func configureMonitoring( for selection: FamilyActivitySelection, timeLimitInMinutes: Int, activityName: String, eventName: String ) { let activityName = DeviceActivityName(activityName) let eventName = DeviceActivityEvent.Name(eventName) monitoringSelections[activityName] = (selection, DateComponents(minute: timeLimitInMinutes)) setupMonitoring(for: activityName, with: eventName) } /// Stops monitoring for a specific event. func stopMonitoring(for activityName: String) { let activityName = DeviceActivityName(activityName) Task { print("🛑 Stopping monitoring for \(activityName.rawValue).") deviceActivityCenter.stopMonitoring([activityName]) monitoringSelections.removeValue(forKey: activityName) } } /// Stops all monitoring. func stopAllMonitoring() { print("🛑 Stopping monitoring") deviceActivityCenter.stopMonitoring() } // MARK: - Private Methods /// Sets up monitoring for a specific event. private func setupMonitoring( for activityName: DeviceActivityName, with eventName: DeviceActivityEvent.Name ) { stopAllMonitoring() guard let (selection, timeLimit) = monitoringSelections[activityName] else { print("⚠️ No selection configured for \(activityName.rawValue).") return } print("🛠 Setting up monitoring for \(activityName.rawValue).") print("📋 Monitoring Details:") print("- Time Limit: \(timeLimit.minute ?? 0) minutes.") let warningThreshold = DateComponents(minute: 3) let timeZone = TimeZone.current let schedule = DeviceActivitySchedule( intervalStart: DateComponents(timeZone: timeZone, hour: 0, minute: 0, second: 0), intervalEnd: DateComponents(timeZone: timeZone, hour: 23, minute: 59, second: 59), repeats: true, warningTime: warningThreshold ) let events: [DeviceActivityEvent.Name: DeviceActivityEvent] = [ eventName: DeviceActivityEvent( applications: selection.applicationTokens, categories: selection.categoryTokens, webDomains: selection.webDomainTokens, threshold: timeLimit ) ] do { try deviceActivityCenter.startMonitoring( activityName, during: schedule, events: events ) print("✅ Monitoring started for \(activityName.rawValue) with time limit \(timeLimit.minute ?? 0) minutes.") } catch { print("❌ Failed to start monitoring \(activityName.rawValue): \(error.localizedDescription)") } } // MARK: - DeviceActivityMonitor Overrides override func intervalDidStart(for activity: DeviceActivityName) { print("🟢 Interval for \(activity.rawValue) started.") } override func intervalWillStartWarning(for activity: DeviceActivityName) { print("⚠️ Warning: \(activity.rawValue) is about to start.") } /// Handles warnings for approaching the time limit. override func eventWillReachThresholdWarning( _ event: DeviceActivityEvent.Name, activity: DeviceActivityName ) { super.eventWillReachThresholdWarning(event, activity: activity) print("⚠️ Warning: \(activity.rawValue) is about to reach its time limit.") print("⚠️ Event: \(event.rawValue)") } /// Handles when the time limit is reached. override func eventDidReachThreshold( _ event: DeviceActivityEvent.Name, activity: DeviceActivityName ) { super.eventDidReachThreshold(event, activity: activity) print("🟢 Limit reached.") Task { @MainActor in print("🕒 \(activity.rawValue) has reached its time limit.") print("🕒 Event: \(event.rawValue)") guard let (selection, _) = monitoringSelections[activity] else { print("⚠️ No selection configured for \(activity.rawValue).") return } blockApps(for: selection) } } // MARK: - Blocking Logic /// Blocks the selected apps/categories. private func blockApps(for selection: FamilyActivitySelection) { print("🔒 Blocking apps/categories for selection.") print("- Applications: \(selection.applicationTokens)") print("- Categories: \(selection.categoryTokens)") let store = ManagedSettingsStore() store.shield.applications = selection.applicationTokens store.shield.applicationCategories = .specific(selection.categoryTokens) print("🔒 Apps/categories blocked successfully.") } }
2
1
591
Jan ’25
`user` not returned from Sign in with Apple REST API
I have tried everything to get the user field returned with Sign in flow and it never does, not for new users, not even if i create a new app! Working with Apple is so frustrating and you have to pay for it!! Referencing this page, I am using scope=name email. I have tried using + and %20 as the spacer and neither makes a difference. I have also tried setting response_type = code and code id_token (again with + and %20 as the spacer) which also doesn't make a difference. Always the id_token is returned and always the email, but never the user. https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms#3332115 AUTHORIZE REQUEST https://appleid.apple.com/auth/authorize? { "response_type": "code", "client_id": "com.example.service", "scope": "name email", "state": "77264297-813c-4738-83ef-f1b77daea04c", "redirect_uri": "https://example.com/auth/apple/callback", "code_challenge_method": "S256", "code_challenge": "2SJCneEpjKcN.....xIIHnpqcvjK_Y0s", "access_type": "offline", "nonce": "1734523662", "response_mode": "form_post" } TOKEN REQUEST https://appleid.apple.com/auth/token? { "grant_type": "authorization_code", "code": "c870aaec987a14.....dqakaGP4Yn1nH3dnPgww", "client_id": "com.hikesync.service", "client_secret": "eyJhbGciOiJFUzI....3izij6dojYfdV6JMdbQPx3sOA", "redirect_uri": "https://hikesync.com/auth/apple/callback", "code_verifier": "38hHUC....mYuE0zfYVNTycg" } RESPONSE { "access_token": "a2b70e12d38b446....4hA7-RLNj0ifU5Q", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "rb4ed9be2b4024......w5RWjVFUQ", "id_token": "eyJraWQiOiJyQlJmV.......0Df0ihEJiA" } JWT { "iss": "https://appleid.apple.com", "aud": "SERVICE_ID", "exp": 1734606699, "iat": 1734520299, "sub": "000000.f7f7c0ac.....db9fad7e19.1111", "nonce": "NONCE", "at_hash": "NAfjmciTi2NtmPYIMAgjig", "email": "abc123@privaterelay.appleid.com", "email_verified": true, "is_private_email": true, "auth_time": 1734520297, "nonce_supported": true }
2
1
499
Dec ’24
What is an ASDError Domain Error ?
Is there any resource which describes this type of errors? I was integrating SKADNetwork view through Ad attribution and everything from the source app side is done and this error appears after the target app is installed and opened. Here is the full error Error setting install attribution pingback registered for app: <APP ID>, error: Error Domain=ASDErrorDomain Code=1209 "SKAdNetwork: Could not set registered for pingback that does not exist." UserInfo={NSLocalizedDescription=SKAdNetwork: Could not set registered for pingback that does not exist.}, result: 0 I cannot find any resource on the internet which gives any info about this ASDErrors. If anyone can help, you would be doing me a solid, Thanks in advance.
2
1
2.3k
Apr ’25
Contact Provider Extension via Managed App (MDM) = managed contacts?
When using Mobile Device Management (MDM), it is possible to restrict access to contacts on managed devices. Please see https://support.apple.com/en-us/101932 According to this article, contacts are considered "managed" if they come from either a managed app or a managed account. Does this principle also apply when an MDM-managed app provides contacts via the Contact Provider Extension (CPE)? Specifically, would such "managed" contacts remain inaccessible to unmanaged apps? Our goal is to ensure that unmanaged apps cannot access these contacts. Thanks!
0
1
244
Nov ’24
Rosetta 2 - Build 1.0.0.0.1.1744447383
Goal: Manually install an explicit version of Rosetta2 Background: Me and some customers have an old app (intel) which perfectly worked with Rosetta2. In the last week of April most macheines were updated to Mac Os 15.4.1. and the app still starts but certain functionality is bronken. Some fields ind the forms don't write back to the database, some data can't be read from the database. (Most installations will fade out over the next month but it would be great to have the app fully working for data migration.) First try was to step back to 15.4. (Clean Install - Install App - Rosetta installs as expected): no change, app still broken Second try back to 15: (Clean Install - Install App - Rosetta installs as expected): App still broken (!) This is interesting as the app worked for month using Mac Os 15! Third try: Back to MacOS 14 (Clean Install - Install App - Rosetta installs as expected): App is working like nothing happend. (All attempts on same hardware of course.) Reasoning: Rosetta2 was the only software (besides the app itself) installed after clean MacOS installs. Now, my guess is that there were might be a change in Rosetta2 as the app worked on MacOs 15 up the update 15.4.1. was installed. Checking versions (pkgutil --pkg-info com.apple.pkg.RosettaUpdateAuto): Rosetta version MacOS 14: 1.0.0.0.1.1722778371 Rosetta version on MacOS 15.4.1: 1.0.0.0.1.1744447383 To fully verify the cause it would be great to uninstall Rosetta on MacOS15.4.1 machine and explicit install lower version (1.0.0.0.1.1722778371) which must be available somewhere as MacOS14 still gets this version. I know how to uninstall - is there a possibility to manually install an explicit version of Rosetta2?
0
1
80
May ’25
WeatherKit DayWeather::date Timezone Issue
I use WeatherKit with Swift to get multiple cities weather by longitude and latitude. But I use this API in WeatherService for daily forecast: final public func weather<T>(for location: CLLocation, including dataSet: WeatherQuery<T>) async throws -> T And I found there is something wired: The date of WeatherKit::DayWeather is based on my device's timezone settings. Tokyo's Day Weather is start at UTC+8, New York' Day Weather is start UTC+8. Is there any way to set timezone correctly?
0
1
106
Apr ’25
How to remove INSendMessageIntent in Shortcuts app?
I’ve implemented an Intent Extension and added support for handling the INSendMessageIntent in the intent handler class. Currently, this intent is automatically visible in the Shortcuts app by default. However, for security reasons (as it involves handling phone numbers), I want to restrict the use of this intent to Siri only and ensure it does not appear in the Shortcuts app. Has anyone encountered this requirement before or knows a way to prevent the intent from appearing in the Shortcuts app, while still keeping it functional via Siri? Looking forward to your suggestions!
1
1
375
Jan ’25
How to debug a CoreSpotlight extension?
My CoreSpotlight extension seems to exceed the 6 MB memory limit. What’s the best way to debug this? I've tried to attach the debugger on the Simulator but the extension seems to be never launched when I trigger the reindex from Developer settings. Is this supposed to work? On device, I am able to attach the debugger. However, I can neither transfer the debug session to Instruments, nor display the memory graph. So I've no idea how the memory is used. Any recommendations how to move forward? Is there a way to temporarily disable the memory limit since even with LLDB attached, the extension is killed.
0
1
88
Apr ’25
macOS 15.1 MFMailComposeViewController.canSendMail() returns false always
In my Catalyst app I use func setupMailComposer() { // Check if the device can send email guard MFMailComposeViewController.canSendMail() else { print("Mail services are not available") showMailErrorAlert() return } // Create and configure the mail composer let mailComposeVC = MFMailComposeViewController() mailComposeVC.mailComposeDelegate = self // Set the email details mailComposeVC.setToRecipients(["example@example.com"]) mailComposeVC.setSubject("Subject for your email") mailComposeVC.setMessageBody("This is the body of the email.", isHTML: false) // Attach a file (optional) if let filePath = Bundle.main.path(forResource: "example", ofType: "pdf"), let fileData = try? Data(contentsOf: URL(fileURLWithPath: filePath)) { mailComposeVC.addAttachmentData(fileData, mimeType: "application/pdf", fileName: "example.pdf") } // Present the mail composer self.present(mailComposeVC, animated: true, completion: nil) } Since I have updated to macOS 15.1 the canSendMail() function returns false although I have configured Apple Mail (like before in 15.0 where it worked flawlessly).
4
1
466
Apr ’25
Set Default Value for Date Picker in App Intent
Hi everyone, I have a simple question regarding App Intents. I have an intent that defines a few parameters, one of which is a Date. When the user is prompted for input, I’d like the date picker to start at a specific value (e.g., tomorrow) instead of the default current date. Is there a way to set an initial/default value for the date parameter in an App Intent? Thanks in advance for any guidance!
0
1
290
Jan ’25