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

getTimeline called twice on load
When I run my widget from xcode I see getTimeline is called twice for some reason. It's called the first time, then after it returns a timeline it's called again. The logs have the following message: "-[EXSwiftUI_Subsystem beginUsing:withBundle:] unexpectedly called multiple times." It takes about 0.5 seconds for the first getTimeline call to return so it doesn't seem like the OS should try to call this method again so quickly (my timeline entries all have times in the future so they shouldn't request the widget to load immediately) Is this a bug, or expected? Seems to happen every time I run the widget.
8
1
3.3k
Sep ’20
Updating Widgets from StaticConfiguration to IntentConfiguration Requires Re-Installation
I'm updating my widget from StaticConfiguration to IntentConfiguration. When I do so, existing widgets installed within simulators and on my iPhone device either show a blank screen or a placeholder screen and fail to initialize. Is there a safe way to upgrade my widget configuration? I would hate to break the widget for our existing users and force them to manually reinstall.
9
0
2.1k
Sep ’20
App Clip launch from Maps
Hello, I set up multiple Advanced App Clips experiences with some attached to locations in Apple Maps. But it never appears on those locations in the Maps app. However, the App Clips perfectly launch when scanned from a QR Code, but the App Banner in Safari does not appear if the App is not already installed on my phone. Does anyone know how to debug and fix this issue? Or maybe I am missing something, a review of such Advanced App Clips Experiences linked to Maps perhaps?
3
1
1.6k
Sep ’20
iOS 14 CoreFoundation crash with EXC_BREAKPOINT
Hi, I am facing a strange issue in my app with iOS14 there is a intermittent crash, i am using NetServiceBrowser for MDNS discovery not sure if that is causing the problem crash log has below information: Crashed: com.apple.main-thread 0 CoreFoundation 0x1a906c4c4 CFAssertMismatchedTypeID + 108 1 CoreFoundation 0x1a8f7db0c CFRunLoopSourceRemoveFromRunLoop + 298 2 CFNetwork 0x1a96255b0 CFNetServiceBrowserStopSearch + 460 3 CoreFoundation 0x1a8f81240 CFRUNLOOPISCALLINGOUTTOASOURCE0PERFORMFUNCTION + 24 4 CoreFoundation 0x1a8f81140 CFRunLoopDoSource0 + 204 5 CoreFoundation 0x1a8f80488 CFRunLoopDoSources0 + 256 6 CoreFoundation 0x1a8f7aa40 CFRunLoopRun + 776 7 CoreFoundation 0x1a8f7a200 CFRunLoopRunSpecific + 572 8 GraphicsServices 0x1bf075598 GSEventRunModal + 160 9 UIKitCore 0x1ab840004 -[UIApplication run] + 1052 10 UIKitCore 0x1ab8455d8 UIApplicationMain + 164
29
1
10k
Oct ’20
Send iMessage AND Text (SMS) from the Command Line
This code sends a text message from the command line on run {targetBuddyPhone, targetMessage}   tell application "Messages"     set targetService to 1st service whose service type = SMS      set targetBuddy to buddy targetBuddyPhone of targetService     send targetMessage to targetBuddy   end tell end run  And this code sends an iMessage from the command line on run {targetBuddyPhone, targetMessage}   tell application "Messages"     set targetService to 1st service whose service type = iMessage     set targetBuddy to buddy targetBuddyPhone of targetService     send targetMessage to targetBuddy   end tell end run  I’m looking for a solution to combine this code into a single snippet that will try to send an iMessage if the recipient has iMessages, but if they do not, then the code will send a SMS message.
2
0
3.3k
Nov ’20
iOS14 Widget Crash
I found a lot of widget crashes in the AppStore, looking at the call stack crashes should be in the widget initialization phase, and there is not an execution to the project code, what is the cause of this problem? The crashing system is iOS14 and iOS14.2 This is a few related crashes: Exception Type:&#9;EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001e79e1424 Termination Signal: Trace/BPT trap: 5 Termination Reason: Namespace SIGNAL, Code 0x5 Terminating Process: exc handler [318] Triggered by Thread:&#9;0 Thread 0 name: Thread 0 Crashed: 0&#9; WidgetKit&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001e79e1424 closure #1 in WidgetExtensionContext.getDescriptors(completion:) + 176 (WidgetExtensionContext.swift:88) 1&#9; WidgetKit&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001e79e13bc closure #1 in WidgetExtensionContext.getDescriptors(completion:) + 72 (WidgetExtensionContext.swift:88) 2&#9; WidgetKit&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001e79e0844 thunk for @escaping @callee_guaranteed () -> () + 20 (<compiler-generated>:0) 3&#9; libdispatch.dylib&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a8235298 _dispatch_call_block_and_release + 24 (init.c:1454) 4&#9; libdispatch.dylib&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a8236280 _dispatch_client_callout + 16 (object.m:559) 5&#9; libdispatch.dylib&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a82185b8 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 856 (inline_internal.h:2548) 6&#9; CoreFoundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a84f580c CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12 (CFRunLoop.c:1790) 7&#9; CoreFoundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a84efcc4 __CFRunLoopRun + 2480 (CFRunLoop.c:3118) 8&#9; CoreFoundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a84eeddc CFRunLoopRunSpecific + 572 (CFRunLoop.c:3242) 9&#9; Foundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a8884158 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 228 (NSRunLoop.m:374) 10&#9;Foundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a88b5264 -[NSRunLoop(NSRunLoop) run] + 88 (NSRunLoop.m:399) 11&#9;libxpc.dylib&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a8138748 _xpc_objc_main + 684 (main.m:265) 12&#9;libxpc.dylib&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a813a938 xpc_main + 176 (init.c:1198) 13&#9;Foundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a88b7468 -[NSXPCListener resume] + 300 (NSXPCListener.m:448) 14&#9;PlugInKit&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001b7829d68 -[PKService run] + 396 (PKService.m:186) 15&#9;PlugInKit&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001b78299d8 +[PKService main] + 572 (PKService.m:115) 16&#9;PlugInKit&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001b782a160 +[PKService _defaultRun:arguments:] + 20 (PKService.m:233) 17&#9;ExtensionKit&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001e9cea994 EXExtensionMain + 80 (EXExtensionMain.m:23) 18&#9;Foundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a89f1ccc NSExtensionMain + 192 (NSExtensionMain.m:13) 19&#9;libdyld.dylib&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x00000001a83845c4 start + 4 Thread 1: 0&#9; libsystem_pthread.dylib&#9;&#9;&#9; 0x00000001a829086c start_wqthread + 0 Thread 2: 0&#9; libsystem_pthread.dylib&#9;&#9;&#9; 0x00000001a829086c start_wqthread + 0 Thread 3: 0&#9; libsystem_pthread.dylib&#9;&#9;&#9; 0x00000001a829086c start_wqthread + 0 Thread 4: 0&#9; libsystem_pthread.dylib&#9;&#9;&#9; 0x00000001a829086c start_wqthread + 0
3
1
917
Dec ’20
Sidecar not connecting, device timed out...
I have a new iPad Air (4th Gen) trying to connect with my Macbook Pro 2017 on Big Sur... Display is not connecting and request times out. They are on the same Wifi network, have bluetooth enabled (although the devices wont connect to each other, but show under My Devices), have Handoff enabled, and am logged in under the same Apple ID with 2FA. I’ve tried restarting the devices, toggling settings, and resetting network settings... I've tried all of the above connected with a USB-C and also unconnected. The iPad is set as a Trusted device via Finder when plugged into my Macbook. Not sure what else I can do. Thanks in advance!
18
0
21k
Mar ’21
Safari Web Extension and Sign in with Apple
My existing chrome extension has "Sign in with Apple" given that we have iOS users. When user clicks "Continue with Apple" button in the extension log in pop up, this is what we do: javascript window.open( 'https://appleid.apple.com/auth/authorize?client_id=' + clientID + '&amp;redirect_uri=' + backEndURL + '&amp;response_type=id_token%20code&amp;response_mode=form_post&amp;scope=email%20name', 'Sign in with Apple', 'height=500,width=400,left=600,top=200,status=no,location=no,toolbar=no,menubar=no' ) In chrome, this opens a popup window with that URL. In Safari Converted Web Extension, it opens custom Apple sign in flow, where it says: "Do you want to sign in to *** with your Apple ID YYY?" and then with my mac password I'm able to authenticate. Afterwards, nothing happens. Expected: a redirect to the URL specified in the window.open. Now let's do a trick: I'll wrap the above window.open code into javascript setTimeout (() = {window.open (...)}, 3000) Because of security reasons, safari then won't open the popup after 3s and will display a notification in the toolbar "Popup blocked..". If we allow the popup, then it finally opens as a normal window popup and after sign in, it redirects to our backend and it successfully authenticates. Any ides what how to solve this? P.S. We're not able to use embedded Sign in with Apple JS - https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/configuring_your_webpage_for_sign_in_with_apple script because we can't host a remote code in the extension (it will be deprecated soon). So, we arere using this. - https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms
2
0
1.6k
Mar ’21
Developer APIs for AirTag integration in our apps and games?
I'm very excited about the new AirTag product and am wondering if there will be any new APIs introduced in iOS 14.5+ to allow developers to build apps around them outside the context of the Find My network? The contexts in which I am most excited about using AirTags are: Gaming Health / Fitness-focused apps Accessibility features Musical and other creative interactions within apps I haven't been able to find any mention of APIs. Thanks in advance for any information that is shared here. Alexander
34
4
27k
Apr ’21
-[NSURLSessionWebSocketTask cancelWithCloseCode:reason:] reliability issue
Hello, For our iOS app, we're switching WebSocket client implementation from one using Poco project - https://github.com/pocoproject/poco to one based on NSURLSessionWebSocketTask. We are observing one regression which prevents us from shipping this solution though: 5-7% of calls to -[NSURLSessionWebSocketTask cancelWithCloseCode:reason:] fail to deliver given close code to server and 1006 close code (AbnormalClosure) is used instead. Our test consist of following steps: Create WebSocket using NSURLSessionWebSocketTask Send "Hello" message Close WebSocket with 1011 close code Destroy NSURLSessionWebSocketTask instance Check whether server received 1011 close code We do not perform those steps line by line, but rather use delays (~100-200ms) between each step. We perform such test 1000 times and observe 5-7% failure rate consistently. Distribution of failures is random. We did perform test on both iOS simulator and iOS devices with no observable differences. We did perform test on multiple server implementations (tornado- and node.js based ones) running on local machine (same as Xcode) and remote one We always receive "Hello" message on server 1011 close code is arbitrarily chosen for testing, but results are same for different ones, too. We did setup mitmproxy and for failed tests see following log: Error in WebSocket connection to 20.16.12.131:8080: WebSocket connection closed unexpectedly by client: TcpDisconnect(None) We did enable CFNetwork diagnostic using CFNETWORK_DIAGNOSTICS and found one difference between success and failure cases. For successful cases we see log which looks like this: default 16:27:15.831193+0200 Playground-ObjC tcp_close [C7.1:2] TCP Packets: snd 0.000s seq 1092086878:1092086879 ack 0 win 65535 len 0 [SEC] rcv 0.004s seq 3101059099:3101059100 ack 1092086879 win 65535 len 0 [S.] snd 0.000s seq 1092086879:1092086879 ack 3101059100 win 4117 len 0 [.] snd 0.002s seq 1092086879:1092087279 ack 3101059100 win 4117 len 400 [P.] rcv 0.001s seq 3101059100:3101059100 ack 1092086879 win 2058 len 0 [.] rcv 0.000s seq 3101059100:3101059100 ack 1092087279 win 2052 len 0 [.] rcv 0.015s seq 3101059100:3101059229 ack 1092087279 win 2052 len 129 [P.] ECT0 snd 0.000s seq 1092087279:1092087279 ack 3101059229 win 4113 len 0 [.] snd 0.003s seq 1092087279:1092087289 ack 3101059229 win 4113 len 10 [P.] rcv 0.002s seq 3101059229:3101059229 ack 1092087289 win 2052 len 0 [.] snd 0.017s seq 1092087289:1092087297 ack 3101059229 win 4113 len 8 [P.] snd 0.001s seq 1092087297:1092087298 ack 3101059229 win 4113 len 0 [F.] rcv 0.000s seq 3101059229:3101059229 ack 1092087297 win 2052 len 0 [.] rcv 0.001s seq 3101059229:3101059233 ack 1092087297 win 2052 len 4 [P.] ECT0 Last packet 0ms ago. So it's something related to "tcp_close" and seems to log whole TCP packets that were exchanged during connection. For failed cases such log is not present. One additional log we see potentially interesting (but were not able to confirm its meaning or relation to failed cases) comes from runningboardd: default 16:27:15.830447+0200 runningboardd Invalidating assertion 33-1364-23682 (target:[applicationorg.example.app:1364]) from originator [applicationorg.example.app:1364] So that's where we are right now and we have no idea where to dig next. We wonder if anyone else have seen such problem or can point us to any direction we could try next. Thanks much, Damian &amp;amp;amp; Maciek
3
1
1k
May ’21
Page-based layouts with TextKit 2?
In the "old" TextKit, page-based layout is accomplished by providing an array of NSTextContainers to NSLayoutManager, each with its own NSTextView. TextKit 2, NSTextLayoutManager allows only a single text container. Additionally, NSTextParagraph seems to be the only concrete NSTextElement class. Paragraphs often need to break across page boundaries. How would one implement page-based layout in TextKit 2?
4
0
3k
Jun ’21
Programmatically open popup in Safari Web Extension
I have a Safari web extension that needs the ability to open the popup when the user interacts with a modal coming from the content script. There is a native message handler that comes with the safari web extension when you first create it: import SafariServices import os.log class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { func beginRequest(with context: NSExtensionContext) { let item = context.inputItems[0] as! NSExtensionItem let message = item.userInfo?[SFExtensionMessageKey] os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@", message as! CVarArg) let response = NSExtensionItem() response.userInfo = [ SFExtensionMessageKey: [ "Response to": message ] ] print("hit") context.completeRequest(returningItems: [response], completionHandler: nil) } } I have the permissions to send a native message, I've seen some examples online where you can access the SFSafariApplication module from SafariServices and open the popover. But I can't seem to access SFSafariApplication in this module.
1
0
1.1k
Jul ’21
SharePlay and Multiple Apps
I was hoping to add support for SharePlay, but my app is not Universal, because it is around 5 years old. The macOS and iOS versions have different bundle ids, and making a universal app would be a bag of hurt (loss of reviews, migrating data in sandboxed environments and lots more). Am I correct that SharePlay will only work with a single bundle id? I was hoping by simply choosing the same activity type in each app they could connect, but I don't really see how it can given the activity type is hard coded, rather than configured in the Info.plist. If this is the case, it seems like a lost opportunity, not only for "legacy" apps like ours, but also for anyone who might want to work between apps in an app group. Presumably rather than hard coding the activity type, it could have been registered as an Info.plist configuration or entitlement, allowing apps to partake with different bundle ids, the same way it works for iCloud for example.
3
1
1.4k
Jul ’21
Minimum deployment Version for older WatchOSs and newer iOSs.
If a "Minimum Deployment Target" is updated to WatchOS7 on a product(iOS app with a companion watch app) that is already available on the App Store, watches running WatchOS6 will obviously no longer get updates. However, what is the experience for a user who has a WatchOS6 (maybe they own a Series 2) connected to an iPhone with iOS14? Will both the iPhone app and the Watch app stop getting updates? Will the Watch app stop getting updates, but the iPhone app continue receiving them and we have to manage this? Something else? Thanks in advance!
2
0
1.5k
Jul ’21
Check if Background URLSession with identifier exists
I have a working background URLSession. I know that upon creating an URLSession with the same session identifier I get a "background URLSession with identifier x already exists" message. I know that I can store the session and call .finishTasksAndInvalidate() on it if needed. My use case is that if the application terminates, and the user relaunches the application before the background task completes, I need to be able to check if a background URLSession with the same identifier exists, and if it does, restitute the application state with the same handlers (so that I can update a UIProgressView for example). I have two questions: How do I check that a background URLSession with a given identifier already exists? Does the AppDelegate completion handler still get called if the application was terminated and relaunched?
5
0
1.9k
Aug ’21