Post

Replies

Boosts

Views

Activity

Animated Custom Transitions Crash using Swift 6
When you apply an animation to a custom Transition in Swift 6, it is likely that that the app will crash with a SwiftUI.AsyncRenderer dispatch_assert_queue_fail error. Non-animated Transitions do not crash nor do animated system transitions. If you use ViewModifiers to create an AnyTransition with the .modifier(active:, identity:) static method, there is no problem. I used the example Transition in the docs for Transition to illustrate this problem. I'm using Xcode 16.2 RC and Swift 6, running iOS 18.1.1 on an iPhone 16 Pro. I've created two separate Previews that illustrate what specifically crashes the app and what doesn't as well as a workaround for this bug. func generateRandomString() -> String { let characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" return String((0..<10).compactMap { _ in characters.randomElement() }) } // MARK: Works extension AnyTransition { struct RotatingFadeTransitionModifier: ViewModifier { let opacity: CGFloat let rotation: Angle func body(content: Content) -> some View { content .opacity(opacity) .rotationEffect(rotation) } } static var rotatingFade: AnyTransition { .asymmetric( insertion: .modifier( active: RotatingFadeTransitionModifier(opacity: 0, rotation: .degrees(30)), identity: RotatingFadeTransitionModifier(opacity: 1, rotation: .zero) ), removal: .modifier( active: RotatingFadeTransitionModifier(opacity: 0, rotation: .degrees(-30)), identity: RotatingFadeTransitionModifier(opacity: 1, rotation: .zero) ) ) } } struct WorkingTransitionView: View { @State private var text: String = "some string" var body: some View { VStack(spacing: 32) { Text("system transition: \(text)") .id(text) .transition(.slide) // Gets the explicit Button animation applied instead of // the transition animation Text("animated system transition: \(text)") .id(text) .transition(.slide.animation(.bouncy(duration: 0.5))) Text("custom transition: \(text)") .id(text) .transition(.rotatingFade) Text("animated custom transition: \(text)") .id(text) .transition(.rotatingFade.animation(.bouncy( extraBounce: 0.5))) Button("animated randomize - safe") { withAnimation(.smooth(duration: 5.45, extraBounce: 0.15)) { text = generateRandomString() } } } } } // MARK: Crashes struct RotatingFadeTransition: Transition { func body(content: Content, phase: TransitionPhase) -> some View { content .opacity(phase.isIdentity ? 1.0 : 0.0) .rotationEffect(phase.rotation) } } extension TransitionPhase { fileprivate var rotation: Angle { switch self { case .willAppear: .degrees(30) case .identity: .zero case .didDisappear: .degrees(-30) } } } struct CrashingTransitionView: View { @State private var text: String = "some string" @State private var presentCustomTransitionText: Bool = false @State private var presentAnimatedCustomTransitionText: Bool = false var body: some View { VStack(spacing: 32) { Text("on 1-5 attempts generally, animated custom Transitions will crash with a SwiftUI.AsyncRenderer dispatch_assert_queue_fail") Divider() textWithSafeSystemTransition if presentCustomTransitionText { textWithCustomTransition } if presentAnimatedCustomTransitionText { textWithAnimatedCustomTransition } Divider() Text("Randomization") Button("randomize - won't crash non-animated custom transition text") { text = generateRandomString() } Button("animated randomize - will crash any custom transition text") { withAnimation(.smooth(duration: 0.45, extraBounce: 0.15)) { text = generateRandomString() } } Divider() Text("Text Presentation") Button("present non-animated custom transition text") { presentCustomTransitionText = true } Button("present animated custom transition text") { presentAnimatedCustomTransitionText = true } } } private var textWithSafeSystemTransition: some View { Text("safe, system transition: \(text)") .id(text) .transition(.slide) } private var textWithCustomTransition: some View { Text("safe text, custom transition: \(text)") .id(text) .transition(RotatingFadeTransition()) } private var textWithAnimatedCustomTransition: some View { Text("crashing text: \(text)") .id(text) .transition(RotatingFadeTransition().animation(.smooth)) } } #Preview("Working Code") { WorkingTransitionView() } #Preview("Crashing Code") { CrashingTransitionView() }
0
0
167
2w
How to determine UNLocationNotificationTrigger delivery
Hi. I'm looking to schedule a number of notifications based on the user's location and have them be triggered UNLocationNotificationTriggers. I want to know whether notifications get delivered so I can limit the number of notifications the user receives in a day. I was hoping I could determine their delivery by either the UNUserNotificationCenterDelegate's method userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) (which only knows when the user has tapped on the notification or deleted it) or by UNUserNotificationCenter.current().deliveredNotifications() (which should return the notification if it was delivered and is in the Notification Center). UNUserNotificationCenter.current().deliveredNotifications() is not returning notifications that were delivered via UNLocationNotificationTriggers. I'm assuming this is for some privacy reason? All of the UNLocationNotificationTriggers are configured with notifyOnEntry to be true, notifyOnExit to be false, and repeats to be false. They get delivered appropriately, but I can't determine if/when they get delivered to ensure the user doesn't receive too many notifications. Notifications delivered with a UNTimeIntervalNotificationTrigger are returned as expected. Is all of this by design or is there another way to determine when a notification scheduled with a UNLocationNotificationTrigger gets delivered? I'm just trying to create the best experience for my users. Thank you.
0
0
473
Mar ’24
Associated Domains stopped working after updating app Bundle ID
I updated the app bundle ID of my app in my associated domains file on my server which can be viewed using the Apple CDN at (https://app-site-association.cdn-apple.com/a/v1/myApp.app) and on my server at (https://myApp.app/.well-known/apple-app-site-association). All I did was update the app Bundle ID of my app in Xcode and likewise in the associated domains file, and now it is no longer working and I'm getting the error Application with identifier ABCDE12345.app.myApp.MyApp is not associated with domain myApp.app. This error is thrown when attempting to use the webcredentials portion of the associated domain file for logging in via Passkey. I've waited for 6 days to let the changes propagate through the CDN but the issue is persisting. Strangely enough, it has worked a few times since I changed it but almost always fails. This intermittent behavior leads me to believe it might be something up with the CDN? The only thing I changed about my appID was the domain, e.g. ABCDE12345.io.oldDomain.MyApp to ABCDE12345.app.myApp.MyApp. My file is structured as so: { "applinks": { "apps": [], "details": [ { "appID": "ABCDE12345.app.myApp.MyApp", "components": [ ... ] } ] }, "webcredentials": { "apps": [ "ABCDE12345.app.myApp.MyApp" ] } } Likewise I updated the entitlements in my app to webcredentials:myApp.app from webcredentials:oldDomain.io and similarly for the appLinks. I've tried deleting the app, restarting Xcode, clean builds, all that jazz to no avail. Any advice you have for remedying this would be greatly appreciated. This has brought my beta to a halt because no one can log in or sign up. Thank you.
1
0
1.8k
Nov ’23
Fonts occasionally lost when using MeshResource.generateText()
I'm working on an iOS project that is almost entirely SwiftUI, save for the UIViewRepresentable ARView that I'm using. I'm using RealityKit. When calling MeshResouce.generateText(), fairly often some or all Entities will fail to generate their Mesh with the proper font and will instead render with SF Pro Regular. The font size is not lost, nor any other attributes of the entity. The same data model that generates the entity also provides for a 2D representation of the model, in which the font is never lost. If an entity is generated during makeUIView() of the ARView or during onAppear() of its parent view, the font will never be lost. The font is only lost when the entity is generated in response to user input. Results are unfazed by using .ttf vs .otf for the font files. Very often (maybe always?), once one entity fails to render with its provided font, the subsequently generated entities will also fail to render with their font. I have successfully rendered an Entity then rerendered it and it has lost its font. Possibly related, generating text entities always throws the error CoreText performance note: Client called CTFontCreateWithName() using name "CUSTOM FONT NAME" and got font with PostScript name "CUSTOMFONT-NAME". For best performance, only use PostScript names when calling this API. This error will not be thrown if the first text entity (and therefore all subsequent entities) fails to render properly. If a single text entity gets generated successfully, then subsequent failing entities are more likely to also throw the error. Also always get error warning: using linearization / solving fallback when starting AR Session, but it doesn't seem to be related . Also often (always?) get error 2023-03-27 15:10:30.938146-0700 appName[38594:50629667] [Technique] ARWorldTrackingTechnique <0x15b8d0570>: World tracking performance is being affected by resource constraints [25] Also often (always?) get error 2023-03-27 15:10:30.060163-0700 appName[38594:50629490] [TraitCollection] Class CKBrowserSwitcherViewController overrides the -traitCollection getter, which is not supported. If you're trying to override traits, you must use the appropriate API. I don't know if any of those other errors are related but I figured I should include them. This has been happening intermittently for a long time and with a number of different fonts. I created a very simple version of this in a separate project that will eventually reproduce the error (if you have enough patience). You'll just need to add a non-Apple font to the project. It should render in the provided font sometimes, but when you rerun the project, or if you add the entity enough times, it should fail. It's more likely to fail with the first entity than with subsequent entities, so running the project repeatedly is the most efficient way to reproduce the bug. import SwiftUI import RealityKit class MockRenderQueue: ObservableObject { @Published var renderActions: [(_ arView: ARView, _ cameraAnchor: AnchorEntity) -> Void] = [] } struct ContentView : View { @StateObject var mockRenderQueue = MockRenderQueue() var body: some View { ZStack(alignment: .bottom) { ARViewContainer(renderQueue: mockRenderQueue).edgesIgnoringSafeArea(.all) Button(action: { mockRenderQueue.renderActions.append( addTextEntity ) }) { ZStack { RoundedRectangle(cornerRadius: 20) .frame(height: 48) Text("Add Text Entity") .bold() .foregroundColor(.white) } }.padding() } } func addTextEntity(to arView: ARView, cameraAnchor: AnchorEntity) { let fontName = "Font-Name" // Put your font name here guard let customFont = UIFont(name: fontName, size: 0.1) else { print("Error: Could not find font") return } // Make text Entity let textMesh = MeshResource.generateText("hello world", extrusionDepth: 0.001, font: customFont) let textEntity = ModelEntity(mesh: textMesh, materials: [UnlitMaterial(color: .black)]) // Make an anchor and position it 1m back and centered, facing the user let anchorEntity = AnchorEntity() anchorEntity.look(at: [0,0,0], from: [textMesh.bounds.extents.x / -2,0,-1], relativeTo: cameraAnchor) anchorEntity.transform.rotation *= simd_quatf(angle: .pi, axis: [0,1,0]) // Add TextEntity to anchor anchorEntity.addChild(textEntity) // Add the anchor to the camera anchor cameraAnchor.addChild(anchorEntity) } } struct ARViewContainer: UIViewRepresentable { @ObservedObject var renderQueue: MockRenderQueue @State private var cameraAnchor = AnchorEntity(.camera) func makeUIView(context: Context) -> ARView { let arView = ARView(frame: .zero) arView.scene.addAnchor(cameraAnchor) return arView } func updateUIView(_ arView: ARView, context: Context) { for renderAction in renderQueue.renderActions { renderAction(arView, cameraAnchor) } } } I've tried a handful of different implementations, exposing the ARView through a Coordinator, as a singleton, and other things and I just can't break this bug. Does anyone else have this problem? It is a significant detraction from the user experience and I really need to find out how to fix this. Thank you in advance.
0
0
1.1k
Mar ’23
How do I get MeshResource.generateText() to anchor to something other than the camera using RealityKit and SwiftUI?
I'm using RealityKit and SwiftUI to place 3DText on iOS but I can't get the text to anchor to a position. I stripped the project down to the bare essentials below and it still doesn't work. The box will anchor and stay in one place as I walk around but the text will follow above my device wherever I move. This is driving me crazy because the box works totally as expected but the text just does not. I have tried so many different iterations of the code below to no avail. I was wondering if anyone else was having this problem or if it was just me, potentially a bug? Is there something else I should try? import SwiftUI import RealityKit struct ContentView : View { var body: some View { return ARViewContainer().edgesIgnoringSafeArea(.all) } } struct ARViewContainer: UIViewRepresentable { func makeUIView(context: Context) -> ARView { let arView = ARView(frame: .zero) let anchor = AnchorEntity() anchor.position = simd_make_float3(0, -0.5, -1) let textEntity = ModelEntity(mesh: .generateText("Hello there", extrusionDepth: 0.4, font: .boldSystemFont(ofSize: 8), containerFrame: .zero, alignment: .center, lineBreakMode: .byWordWrapping)) let boxEntity = ModelEntity(mesh: .generateBox(size: 0.2)) anchor.addChild(textEntity) anchor.addChild(boxEntity) arView.scene.anchors.append(anchor) return arView } func updateUIView(_ uiView: ARView, context: Context) {} }
3
0
2.3k
Feb ’22
For APNS, how do I fix “unable to get local issuer certificate” error on Raspberry Pi when program works on Mac?
I'm trying to send a push notification through a python script that works on my Mac but when ran on my Raspberry Pi the program throws the error httpcore.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1122) I've tried adding the GeoTrust and the new AAACertificateServices certs to the Pi, but maybe I did something wrong there. Certs perpetually confuse me so I would really appreciate the help. I'm using Token-based authentication so I'm a bit confused as to what certs the errors are referring to in the first place if not the GeoTrust... Running on a Raspberry Pi 3 Model B with Debian. Also, running openssl s_client -connect api.sandbox.push.apple.com:443 came back as successfully verified so I'm real confused. The whole Traceback is: Traceback (most recent call last): File "/home/jake/.local/lib/python3.9/site-packages/httpx/_exceptions.py", line 326, in map_exceptions yield File "/home/jake/.local/lib/python3.9/site-packages/httpx/_client.py", line 861, in _send_single_request (status_code, headers, stream, ext) = transport.request( File "/home/jake/.local/lib/python3.9/site-packages/httpcore/_sync/connection_pool.py", line 218, in request response = connection.request( File "/home/jake/.local/lib/python3.9/site-packages/httpcore/_sync/connection.py", line 93, in request self.socket = self._open_socket(timeout) File "/home/jake/.local/lib/python3.9/site-packages/httpcore/_sync/connection.py", line 119, in _open_socket return self.backend.open_tcp_stream( File "/home/jake/.local/lib/python3.9/site-packages/httpcore/_backends/sync.py", line 143, in open_tcp_stream return SyncSocketStream(sock=sock) File "/usr/local/opt/python-3.9.0/lib/python3.9/contextlib.py", line 135, in __exit__ self.gen.throw(type, value, traceback) File "/home/jake/.local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions raise to_exc(exc) from None httpcore.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1122) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/jake/Programming/Security/MQTT/NotificationServer.py", line 73, in module sendAlarmNotification() File "/home/jake/Programming/Security/MQTT/NotificationServer.py", line 66, in sendAlarmNotification r = client.post('{}/3/device/{}'.format(server, deviceToken), json=notification, headers=headers) File "/home/jake/.local/lib/python3.9/site-packages/httpx/_client.py", line 992, in post return self.request( File "/home/jake/.local/lib/python3.9/site-packages/httpx/_client.py", line 733, in request return self.send( File "/home/jake/.local/lib/python3.9/site-packages/httpx/_client.py", line 767, in send response = self._send_handling_auth( File "/home/jake/.local/lib/python3.9/site-packages/httpx/_client.py", line 805, in _send_handling_auth response = self._send_handling_redirects( File "/home/jake/.local/lib/python3.9/site-packages/httpx/_client.py", line 837, in _send_handling_redirects response = self._send_single_request(request, timeout) File "/home/jake/.local/lib/python3.9/site-packages/httpx/_client.py", line 861, in _send_single_request (status_code, headers, stream, ext) = transport.request( File "/usr/local/opt/python-3.9.0/lib/python3.9/contextlib.py", line 135, in __exit__ self.gen.throw(type, value, traceback) File "/home/jake/.local/lib/python3.9/site-packages/httpx/_exceptions.py", line 343, in map_exceptions raise mapped_exc(message, **kwargs) from exc type: ignore httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1122) My code is import httpx import time from jwcrypto import jwt, jwk devServer = "https://api.sandbox.push.apple.com:443" prodServer = "https://api.push.apple.com:443" server = devServer pemFilePath = "pushCerts/PushNotificationAuthKey_********.p8" This generates an auth token with the current time, using our pem files def generateAuthToken(): issueTime = int(time.time()) token = jwt.JWT( header={ "alg" : "ES256", "kid" : "******"}, claims={ "iss": "******", "iat": issueTime} ) with open(pemFilePath, "rb") as pemfile: key = jwk.JWK.from_pem(pemfile.read()) token.make_signed_token(key) return token.serialize() deviceToken = "long device token" authToken = 'bearer ' + generateAuthToken() pushType = 'alert' expiration = '3600' priority = '10' topic = 'com.MyName.MyAppName' headers = { 'authorization' : authToken, 'apns-push-type' : pushType, 'apns-expiration' : expiration, 'apns-priority' : priority, 'apns-topic' : topic }
0
0
1.8k
Mar ’21
duplicate symbol _main in
I'm very new to Xcode and am trying to use it to write and build C code. I made a project and got everything to work (it'll run Hello World and all that) but once I add a second file to the project (so that I don't have to create a whole new workspace and project and such for every new file I want to work on) the build fails and I get this error:Apple Mach-O Linker (Id) Error Linker command failed with exit code 1 (use -v to see invocation)I don't know what any of that means. Once I get to the error it says all this:duplicate symbol _main in: /Users/JacobSax/Library/Developer/Xcode/DerivedData/C_Programming-ezejclzfpncidecllfwsjhptguwi/Build/Intermediates.noindex/C Programming.build/Debug/C Programming.build/Objects-normal/x86_64/Program 2.o /Users/JacobSax/Library/Developer/Xcode/DerivedData/C_Programming-ezejclzfpncidecllfwsjhptguwi/Build/Intermediates.noindex/C Programming.build/Debug/C Programming.build/Objects-normal/x86_64/Program 3.old: 1 duplicate symbol for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)I just want to be able to have multiple files in my project so I don't have to make a new workspace or project whenever I'm writing code. Forgive me for my lack of knowledge. Thanks.
2
0
12k
May ’18