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

Calling [NSUserDefaults objectForKey:] crashes as it attempts to insert nil object into dictionary
Hi, I work at OneSignal, a third-party SDK, and have the following two crash reports submitted by a client for the same issue. Because the crash originates from our SDK, even if the root cause may be elsewhere, the onus is on our team to try to resolve this crash. Additionally, my information is limited as this is not our own crash report. I'm trying to figure out why this crash happens and how we can address it within our SDK. Crash Reported: Fatal Exception: NSInvalidArgumentException [NSMutableDictionary __addObject:forKey:]: object cannot be nil Context: Our SDK makes a call to [NSUserDefaults(NSUserDefaults) objectForKey:] on the standardUserDefaults and passes in a non-null key. It appears further up the call stack, a null value is being added to a dictionary. I assume this is the innards of how the search list is generated. Additional Information: The client states that it seems to happen only once per user and the scale is not extremely high but it is increasing. They are unsure what happened and when. They don't have much information about the devices except it has happened on iOS 18. Log 1: 0 CoreFoundation 0x2d5fc __exceptionPreprocess 1 libobjc.A.dylib 0x31244 objc_exception_throw 2 CoreFoundation 0x15548 -[NSMutableDictionary __addObject:forKey:] 3 CoreFoundation 0x20850 -[__NSDictionaryM __apply:context:] 4 CoreFoundation 0x54700 ___CFPrefsDeliverPendingKVONotificationsGuts_block_invoke 5 CoreFoundation 0x52988 __CFDictionaryApplyFunction_block_invoke 6 CoreFoundation 0x52524 CFBasicHashApply 7 CoreFoundation 0x21040 CFDictionaryApplyFunction 8 CoreFoundation 0x7a6b0 _CFPrefsDeliverPendingKVONotificationsGuts 9 CoreFoundation 0x777d0 -[_CFXPreferences _deliverPendingKVONotifications] 10 CoreFoundation 0x776ac __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke 11 CoreFoundation 0x5cf24 normalizeQuintuplet 12 CoreFoundation 0x5cd60 -[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:] 13 CoreFoundation 0x5cc60 -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] 14 CoreFoundation 0x5c8bc _CFPreferencesCopyAppValueWithContainerAndConfiguration 15 Foundation 0xf0dcc -[NSUserDefaults(NSUserDefaults) objectForKey:] 16 OneSignalCore 0xc7c8 -[OneSignalUserDefaults keyExists:] + 61 (OneSignalUserDefaults.m:61) 17 OneSignalCore 0xc8b0 -[OneSignalUserDefaults getSavedBoolForKey:defaultValue:] + 70 (OneSignalUserDefaults.m:70) 18 OneSignalCore 0xbb10 +[OSPrivacyConsentController requiresUserPrivacyConsent] + 59 (OSPrivacyConsentController.m:59) 19 OneSignalCore 0xbc30 +[OSPrivacyConsentController shouldLogMissingPrivacyConsentErrorWithMethodName:] + 75 (OSPrivacyConsentController.m:75) 20 OneSignalCore 0x4418 +[OneSignalConfigManager shouldAwaitAppIdAndLogMissingPrivacyConsentForMethod:] + 50 (OneSignalConfigManager.m:50) 21 OneSignalOSCore 0x537c OSOperationRepo.flushDeltaQueue(inBackground:) + 140 (OSOperationRepo.swift:140) 22 OneSignalOSCore 0x4868 closure #1 in OSOperationRepo.pollFlushQueue() + 84 (OSOperationRepo.swift:84) 23 OneSignalOSCore 0x5078 thunk for @escaping @callee_guaranteed @Sendable () -> () 24 libdispatch.dylib 0x3fa8 _dispatch_client_callout 25 libdispatch.dylib 0x745c _dispatch_continuation_pop 26 libdispatch.dylib 0x1b620 _dispatch_source_latch_and_call 27 libdispatch.dylib 0x1a1e8 _dispatch_source_invoke 28 libdispatch.dylib 0xb42c _dispatch_lane_serial_drain 29 libdispatch.dylib 0xc124 _dispatch_lane_invoke 30 libdispatch.dylib 0x1738c _dispatch_root_queue_drain_deferred_wlh 31 libdispatch.dylib 0x16bd8 _dispatch_workloop_worker_thread 32 libsystem_pthread.dylib 0x3680 _pthread_wqthread 33 libsystem_pthread.dylib 0x1474 start_wqthread Log 2: Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x2d5fc __exceptionPreprocess 1 libobjc.A.dylib 0x31244 objc_exception_throw 2 CoreFoundation 0x15548 -[NSMutableDictionary __addObject:forKey:] 3 CoreFoundation 0x168f0 __72-[CFPrefsSource mergeIntoDictionary:sourceDictionary:cloudKeyEvaluator:]_block_invoke 4 CoreFoundation 0x23ecc -[__NSFrozenDictionaryM __apply:context:] 5 CoreFoundation 0x4f82c -[CFPrefsSource mergeIntoDictionary:sourceDictionary:cloudKeyEvaluator:] 6 CoreFoundation 0x783b8 -[CFPrefsSearchListSource alreadylocked_getDictionary:] 7 CoreFoundation 0x77dfc -[CFPrefsSearchListSource alreadylocked_copyValueForKey:] 8 CoreFoundation 0x77d30 -[CFPrefsSource copyValueForKey:] 9 CoreFoundation 0x77ce4 __76-[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:]_block_invoke 10 CoreFoundation 0x77690 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke 11 CoreFoundation 0x5cf24 normalizeQuintuplet 12 CoreFoundation 0x5cd60 -[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:] 13 CoreFoundation 0x5cc60 -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] 14 CoreFoundation 0x5c8bc _CFPreferencesCopyAppValueWithContainerAndConfiguration 15 Foundation 0xf0dcc -[NSUserDefaults(NSUserDefaults) objectForKey:] 16 OneSignalCore 0xc7c8 -[OneSignalUserDefaults keyExists:] + 61 (OneSignalUserDefaults.m:61) 17 OneSignalCore 0xcbd8 -[OneSignalUserDefaults getSavedDoubleForKey:defaultValue:] + 107 (OneSignalUserDefaults.m:107) 18 OneSignalFramework 0x8964 +[OneSignal shouldStartNewSession] + 350 (OneSignal.m:350) 19 OneSignalFramework 0xc968 +[OneSignalTracker applicationBecameActive] + 83 (OneSignalTracker.m:83) 20 OneSignalFramework 0xb894 -[OneSignalLifecycleObserver didBecomeActive] + 84 (OneSignalLifecycleObserver.m:84) ...... 55 UIKitCore 0x3ee674 -[UIApplication _run] 56 UIKitCore 0x14e88 UIApplicationMain 57 UnityFramework 0x399aef0 -[UnityFramework runUIApplicationMainWithArgc:argv:] + 96 (main.mm:96) 58 ClientsApp 0x412c main + 28 (main.mm:28)
2
0
89
Apr ’25
How to implement normal loading of web content when I intercept all request header information using the Swizzling method
I am developing a web application, I hope to be able to intercept all requests in the loaded web page, match the network request I want to specifically intercept the network request and then obtain the request header information (not the user's personal privacy data interception), if the use is the method of injection, the request header information is incomplete, such as the more important "content-type" field in the request header, so I try to use Swizzling method to intercept all http and https requests, and I can now intercept all the request information. But there is still a problem with my project, when loading x.com, logging in, appearing white screen after the successful landing, and not loading to the page after the successful landing, I don't know where the reason is。 Below is my core code implementation fragment. import WebKit // MARK: - WebViewController class WebViewController: UIViewController { fileprivate var webView: WKWebView! private var schemeHandler: WWKProxyWKURLSchemeHandler! override func viewDidLoad() { super.viewDidLoad() Self.initSwizzling setupWebView() loadInitialContent() } private func setupWebView() { let config = WKWebViewConfiguration() schemeHandler = WWKProxyWKURLSchemeHandler() config.setURLSchemeHandler(self.schemeHandler, forURLScheme: "https") config.setURLSchemeHandler(self.schemeHandler, forURLScheme: "http") webView = WKWebView(frame: view.bounds, configuration: config) webView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(webView) } private func loadInitialContent() { if let url = URL(string: "https://x.com") { let request = URLRequest(url: url,cachePolicy:.reloadIgnoringLocalCacheData,timeoutInterval: 15) webView.load(request) } } func reloadWebView() { webView?.reloadFromOrigin() } } class WWKProxyWKURLSchemeHandler: NSObject, WKURLSchemeHandler { private let lock = NSLock() private var activeTasks = [ObjectIdentifier: URLSessionDataTask]() func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) { lock.lock() defer { lock.unlock() } let taskID = ObjectIdentifier(urlSchemeTask) guard !activeTasks.keys.contains(taskID) else { print("⚠️ Task already started: \(urlSchemeTask.request.url?.absoluteString ?? "")") return } print("Intercepted URL---:",urlSchemeTask.request.url?.absoluteString ?? "") print("All requests intercepted----:",urlSchemeTask.request.allHTTPHeaderFields) let request = urlSchemeTask.request let dataTask = URLSession.shared.dataTask(with: request) { [weak self] data, response, error in guard let self = self else { return } self.lock.lock() let isActive = self.activeTasks[taskID] != nil self.lock.unlock() guard isActive else { print("🌀 Task already cancelled: \(urlSchemeTask.request.url?.absoluteString ?? "")") return } // Make sure it only handles once guard self.activeTasks.keys.contains(taskID) else { return } self.activeTasks.removeValue(forKey: taskID) DispatchQueue.main.async { if let error = error { urlSchemeTask.didFailWithError(error) print("🔴 Task failed: \(urlSchemeTask.request.url?.absoluteString ?? "") - \(error.localizedDescription)") return } guard let response = response, let data = data else { urlSchemeTask.didFailWithError(URLError(.unknown)) print("🔴 Invalid response: \(urlSchemeTask.request.url?.absoluteString ?? "")") return } urlSchemeTask.didReceive(response) urlSchemeTask.didReceive(data) urlSchemeTask.didFinish() print("🟢 Task completed: \(urlSchemeTask.request.url?.absoluteString ?? "")") } } self.activeTasks[taskID] = dataTask dataTask.resume() } func webView(_ webView: WKWebView, stop task: WKURLSchemeTask) {} private func finishTask(taskID: ObjectIdentifier ,task: WKURLSchemeTask, response: URLResponse?, data: Data?, error: Error?) { lock.lock() defer { lock.unlock() } guard activeTasks.keys.contains(taskID) else { return } activeTasks.removeValue(forKey: taskID) DispatchQueue.main.async { if let error = error { task.didFailWithError(error) print("🔴 Task failed: \(task.request.url?.absoluteString ?? "") - \(error.localizedDescription)")return} guard let response = response, let data = data else { task.didFailWithError(URLError(.unknown)) print("🔴 Invalid response: \(task.request.url?.absoluteString ?? "")") return } task.didReceive(response) task.didReceive(data) task.didFinish() print("🟢 Task completed: \(task.request.url?.absoluteString ?? "")") } } } extension WKWebView { @objc dynamic class func qm_handlesURLScheme(_ urlScheme: String) -> Bool { if urlScheme == "https" || urlScheme == "http" {return false} return self.qm_handlesURLScheme(urlScheme) } // Exchange of execution methods static func setupSwizzling() { let originalSelector = #selector(handlesURLScheme(_:)) let swizzledSelector = #selector(qm_handlesURLScheme(_:)) // Implemented by Runtime Get Method guard let originalMethod = class_getClassMethod(WKWebView.self, originalSelector), let swizzledMethod = class_getClassMethod(WKWebView.self, swizzledSelector) else { return } // Implementation of Exchange Methods method_exchangeImplementations(originalMethod, swizzledMethod) } } extension WebViewController { private static let initSwizzling: Void = { DispatchQueue.once(token: "com.webview.swizzling") { WKWebView.setupSwizzling() } }() } // GCD Once extension DispatchQueue { private static var tokens = Set<String>() class func once(token: String, block: () -> Void) { objc_sync_enter(self) defer { objc_sync_exit(self) } guard !tokens.contains(token) else { return } tokens.insert(token) block() } } extension WebViewController: WKNavigationDelegate { func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { decisionHandler(.allow) } }
1
0
57
Apr ’25
How to register ContactProviderDomain
Hi there, we are implementing the new ContactProviderExtension introduced in iOS 18 and we are able to activate the extension, add data and everything. But we want to add domains to seperate contacts and currently we are getting an error "ContactProvider.ContactProviderError.domainNotRegistered". That makes sense because in the API docu we are not finding a way to register our domains. We are using ContactProviderDomain to create domains but we are not able to find any function to register. Could you please give a hint? Thank you
1
0
133
Apr ’25
Increased Memory Limit for QL Preview Generator
we have written a QL preview generator for some 3D data formats not supported by the AR Quicklook generators included in iOS. however, we are struggeling with the 100 MB memory ceiling imposed on an app extension in iOS. we have included the "Increased Memory Limit" entitlement in both the app and in the preview extensions. nevertheless, the preview generator is limited to 100 MB, even on most recent devices like iPhone 16 Pro Max. we can even see 100 MB limit when we attach to the process with Xcode. my question: did we miss anything? are there additional steps necessary to obtain the increased memory limit? must we explicitly apply for it? 500 MB would be fine (our preview generator does not load textures). best regards
2
0
68
Apr ’25
date(byAdding:value:to:options:) Method Behaves Strangely
Let’s try calculating one day after "2023/11/04 12:00 New York time". let timeZone = TimeZone(identifier: "America/New_York")! var calendar = Calendar(identifier: .gregorian) calendar.timeZone = timeZone var dateFormatter = DateFormatter() dateFormatter.timeZone = timeZone dateFormatter.locale = .init(identifier: "ja_JP") dateFormatter.dateStyle = .short dateFormatter.timeStyle = .short var dateComponents = DateComponents() dateComponents.year = 2023 dateComponents.month = 11 dateComponents.day = 4 dateComponents.hour = 12 // At New York 2023/11/04 12:00 let date1 = calendar.date(from: dateComponents)! print(dateFormatter.string(from: date1)) // Add 1 day let date2 = calendar.date(byAdding: .day, value: 1, to: date1)! print(dateFormatter.string(from: date2))``` The output is: 2023/11/04 12:00 2023/11/05 12:00 Now, let’s try the following—also to get the time one day later: let date2 = calendar.date(byAdding: .minute, value: 24 * 60, to: date1)! print(dateFormatter.string(from: date2)) This outputs: 2023/11/04 12:00 2023/11/05 11:00 What's Causing This Difference? It’s likely due to Daylight Saving Time (DST). But why do we get different results between the first and second examples?
1
0
70
Apr ’25
Family Controls Approved for Main App but Not Extension – Blocking
Hi everyone, I’m developing a screen-time and focus app that uses Apple’s Family Controls framework to block distracting apps and reward users through a gamified experience. Apple approved Family Controls (Distribution) for the main app identifier, but they did not approve the required extension target (which implements DeviceActivityMonitor, required for the framework to function). Because of this, I can’t archive or upload the app to TestFlight — and I’ve been stuck in limbo for over 2 months. This is severely delaying my launch. The app works perfectly, but I can’t release it because the extension wasn’t included in the entitlement approval. Has anyone else run into this with Family Controls? Is there any known way to escalate or fast-track approval for additional app IDs or targets? Would really appreciate any help, advice, or hacks. 🙏 Thanks, Enzer
0
0
60
Apr ’25
LiveCommunicationKit
What I want to achieve now is that when the app is not running, upon receiving a notification, it displays an interface similar to CallKit with accept and decline buttons. Here is part of my code: @available(iOS 17.4, *) class LiveCommunicationManager: NSObject, ConversationManagerDelegate { static let shared = LiveCommunicationManager() var isInvalidate:Bool = false var configuration: ConversationManager! override init() { let config = ConversationManager.Configuration( ringtoneName: "notes_of_the_optimistic", iconTemplateImageData: UIImage(named: "AppIcon")?.pngData(), // 图标的 PNG 数据 maximumConversationGroups: 1, // 最大对话组数 maximumConversationsPerConversationGroup: 1, // 每个对话组内最大对话数 includesConversationInRecents: false, // 是否在通话记录中显示 supportsVideo: false, // 是否支持视频 supportedHandleTypes: [.generic,.phoneNumber,.emailAddress] // 支持的通话类型 ) configuration = ConversationManager.init(configuration: config) } func reportIncomingCall(uuid: UUID, callerName: String) { configuration.delegate = self let local = Handle(type: .generic, value: callerName, displayName: callerName) let update = Conversation.Update(localMember: local,members: [local],activeRemoteMembers: [local]) Task{ do { try await configuration.reportNewIncomingConversation(uuid: uuid, update: update) print("成功报告新来电") } catch { print("报告新来电失败: \(error.localizedDescription)") } } } func conversationManager(_ manager: ConversationManager, conversationChanged conversation: Conversation) { print("会话状态改变了") } func conversationManagerDidBegin(_ manager: ConversationManager) { print("会话已经开始了") manager.delegate = self } func conversationManagerDidReset(_ manager: ConversationManager) { print("会话将要清除了") } func conversationManager(_ manager: ConversationManager, perform action: ConversationAction) { print("会话接听了") configuration.invalidate() } func conversationManager(_ manager: ConversationManager, timedOutPerforming action: ConversationAction) { print("会话超时了") } func conversationManager(_ manager: ConversationManager, didActivate audioSession: AVAudioSession) { print("会话激活了") } func conversationManager(_ manager: ConversationManager, didDeactivate audioSession: AVAudioSession) { print("会话死亡了") } } 在Appdelegate里设置了这些: func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -&gt; Void) { // 在这里处理离线推送通知 completionHandler(.noData) // 返回后台任务完成 if let aps = userInfo["aps"] as? [String: Any], let alert = aps["alert"] as? [String : Any]{ // 静默推送的处理逻辑 if #available(iOS 17.4, *) { let manager = LiveCommunicationManager.shared if manager.isInvalidate { return } if let msgType = userInfo["msgType"] as? Int{ if msgType == 5{ manager.configuration.invalidate() }else{ let callerName = alert["title"] as? String ?? "Fanvil" manager.reportIncomingCall(uuid: UUID(), callerName: callerName) } } } } } Xcode has been configured with the necessary capabilities, such as Background Fetch, Voice over IP, Background Processing, and Push Notification. The issue now is that sometimes the code works as expected, allowing the app to wake up when not running and displaying the system interface with accept and decline buttons. However, after a few successful attempts, the app stops waking up, and no notification appears. But when I manually open the app, the didReceiveRemoteNotification method gets triggered. I’d like to know why this stops working after a few times.
0
1
123
Apr ’25
I encountered some problems while developing the default translation app.
Simulator device failed to install the application. Domain: IXErrorDomain Code: 2 Failure Reason: Invalid placeholder attributes. User Info: { DVTErrorCreationDateKey = "2025-04-01 17:20:32 +0000"; FunctionName = "+[IXPlaceholder _placeholderForBundle:client:withParent:installType:metadata:placeholderType:mayBeDeltaPackage:isFromSerializedPlaceholder:error:]"; IDERunOperationFailingWorker = IDELaunchiPhoneSimulatorLauncher; SimCallingSelector = "installApplication:withOptions:error:"; SourceFileLine = 981; } Failed to create app extension placeholder for /Users/eddiepeng/Library/Developer/Xcode/DerivedData/Omnit-bjygrdfdoommzzcnbjuvwoakvdkw/Build/Products/Release-iphonesimulator/Omnit.app/PlugIns/OmnitTranslationExtension.appex Domain: IXErrorDomain Code: 2 Failure Reason: Failed to create promise. User Info: { FunctionName = "+[IXPlaceholder _placeholderForBundle:client:withParent:installType:metadata:placeholderType:mayBeDeltaPackage:isFromSerializedPlaceholder:error:]"; SourceFileLine = 981; } Failed to set placeholder attributes top.delta17.Omnit.OmnitTranslationExtension Domain: IXErrorDomain Code: 2 Failure Reason: Failed to create promise. User Info: { FunctionName = "+[IXPlaceholder _placeholderForBundle:client:withParent:installType:metadata:placeholderType:mayBeDeltaPackage:isFromSerializedPlaceholder:error:]"; SourceFileLine = 818; } extensionDictionary must be set in placeholder attributes for an app extension placeholder Domain: IXErrorDomain Code: 17 Failure Reason: Invalid placeholder attributes. User Info: { FunctionName = "-[IXPlaceholder setPlaceholderAttributes:error:]"; SourceFileLine = 1999; } Event Metadata: com.apple.dt.IDERunOperationWorkerFinished : { "device_identifier" = "E645E32D-57B1-4A24-95A4-6BFD0062F51D"; "device_model" = "iPhone17,3"; "device_osBuild" = "18.4 (22E238)"; "device_platform" = "com.apple.platform.iphonesimulator"; "device_thinningType" = "iPhone17,3"; "dvt_coredevice_version" = "443.19"; "dvt_coresimulator_version" = "1010.10"; "dvt_mobiledevice_version" = "1784.102.1"; "launchSession_schemeCommand" = Run; "launchSession_state" = 1; "launchSession_targetArch" = arm64; "operation_duration_ms" = 38; "operation_errorCode" = 2; "operation_errorDomain" = IXErrorDomain; "operation_errorWorker" = IDELaunchiPhoneSimulatorLauncher; "operation_name" = IDERunOperationWorkerGroup; "param_debugger_attachToExtensions" = 0; "param_debugger_attachToXPC" = 1; "param_debugger_type" = 3; "param_destination_isProxy" = 0; "param_destination_platform" = "com.apple.platform.iphonesimulator"; "param_diag_113575882_enable" = 0; "param_diag_MainThreadChecker_stopOnIssue" = 0; "param_diag_MallocStackLogging_enableDuringAttach" = 0; "param_diag_MallocStackLogging_enableForXPC" = 1; "param_diag_allowLocationSimulation" = 1; "param_diag_checker_tpc_enable" = 1; "param_diag_gpu_frameCapture_enable" = 0; "param_diag_gpu_shaderValidation_enable" = 0; "param_diag_gpu_validation_enable" = 0; "param_diag_guardMalloc_enable" = 0; "param_diag_memoryGraphOnResourceException" = 0; "param_diag_mtc_enable" = 1; "param_diag_queueDebugging_enable" = 1; "param_diag_runtimeProfile_generate" = 0; "param_diag_sanitizer_asan_enable" = 0; "param_diag_sanitizer_tsan_enable" = 0; "param_diag_sanitizer_tsan_stopOnIssue" = 0; "param_diag_sanitizer_ubsan_enable" = 0; "param_diag_sanitizer_ubsan_stopOnIssue" = 0; "param_diag_showNonLocalizedStrings" = 0; "param_diag_viewDebugging_enabled" = 1; "param_diag_viewDebugging_insertDylibOnLaunch" = 1; "param_install_style" = 2; "param_launcher_UID" = 2; "param_launcher_allowDeviceSensorReplayData" = 0; "param_launcher_kind" = 0; "param_launcher_style" = 0; "param_launcher_substyle" = 0; "param_runnable_appExtensionHostRunMode" = 0; "param_runnable_productType" = "com.apple.product-type.application"; "param_structuredConsoleMode" = 1; "param_testing_launchedForTesting" = 0; "param_testing_suppressSimulatorApp" = 0; "param_testing_usingCLI" = 0; "sdk_canonicalName" = "iphonesimulator18.4"; "sdk_osVersion" = "18.4"; "sdk_variant" = iphonesimulator; } System Information macOS Version 15.3.2 (Build 24D81) Xcode 16.3 (23785) (Build 16E140) Timestamp: 2025-04-02T01:20:32+08:00
3
0
73
Apr ’25
Add MacOs Finder compatible Quicklook Extension for custom file types to Mac Catalyst App
I have an iOS app which has an embedded Quicklook Extension that works perfectly - in the Files app on iPad/iPhone I can QuickLook view and edit custom file types without problems. However, when I run the app on a Silicon Mac using Mac Catalyst (or (Made For iPad)) while the Finder does recognise the custom file types (allowing "Open in…" or double-clicking to open) it does not show the Quick Look extension. How do I add Finder QuickLook extension functionality to a Mac Catalyst app? Thanks
2
0
55
Mar ’25
How do I handle force-quit in Swift
How do I handle force quit in Swift? I received crash reports during a tesflight test. I didn't understand what it was: none of my app's symbols were present, and Xcode didn't want them either... unlike two others who were very specific. By doing a few Google queries, I saw that [UIApplication _terminateWithStatus:] + 136 (UIApplication.m:7578). Accompanied by a SIGSEV... corresponded to a simple thing: it's a crash during a force quit. I tested it with two iPhones, connected to my Mac, and launched the app from Xcode on each of them. I waited a bit, then quit it. It immediately went into the background and waited to launch operations with BackgroundTaskManager. I went to the app carousel and quit it with a swipe of my finger. I immediately see in the log that "sceneDidDisconnect" from SceneDelegate is called... then the immediate crash occurs, with the same elements as those received during the test flight crashlog.crash : SIGSEV and [UIApplication _terminateWithStatus:] and identical elements thereafter. And this applies regardless of what I put in "SceneDidDisconnect," a print, and something to close the BGtasks if they are running (but iOS should normally kill them too, right?) .. 1 or 2 secondes after it crashes. At the moment of the crash, the Xcode cursor is positioned on "class Appdelegate" in AppDelegate. class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate { My question is: how do I handle force quit in Swift? I have another Objective-C application that does the same thing and runs identical operations in the background. If I force quit it, there is no crash.
4
0
78
Mar ’25
Issues with Family Control API: App Blocking & Screen Time for Multiple Children
We are developing a parental control application in SwiftUI with features like app blocking and screen time management. We are using the Family Control API along with Apple Family Sharing, allowing parents to add multiple children to the family group. We have followed the apple documentation still we are facing following issues: App Blocking Issue: The family picker does not display each child's name separately or their apps individually. Instead, it shows all children's apps together, making it difficult to block apps for a specific child. Screen Time Data Issue: We receive the total screen time usage for all children combined rather than separate screen time data for each child. Syncing Delay: When a new child is added to the Family Sharing group, we are unsure how long it takes for their apps to sync and appear on the parent’s device.
1
3
286
Mar ’25
Safari Web Extensions & NSXPCConnection
I have a basic setup following WWDC 2020 on Safari Web Extensions and another one on XPC. The video even mentions that one can use UserDefaults or XPC to communicate with the host app. Here is my setup. macOS 15.2, Xcode 16.2 A macOS app (all targets sandboxed, with an app group) with 3 targets: SwiftUI Hello World web extension XPC Service The web extension itself works and can update UserDefaults, which can then be read by SwiftUI app - everything works by the book. The app can communicate to the XPC service via NSXPCConnection - again, everything works fine. The problem is that the web extension does not communicate with XPC, and this is what I need so that I can avoid using UserDefaults for larger and more complex payloads. Web Ext handler code: class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { func beginRequest(with context: NSExtensionContext) { // Unpack the message from Safari Web Extension. let item = context.inputItems[0] as? NSExtensionItem let message = item?.userInfo?[SFExtensionMessageKey] // Update the value in UserDefaults. let defaults = UserDefaults(suiteName: "com.***.AppName.group") let messageDictionary = message as? [String: String] if messageDictionary?["message"] == "Word highlighted" { var currentValue = defaults?.integer(forKey: "WordHighlightedCount") ?? 0 currentValue += 1 defaults?.set(currentValue, forKey: "WordHighlightedCount") } let response = NSExtensionItem() response.userInfo = [ SFExtensionMessageKey: [ "Response to": message ] ] os_log(.default, "setting up XPC connection") let xpcConnection = NSXPCConnection(serviceName: "com.***.AppName.AppName-XPC-Service") xpcConnection.remoteObjectInterface = NSXPCInterface(with: AppName_XPC_ServiceProtocol.self) xpcConnection.resume() let service = xpcConnection.remoteObjectProxyWithErrorHandler { error in os_log(.default, "Received error: %{public}@", error as CVarArg) } as? AppName_XPC_ServiceProtocol service?.performCalculation(firstNumber: 23, secondNumber: 19) { result in NSLog("Result of calculation XPC is: \(result)") os_log(.default, "Result of calculation XPC is: \(result)") context.completeRequest(returningItems: [response], completionHandler: nil) } } } The error I'm getting: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.***.AppName.AppName-XPC-Service was invalidated: failed at lookup with error 3 - No such process." What am I missing?
6
0
155
Mar ’25
FamilyActivityPicker: manage own device AND children device
Hello, I am unable to figure out how I tell the FamilyActivityPicker whether it should show apps installed on my personal device (to be used with AuthorizationCenter.shared.requestAuthorization(for: .individual)) or apps installed on my child’s device (authenticated their phone via AuthorizationCenter.shared.requestAuthorization(for: .child)). Is there any parameter or SwiftUI modifier I need to apply? Otherwise, how does the user or the app know which token belongs to them and which token belongs to their child’s device? Radar: FB17020977 Thanks a lot for your help!
0
0
44
Mar ’25
IdentityLookup deferQueryRequestToNetwork error 3 despite valid AASA and extension setup
I'm seeking help troubleshooting a persistent com.apple.IdentityLookup.error.messagefilter Code=3 error when my Message Filter Extension tries to defer to network. I’ve exhausted Apple documentation and forum posts, and Apple Support has asked me to escalate this via the forums to reach engineering. ✅ My Setup: Xcode: 16.2 macOS: Sequoia 15.3.1 (Apple Silicon Mac mini) Device: iPhone 14 Pro iOS: 18.3.2 (Developer Mode enabled) Tested via: TestFlight install on real device 📦 App Structure: Main App Target (minimal "hello world" logic) Message Filter Extension Target Messages Extension Target Message Reporting Extension Target Notifications Extension Target ✅ Capabilities & Configurations Main App Capabilities: App Groups: group.com.example.shared Network Extensions: Content Filter Associated Domains: messagefilter:my-api.example.com applinks:my-api.example.com Message Filter Capabilities: App Groups: same as main app Network Extensions: Content Filter Associated Domains: same as above 📄 Info.plist Config Main App Info.plist: NSAppTransportSecurity with: NSAllowsArbitraryLoads = YES Exception domain my-api.example.com with: NSIncludesSubdomains = YES NSTemporaryExceptionAllowsInsecureHTTPLoads = YES NSTemporaryExceptionMinimumTLSVersion = TLSv1.2 MessageFilter Info.plist: Same ATS settings as above NSExtension block: <key>NSExtension</key> <dict> <key>NSExtensionAttributes</key> <dict> <key>ILMessageFilterExtensionNetworkURL</key> <string>https://my-api.example.com/api/sms-filter</string> <key>ILClassificationExtensionSMSReportDestination</key> <string>+10000000000</string> </dict> <key>NSExtensionPointIdentifier</key> <string>com.apple.identitylookup.message-filter</string> <key>NSExtensionPrincipalClass</key> <string>$(PRODUCT_MODULE_NAME).MessageFilterExtension</string> </dict> 📜 Entitlements Main App Entitlements <key>com.apple.developer.associated-domains</key> <array> <string>messagefilter:my-api.example.com</string> <string>applinks:my-api.example.com</string> </array> <key>com.apple.developer.networking.networkextension</key> <array> <string>content-filter-provider</string> </array> <key>com.apple.security.application-groups</key> <array> <string>group.com.example.shared</string> </array> Message Filter Extension Entitlements Identical to main app’s, scoped to the extension. 📄 AASA File (Hosted on https://my-api.example.com/.well-known/apple-app-site-association) Serves as application/json, returns 200 OK, and is reachable on device via Safari. Logs confirm AASA is downloaded and installed successfully during TestFlight install. { "applinks": { "apps": [], "details": [ { "appID": "TEAMID.com.example.app", "paths": ["*"] }, { "appID": "TEAMID.com.example.app.MessageFilter", "paths": ["*"] } ] }, "messagefilter": { "apps": [], "details": [ { "appID": "TEAMID.com.example.app", "filterType": "URL", "domains": ["my-api.example.com"] }, { "appID": "TEAMID.com.example.app.MessageFilter", "filterType": "URL", "domains": ["my-api.example.com"] } ] }, "classificationreport": { "apps": [], "details": [ { "appID": "TEAMID.com.example.app", "domains": ["my-api.example.com"] }, { "appID": "TEAMID.com.example.MessageReporting", "domains": ["my-api.example.com"] } ] } } ❌ The Problem When the extension launches and receives an SMS to classify, logs show: deferQueryRequestToNetwork failed: The operation couldn’t be completed. (com.apple.IdentityLookup.error.messagefilter error 3.) The extension loads, network URL is available, the AASA is installed, and yet the extension is not allowed to defer to network. This occurs every time. 🧪 Other Notes Tried rebuilding everything from scratch Archiving to TestFlight, not running via Xcode Clean entitlements verified using codesign -d --entitlements :- Console logs show no issues with AASA download or validation Any help or insights from Apple engineering or others in the community who have successfully deployed a working Message Filter Extension would be hugely appreciated. Thanks in advance 🙏
1
1
62
Mar ’25
Spotlight search by keywords setuped in NSUserActivity doesn't work
Hey there! I faced issue in iOS 18 and newer when Spotlight search doesn't show my App in results. In older versions it works. Here is my code: func configureUserActivitity(with id: String, keywords: [String]) { let activity = NSUserActivity(activityType: id) activity.contentAttributeSet = self.defaultAttributeSet activity.isEligibleForSearch = true activity.keywords = Set(keywords) activity.becomeCurrent() self.userActivity = activity } I didn't find any reasons why it doesn't work now. Maybe I should report a bug?
6
0
129
Mar ’25
My FinderSync Extension is blocked by the System
Hi guys, I'm developing a FinderSync Extension that extends Finder contextual menu with a couple of items doing some trivial file operations. I'm using Xcode 16.2 on macOS Sequoia 15.3.2 I could run the containing app in debug, and in System Preferences -> File Providers the flag is enabled for my app finder extension. Anyway, the contextual menu does not show in Finder, probably because the finder extension crashes immediately. Some output: pluginkit -m | grep "com\.[^a]" + com.mycompany.MyApp.MyAppFinderExtension(1.1.14) codesign -dvvv --entitlements - /Users/me/Library/Developer/Xcode/DerivedData/MyApp-dmzhnwmosboixodalsrrbwvwvmqm/Build/Products/Debug/MyApp.app/Contents/PlugIns/MyApp\ Finder\ Extension.appex Executable=/Users/me/Library/Developer/Xcode/DerivedData/MyApp-dmzhnwmosboixodalsrrbwvwvmqm/Build/Products/Debug/MyApp.app/Contents/PlugIns/MyApp Finder Extension.appex/Contents/MacOS/MyApp Finder Extension Identifier=com.mycompany.MyApp.MyAppFinderExtension Format=bundle with Mach-O thin (arm64) CodeDirectory v=20400 size=659 flags=0x2(adhoc) hashes=9+7 location=embedded Hash type=sha256 size=32 CandidateCDHash sha256=b59538ef9e3b6e8cf462a3e260e3bf26d050deb5 CandidateCDHashFull sha256=b59538ef9e3b6e8cf462a3e260e3bf26d050deb5e21fb27d4fa0a4fe5f3e78b7 Hash choices=sha256 CMSDigest=b59538ef9e3b6e8cf462a3e260e3bf26d050deb5e21fb27d4fa0a4fe5f3e78b7 CMSDigestType=2 CDHash=b59538ef9e3b6e8cf462a3e260e3bf26d050deb5 Signature=adhoc Info.plist entries=23 TeamIdentifier=not set Sealed Resources version=2 rules=13 files=9 Internal requirements count=0 size=12 [Dict] [Key] com.apple.security.app-sandbox [Value] [Bool] true [Key] com.apple.security.application-groups [Value] [Array] [String] [Key] com.apple.security.assets.movies.read-write [Value] [Bool] true [Key] com.apple.security.assets.music.read-write [Value] [Bool] true [Key] com.apple.security.assets.pictures.read-write [Value] [Bool] true [Key] com.apple.security.files.documents.read-write [Value] [Bool] true [Key] com.apple.security.files.downloads.read-write [Value] [Bool] true [Key] com.apple.security.files.user-selected.read-write [Value] [Bool] true [Key] com.apple.security.get-task-allow [Value] [Bool] true [Key] com.apple.security.personal-information.location [Value] [Bool] true The log is showing something very strange: log show --predicate 'eventMessage contains "com.mycompany.MyApp" and messageType = error' --last 1h Filtering the log data using "composedMessage CONTAINS "com.mycompany.MyApp" AND logType == 16" Skipping info and debug messages, pass --info and/or --debug to include. Timestamp Thread Type Activity PID TTL 2025-03-25 10:20:48.428127+0100 0x221af Error 0x53dbe 159 0 tccd: [com.apple.TCC:access] Request message contains a target_token to accessing_process (TCCDProcess: identifier=com.mycompany.MyApp, pid=4140, auid=501, euid=501, binary_path=/Users/me/Library/Developer/Xcode/DerivedData/MyApp-dmzhnwmosboixodalsrrbwvwvmqm/Build/Products/Debug/MyApp.app/Contents/MacOS/MyApp) but TCCDProcess: identifier=com.apple.audio.coreaudiod, pid=184, auid=202, euid=202, binary_path=/usr/sbin/coreaudiod is not a TCC manager for service: kTCCServiceScreenCapture. 2025-03-25 10:20:53.166554+0100 0x22139 Error 0x67ff4 163 0 runningboardd: (RunningBoard) [com.apple.runningboard:general] RBSStateCapture remove item called for untracked item 163-158-7088 (target:[app<application.com.mycompany.MyApp.36628067.36635236.92E24CD3-97A8-4340-A46E-4493456283C7(501)>:4140]) 2025-03-25 10:20:53.166575+0100 0x22139 Error 0x67ff4 163 0 runningboardd: (RunningBoard) [com.apple.runningboard:general] RBSStateCapture remove item called for untracked item 163-158-7087 (target:[app<application.com.mycompany.MyApp.36628067.36635236.92E24CD3-97A8-4340-A46E-4493456283C7(501)>:4140]) 2025-03-25 10:20:53.166582+0100 0x22139 Error 0x67ff4 163 0 runningboardd: (RunningBoard) [com.apple.runningboard:general] RBSStateCapture remove item called for untracked item 163-158-7091 (target:[app<application.com.mycompany.MyApp.36628067.36635236.92E24CD3-97A8-4340-A46E-4493456283C7(501)>:4140]) 2025-03-25 10:20:53.166593+0100 0x22139 Error 0x67ff4 163 0 runningboardd: (RunningBoard) [com.apple.runningboard:general] RBSStateCapture remove item called for untracked item 163-132-7084 (target:[xpcservice<com.apple.finder.FinderSync.IsExtensionEnabled([app<application.com.mycompany.MyApp.36628067.36635236.92E24CD3-97A8-4340-A46E-4493456283C7(501)>:4140])(501)>{vt hash: 0}:4144:4144]) -------------------------------------------------------------------------------------------------------------------- Log - Default: 0, Info: 0, Debug: 0, Error: 13, Fault: 0 Activity - Create: 0, Transition: 0, Actions: 0 Especially the first line: MyApp is not accessing coreaudiod - neither trying to get a ScreenCapture, so ... WTF??? How is it possibile? Why is the system blocking MyApp FinderExtension, or preventing it to run? Thank you in advance _Alex
2
0
75
Mar ’25
apple-app-site-association 403
Hi There, hopefully someone can help me here, we weren’t aware but our universal links stopped working sometime last year, as they are not used often on the apps, it wasn’t noticed. We checked all the elements and this is the situation: Our apple-app-site-association file is located at https://ourdomain.com.au/.well-known/apple-app-site-association And it is accessible and can be downloaded. We have Associated Domain services enabled for our app Bundle Id: au.com.identifier.app The Entitlements.plist in our app contains the list of associated domains - the second is the full url, the portal won't let me write it as such as it's not the real address. But links for the first two, …ourdomain.com.au domains don’t work Request https://ourdomain.com.au/.well-known/apple-app-site-association downloads the file and returns status code:403 While checking the availability with https://app-site-association.cdn-apple.com/a/v1/ourdomain.com.au we get the error: ourdomain.com.au: Failed to load resource: the server responded with a status of 404 (Not Found) Going directly to the hosted website: https://app-site-association.cdn-apple.com/a/v1/ourdomain-prod-ourdomainwebsite.azurewebsites.net Returns the json: { "activitycontinuation": { "apps": [ "99ABCD88XXX.au.com.identifier.app", "99ABCD88XXX.au.com.identifier.server.adhoc", "99ABCD88XXX.au.com.identifier.server.dev" ] }, "applinks": { "apps": [], "details": [ { "appID": "99ABCD88XXX.au.com.identifier.app", "paths": [ "/m/" ] }, { "appID": "99ABCD88XXX.au.com.identifier.server.adhoc", "paths": [ "/mt/" ] }, { "appID": "99ABCD88XXX.au.com.identifier.server.dev", "paths": [ "/md/*" ] } ] } } It appears to be something in the redirect from the url but debugging shows nothing obvious. Has anyone experienced this before? Thanks
3
0
94
Mar ’25
SIM verification on iPhone
Hi, We have a need to provide SIM verification. At present, accessing the phone number bound to the device is not programmatically accessible. Would Apple consider exposing this API via a user consent? Otherwise, what is the suggested approach to verify the SIM card is the correct phone number on an iOS device?
1
0
86
Mar ’25