Swift is a powerful and intuitive programming language for Apple platforms and beyond.

Posts under Swift tag

200 Posts

Post

Replies

Boosts

Views

Activity

Programming Languages Resources
This topic area is about the programming languages themselves, not about any specific API or tool. If you have an API question, go to the top level and look for a subtopic for that API. If you have a question about Apple developer tools, start in the Developer Tools & Services topic. For Swift questions: If your question is about the SwiftUI framework, start in UI Frameworks > SwiftUI. If your question is specific to the Swift Playground app, ask over in Developer Tools & Services > Swift Playground If you’re interested in the Swift open source effort — that includes the evolution of the language, the open source tools and libraries, and Swift on non-Apple platforms — check out Swift Forums If your question is about the Swift language, that’s on topic for Programming Languages > Swift, but you might have more luck asking it in Swift Forums > Using Swift. General: Forums topic: Programming Languages Swift: Forums subtopic: Programming Languages > Swift Forums tags: Swift Developer > Swift website Swift Programming Language website The Swift Programming Language documentation Swift Forums website, and specifically Swift Forums > Using Swift Swift Package Index website Concurrency Resources, which covers Swift concurrency How to think properly about binding memory Swift Forums thread Other: Forums subtopic: Programming Languages > Generic Forums tags: Objective-C Programming with Objective-C archived documentation Objective-C Runtime documentation Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com"
0
0
1.8k
Oct ’25
SCNTechnique clearColor Always Shows sceneBackground When Passes Share Depth Buffer
Problem Description I'm encountering an issue with SCNTechnique where the clearColor setting is being ignored when multiple passes share the same depth buffer. The clear color always appears as the scene background, regardless of what value I set. The minimal project for reproducing the issue: https://www.dropbox.com/scl/fi/30mx06xunh75wgl3t4sbd/SCNTechniqueCustomSymbols.zip?rlkey=yuehjtk7xh2pmdbetv2r8t2lx&st=b9uobpkp&dl=0 Problem Details In my SCNTechnique configuration, I have two passes that need to share the same depth buffer for proper occlusion handling: "passes": [ "box1_pass": [ "draw": "DRAW_SCENE", "includeCategoryMask": 1, "colorStates": [ "clear": true, "clearColor": "0 0 0 0" // Expecting transparent black ], "depthStates": [ "clear": true, "enableWrite": true ], "outputs": [ "depth": "box1_depth", "color": "box1_color" ], ], "box2_pass": [ "draw": "DRAW_SCENE", "includeCategoryMask": 2, "colorStates": [ "clear": true, "clearColor": "0 0 0 0" // Also expecting transparent black ], "depthStates": [ "clear": false, "enableWrite": false ], "outputs": [ "depth": "box1_depth", // Sharing the same depth buffer "color": "box2_color", ], ], "final_quad": [ "draw": "DRAW_QUAD", "metalVertexShader": "myVertexShader", "metalFragmentShader": "myFragmentShader", "inputs": [ "box1_color": "box1_color", "box2_color": "box2_color", ], "outputs": [ "color": "COLOR" ] ] ] And the metal shader used to display box1_color and box2_color with splitting: fragment half4 myFragmentShader(VertexOut in [[stage_in]], texture2d<half, access::sample> box1_color [[texture(0)]], texture2d<half, access::sample> box2_color [[texture(1)]]) { half4 color1 = box1_color.sample(s, in.texcoord); half4 color2 = box2_color.sample(s, in.texcoord); if (in.texcoord.x < 0.5) { return color1; } return color2; }; Expected Behavior Both passes should clear their color targets to transparent black (0, 0, 0, 0) The depth buffer should be shared between passes for proper occlusion Actual Behavior Both box1_color and box2_color targets contain the scene background instead of being cleared to transparent (see attached image) This happens even when I explicitly set clearColor: "0 0 0 0" for both passes Setting scene.background.contents = UIColor.clear makes the clearColor work as expected, but I need to keep the scene background for other purposes What I've Tried Setting different clearColor values - all are ignored when sharing depth buffer Using DRAW_NODE instead of DRAW_SCENE - didn't solve the issue Creating a separate pass to capture the background - the background still appears in the other passes Various combinations of clear flags and render orders Environment iOS/macOS, running with "My Mac (Designed for iPad)" Xcode 16.2 Question Is this a known limitation of SceneKit when passes share a depth buffer? Is there a workaround to achieve truly transparent clear colors while maintaining a shared depth buffer for occlusion testing? The core issue seems to be that SceneKit automatically renders the scene background in every DRAW_SCENE pass when a shared depth buffer is detected, overriding any clearColor settings. Any insights or workarounds would be greatly appreciated. Thank you!
1
0
478
8h
SwiftUI View Not Initialized on Background Relaunch (CoreBluetooth / Cold Start?)
I have a question regarding cold start and pre-warming behavior on iOS. I’m developing a SwiftUI app that continuously receives data from a BLE device in the background. We’ve observed that after the BLE stream stops, the OS often terminates our app. Later, when the sensor comes back into range, iOS appears to relaunch (or reinitialize) the app. In our app, we use a WindowGroup like this: WindowGroup { AppView(store: store) } We’ve placed our BLE reconnection logic inside a .task modifier in AppView. What’s confusing is this: Most of the time, when the app is relaunched, AppView is created and the .task runs as expected. However, in about 1 out of 10 cases, AppView is not created at all, so the .task does not execute. I’m trying to understand: Under what conditions does iOS relaunch an app without fully initializing the SwiftUI view hierarchy? Is this related to pre-warming or background relaunch mechanisms (e.g., CoreBluetooth state restoration)? What determines whether the WindowGroup and root view are actually instantiated? Any insight into the system’s relaunch behavior or lifecycle in this scenario would be greatly appreciated.
1
0
52
19h
NEURLFilter Not Blocking urls
Hi I tried to follow this guide https://developer.apple.com/documentation/networkextension/filtering-traffic-by-url I downloaded the sample app and put our pir service server address in the app. The service is already running and the app is connected to the pir service but the url is still not blocked. We tried to block example.com. Is there anything that we need to do in iOS code? This is the sample when there's dataset This is the sample when there's no dataset
1
0
36
1d
iOS crash: EXC_BAD_ACCESS in iOS 26+ when mouting/dismounting WebView
I'm experiencing a native crash on iOS 26+ with WebKit with title: EXC_BAD_ACCESS (KERN_INVALID_ADDRESS). The stack trace points to UIKit/WebKit animation and context menu handling, and the crash occurs while a WebView is presented or dismissed. Crashed: com.apple.main-thread 0 WebKit 0x7bcfac <redacted> + 12 1 WebKit 0xaf5c34 <redacted> + 84 2 UIKitCore 0x34ebdc -[_UIContextMenuAnimator performAllCompletions] + 248 3 UIKitCore 0x7f997c block_destroy_helper.72 + 1840 4 UIKitCore 0x7fb4b4 objectdestroy.36Tm + 88 5 UIKitCore 0x7ad354 objectdestroy.3Tm + 30500 6 UIKitCore 0x5c0e5c __swift_memcpy192_8 + 4352 7 UIKitCore 0x21944 block_copy_helper.374 + 40 8 UIKitCore 0x1dc174 -[_UIGroupCompletion _performAllCompletions] + 160 9 UIKitCore 0x35d0c4 -[_UIGravityWellEffectBody .cxx_destruct] + 180 10 UIKitCore 0x215018 -[UIScrollView _contentLayoutGuideIfExists] + 72 11 UIKitCore 0x943e4 NSStringFromUIEdgeInsets + 304 12 UIKitCore 0x94348 NSStringFromUIEdgeInsets + 148 13 UIKitCore 0x8f598 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ + 36 14 UIKitCore 0x1995d8c -[UIViewAnimationBlockDelegate _sendDeferredCompletion:] + 92 15 libdispatch.dylib 0x1adc _dispatch_call_block_and_release + 32 16 libdispatch.dylib 0x1b7fc _dispatch_client_callout + 16 17 libdispatch.dylib 0x38b10 _dispatch_main_queue_drain.cold.5 + 812 18 libdispatch.dylib 0x10ec8 _dispatch_main_queue_drain + 180 19 libdispatch.dylib 0x10e04 _dispatch_main_queue_callback_4CF + 44 20 CoreFoundation 0x6a2b4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 21 CoreFoundation 0x1db3c __CFRunLoopRun + 1944 22 CoreFoundation 0x1ca6c _CFRunLoopRunSpecificWithOptions + 532 23 GraphicsServices 0x1498 GSEventRunModal + 120 24 UIKitCore 0x9ddf8 -[UIApplication _run] + 792 25 UIKitCore 0x46e54 UIApplicationMain + 336 26 - 0xedf88 main + 24 (AppDelegate.swift:24) 27 ??? 0x196686e28 (Missing)
0
0
23
1d
Static library produced by Xcode 26 causes link error on Xcode 16
When a static library is built with Xcode 26 (with deployment target set to iOS 13) and then linked into an app project compiled with Xcode 16, the build process fails with the following linker error: Undefined symbols for architecture arm64: "_swift_coroFrameAlloc" This occurs even though both the static library and the app project have their deployment targets set to iOS 13.0. The static library works on Xcode 26, but fails to link on Xcode 16. This issue shows up with certain Swift syntax. For example, in my case, using a property getter and setter caused the compiler to emit a reference to _swift_coroFrameAlloc, which in turn triggered the issue. This issue prevents us from distributing pre-built static libraries compiled with Xcode 26 to teammates who are still using Xcode 16. I’ve filed feedback for this issue (FB21130604). Is there any way to work around it? For example, by adding specific Build Settings or something similar? A demo project is available here: https://github.com/Naituw/SwiftLibraryDeploymentTargetIssue The demo project includes: StaticLibraryProject: A simple Swift static library with property getter setter usage AppProject: An iOS app that links against the static library verify_compatibility.sh: An automated script to reproduce the issue Method 1: Manual Build and Verification Open StaticLibraryProject/StaticLibraryProject.xcodeproj in Xcode 26 Build the StaticLibraryProject for iOS device (Release configuration) Locate the built libStaticLibraryProject.a in the build products directory Copy libStaticLibraryProject.a to AppProject/AppProject/ directory Open AppProject/AppProject.xcodeproj in Xcode 16 Build the AppProject for iOS device Method 2: Automated Script Edit verify_compatibility.sh to configure the paths to your Xcode installations: Set XCODE_26_PATH to your Xcode 26 installation path (e.g., /Applications/Xcode.app) Set XCODE_16_PATH to your Xcode 16 installation path (e.g., /Applications/Xcode16.app) Run the script: ./verify_compatibility.sh
4
0
452
1d
DJI Osmo Mobile 8 — DockKit motor control APIs not working (setAngularVelocity, setOrientation)
I'm developing an iOS app that uses Apple's DockKit framework to control gimbals. I've tested with the Insta360 Flow 2 Pro and the DJI Osmo Mobile 8. The Flow 2 Pro supports all DockKit motor control APIs — setAngularVelocity, setOrientation, setLimits — which lets my app do manual pan/tilt control via a virtual joystick. The Osmo Mobile 8 (model DS308, firmware 1.0.0) connects fine via DockKit and reports as docked, but every motor control API fails with "The device doesn't support the requested operation": setAngularVelocity — fails setOrientation(relative: true) — fails setLimits — fails The only thing that works is Apple's system tracking (setSystemTrackingEnabled(true)) for automatic face/body following. This means there's no way for third-party apps to do manual gimbal control (pan/tilt via joystick) on the Osmo 8 through DockKit — only automatic tracking works. Questions: Is anyone else seeing the same limitation with the Osmo 8 and DockKit? Has DJI confirmed whether manual motor control via DockKit is intentionally unsupported, or is this a firmware issue that might be addressed in an update? Does the DJI Mimo app use DockKit for its tracking, or does it use a proprietary Bluetooth protocol? Running iOS 26.4 on iPhone 15 Pro. Happy to share more technical details if helpful.
1
0
144
2d
HomeKit support on MacOS
I am currently developing an app for MacOS that needs to control HomeKit devices like lights. However, it seems like MacOS is supported on the official documentation, but not when I try to create an app ID on developer.apple.com. On the link https://developer.apple.com/apple-home/, MacOS is clearly showed as supported for MacOS. But when I try to create an app ID, it shows that it is only compatible for iOS, VisionOS and WatchOS. Could this be clarified? Best regards, orangeidle25
2
0
69
3d
NSFileWrapper data loss bug in Foundation on macOS Tahoe 26.4.1
There appears to be a data loss bug in NSFileWrapper on macOS 26.4. It may have been around longer but I just never noticed ... So I write a RTFD file wrapper: NSFileWrapper *rtfd = [attributedString RTFDFileWrapperFromRange:NSMakeRange(0, attributedString.length) documentAttributes:@{NSDocumentTypeDocumentAttribute:NSRTFDTextDocumentType}]; Now IF I use -writeToURL:options:originalContentsURL:error: without using the NSFileWrapperWritingAtomic option and I pass in an existing URL, the followings happens: -The method returns NO and populates the NSError with NSFileWriteFileExistsError, as expected. This is what I want. -BUT the existing file is nuked. It just disappears. Foundation kills it. Poof. Another thing I gotta workaround. Getting pretty ridiculous, I must say. Just my lucky day I guess. It would be wonderful if I could work on my own features and fixing my own bugs.
5
0
226
3d
Does Xcode / Swift Package Manager support custom Git authentication flows for private package distribution?
Hi, We are evaluating Swift Package Manager for distributing private packages to external customers. Our use case requires enterprise-grade authentication beyond standard username/password, personal access token, or SSH key based authentication. Our current authentication model relies on request signing / IAM-based authorization rather than standard Git credentials. From what we can tell, Swift Package Manager does not appear to expose a built-in mechanism for custom authentication hooks during package resolution. Because of that, we started exploring whether a Git-based workaround might be possible, such as: using a custom Git URL scheme handling that scheme through a Git remote helper using a Git credential helper or related Git configuration for authentication We tried a proof of concept along these lines, but Xcode did not seem to recognize or resolve the package correctly. We are trying to understand what is officially supported and what is not. Our questions are: Does Xcode / Swift Package Manager support package dependencies that rely on custom Git URL schemes? During package resolution, does Xcode honor system Git configuration for remote helpers and credential helpers? Is there any difference in support between: adding the package through the Xcode UI resolving through swift package resolve resolving through xcodebuild For private package distribution, is there any Apple-recommended approach when authentication requires request signing or a custom IAM-based flow instead of standard Git credentials? If custom Git authentication is not supported, should we assume the recommended path is to place an authenticated proxy or gateway in front of a standard Git or HTTPS endpoint instead? We are mainly trying to determine whether this direction is fundamentally unsupported in Xcode / SwiftPM, or whether there is a supported way to integrate enterprise authentication into package resolution. Any guidance would be appreciated. Thanks!
0
0
47
4d
FileManager displayName(atPath:) no effect?
I logged in to macOS with my localization language. try to perform following code. but always get "Documents". What do I miss? Apple Swift version 5.2.4 macOS 10.15.6 Xcode 11.6 code let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) if paths.count &gt; 0 {     let doc = FileManager().displayName(atPath: paths[0])     print(doc) } result Documents
4
0
1k
4d
How do I identify where my bugs come from
I'm working on an app, and currently, 2 things dont work: account creation and notifications. I want to find the root of why these errors are occurring, and I want to know if these errors are coming from Firebase, certain settings in Xcode not being checked, or my actual written code not being typed correctly. I've tried to run my issue through ChatGPT many times to pretty much no success, so any help on what to do so I can clear certain areas and make sure the bugs aren't from certain spots, and help me narrow down the issue would be great. Otherwise, if there are other guides or threads I can be linked to, and help me fully break down the issue, that would be great. Thank you for your time reading, and I hope I can get some advice.
0
0
33
4d
Navigation bar flickers when pushing to a different screen
Hi everyone, I’m building a SwiftUI app using NavigationStack and running into a weird nav bar issue. For the setup I have a 'home' screen with a vertical ScrollView and a large edge-to-edge header that extends under the top safe area (using .ignoresSafeArea(edges: .top)). I also have a 'detail' screen with a similar immersive layout, where the header/poster image sits at the top and the ScrollView also extends under the top area. I’m using the native navigation bar on both screens and default back button, not a custom nav bar, and I’m not manually configuring UINavigationBarAppearance, I'm just relying on SwiftUI’s default/automatic toolbar behavior. The problem I’m facing is when I push from home to the detail screen, the top nav area briefly flickers and shows the system navigation bar/material background (white in light mode, black in dark mode). It’s clearly the system material, not the poster/image underneath. The screen initially renders with that nav bar state (white/dark), and only after I start scrolling does it correct itself and visually align with the header/background behind it. What I'm thinking is that maybe the detail screen initially renders with systemBackground, so the nav bar uses its default (standard) appearance on the first frame, and only after layout/interaction, once the image-derived background settles, does it switch to the correct scroll-edge/transparent style. One important thing, if I hide the nav bar on the detail screen using .toolbar(.hidden, for: .navigationBar), the issue disappears completely. So this seems specifically tied to the native nav bar’s initial render/appearance timing during the push, rather than just the layout or image loading. I’d prefer to keep the native nav bar and back button rather than implement a custom approach. Has anyone faced this issue before, or is there a correct way to structure edge-to-edge content under the nav bar so it renders properly on first push? Video of the issue: https://imgur.com/a/OYHtYbp
1
0
82
5d
On iPad with Swift Playgrounds: How to open chapter as a playground?
Note On a Mac with Xcode installed, or on an iPad with Swift Playgrounds, you can open this chapter as a playground. Playgrounds allow you to edit the code listings and see the results immediately. (Note in page 3) (I would like to open the chapter or book: Swift Programming Language in Swift Playground on iPad) https://books.apple.com/ve/book/the-swift-programming-language-swift-5-7-beta/id1002622538?l=en-GB Best regards
2
0
1.4k
5d
iPad Pro M4 giving wrong value for layerPointConverted for ultra wide angle
I am using iPad Pro M4 device to apply exposure point to the camera. While converting layerPointConverted from 0 -1 range to device size point it is giving wrong value. But if same code is used for other iPad like Gen2, it gives proper value. In both cases video gravity used is resizeAspectFill. I tried using true depth camera for M4 device but it does not work.
0
0
78
5d
Navigation bar flickers when pushing to a different screen
Hi everyone, I’m building a SwiftUI app using NavigationStack and running into a weird nav bar issue. For the setup I have a 'home' screen with a vertical ScrollView and a large edge-to-edge header that extends under the top safe area (using .ignoresSafeArea(edges: .top)). I also have a 'detail' screen with a similar immersive layout, where the header/poster image sits at the top and the ScrollView also extends under the top area. I’m using the native navigation bar on both screens and default back button, not a custom nav bar, and I’m not manually configuring UINavigationBarAppearance, I'm just relying on SwiftUI’s default/automatic toolbar behavior. The problem I’m facing is when I push from home to the detail screen, the top nav area briefly flickers and shows the system navigation bar/material background (white in light mode, black in dark mode). It’s clearly the system material, not the poster/image underneath. The screen initially renders with that nav bar state (white/dark), and only after I start scrolling does it correct itself and visually align with the header/background behind it. What I'm thinking is that maybe the detail screen initially renders with systemBackground, so the nav bar uses its default (standard) appearance on the first frame, and only after layout/interaction, once the image-derived background settles, does it switch to the correct scroll-edge/transparent style. One important thing, if I hide the nav bar on the detail screen using .toolbar(.hidden, for: .navigationBar), the issue disappears completely. So this seems specifically tied to the native nav bar’s initial render/appearance timing during the push, rather than just the layout or image loading. I’d prefer to keep the native nav bar and back button rather than implement a custom approach. Has anyone faced this issue before, or is there a correct way to structure edge-to-edge content under the nav bar so it renders properly on first push? Video of the issue: https://imgur.com/a/OYHtYbp NavigationStack { ScrollView { HeroView() } .ignoresSafeArea(edges: .top) .navigationTitle("Cinema") .toolbarTitleDisplayMode(.inlineLarge) .toolbarBackgroundVisibility(.automatic, for: .navigationBar) .navigationDestination(for: Route.self) { route in DetailView(movie: route.movie) } } var body: some View { ScrollView { HeaderPosterView() } .ignoresSafeArea(edges: .top) .navigationBarTitleDisplayMode(.inline) .toolbarBackgroundVisibility(.automatic, for: .navigationBar) } }
0
0
102
6d
Scheduled events reach threshold almost immediately on iOS 26.2
Hi, we are developing a screen time management app. The app locks the device after it was used for specified amount of time. After updating to iOS 26.2, we noticed a huge issue: the events started to fire (reach the threshold) in the DeviceActivityMonitorExtension prematurely, almost immediately after scheduling. The only solution we've found is to delete the app and reboot the device, but the effect is not lasting long and this does not always help. Before updating to iOS 26, events also used to sometimes fire prematurely, but rescheduling the event often helped. Now the rescheduling happens almost every second and the events keep reaching the threshold prematurely. Can you suggest any workarounds for this issue?
7
2
576
1w
ManipulationComponent Not Translating using indirect input
When using the new RealityKit Manipulation Component on Entities, indirect input will never translate the entity - no matter what settings are applied. Direct manipulation works as expected for both translation and rotation. Is this intended behaviour? This is different from how indirect manipulation works on Model3D. How else can we get translation from this component? visionOS 26 Beta 2 Build from macOS 26 Beta 2 and Xcode 26 Beta 2 Attached is replicable sample code, I have tried this in other projects with the same results. var body: some View { RealityView { content in // Add the initial RealityKit content if let immersiveContentEntity = try? await Entity(named: "MovieFilmReel", in: reelRCPBundle) { ManipulationComponent.configureEntity(immersiveContentEntity, allowedInputTypes: .all, collisionShapes: [ShapeResource.generateBox(width: 0.2, height: 0.2, depth: 0.2)]) immersiveContentEntity.position.y = 1 immersiveContentEntity.position.z = -0.5 var mc = ManipulationComponent() mc.releaseBehavior = .stay immersiveContentEntity.components.set(mc) content.add(immersiveContentEntity) } } }
17
5
2.6k
1w
Initial presentation of popover hangs when shown from a button in the toolbar
I have a simple reproducer here: struct ContentView: View { @State private var isOn = false @State private var isPresented = false var body: some View { NavigationStack { Color.blue .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Press here") { isPresented = true } .popover(isPresented: $isPresented) { Color.green .frame(idealWidth: 400, idealHeight: 500) .presentationCompactAdaptation(.popover) } } } } } } When I tap on the button in the toolbar you can see there is a hang then the popover shows. Then every time after there is no longer a hang so this seems like a bug. Any ideas? I'm using Xcode 26.3 and a iPad Pro 13-inch (M5) (26.4) simulator.
3
3
177
1w
iOS 26 TabBar Remove Selected Capsule
I have subclassed UITabBar and created a custom look and feel for it. On iOS 18, the tab bar appears as expected. On iOS 26, however, a default Liquid Glass-style capsule selection indicator appears behind the selected tab item. I tried using UITabBarAppearance, including selectionIndicatorTintColor = .clear and selectionIndicatorImage = nil / empty image, but the capsule-style selected background still appears. Is this selection treatment part of the new default system rendering in iOS 26, and if so, is there any supported way to remove or disable it while still using UITabBar?
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
240
1w
Programming Languages Resources
This topic area is about the programming languages themselves, not about any specific API or tool. If you have an API question, go to the top level and look for a subtopic for that API. If you have a question about Apple developer tools, start in the Developer Tools & Services topic. For Swift questions: If your question is about the SwiftUI framework, start in UI Frameworks > SwiftUI. If your question is specific to the Swift Playground app, ask over in Developer Tools & Services > Swift Playground If you’re interested in the Swift open source effort — that includes the evolution of the language, the open source tools and libraries, and Swift on non-Apple platforms — check out Swift Forums If your question is about the Swift language, that’s on topic for Programming Languages > Swift, but you might have more luck asking it in Swift Forums > Using Swift. General: Forums topic: Programming Languages Swift: Forums subtopic: Programming Languages > Swift Forums tags: Swift Developer > Swift website Swift Programming Language website The Swift Programming Language documentation Swift Forums website, and specifically Swift Forums > Using Swift Swift Package Index website Concurrency Resources, which covers Swift concurrency How to think properly about binding memory Swift Forums thread Other: Forums subtopic: Programming Languages > Generic Forums tags: Objective-C Programming with Objective-C archived documentation Objective-C Runtime documentation Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com"
Replies
0
Boosts
0
Views
1.8k
Activity
Oct ’25
SCNTechnique clearColor Always Shows sceneBackground When Passes Share Depth Buffer
Problem Description I'm encountering an issue with SCNTechnique where the clearColor setting is being ignored when multiple passes share the same depth buffer. The clear color always appears as the scene background, regardless of what value I set. The minimal project for reproducing the issue: https://www.dropbox.com/scl/fi/30mx06xunh75wgl3t4sbd/SCNTechniqueCustomSymbols.zip?rlkey=yuehjtk7xh2pmdbetv2r8t2lx&st=b9uobpkp&dl=0 Problem Details In my SCNTechnique configuration, I have two passes that need to share the same depth buffer for proper occlusion handling: "passes": [ "box1_pass": [ "draw": "DRAW_SCENE", "includeCategoryMask": 1, "colorStates": [ "clear": true, "clearColor": "0 0 0 0" // Expecting transparent black ], "depthStates": [ "clear": true, "enableWrite": true ], "outputs": [ "depth": "box1_depth", "color": "box1_color" ], ], "box2_pass": [ "draw": "DRAW_SCENE", "includeCategoryMask": 2, "colorStates": [ "clear": true, "clearColor": "0 0 0 0" // Also expecting transparent black ], "depthStates": [ "clear": false, "enableWrite": false ], "outputs": [ "depth": "box1_depth", // Sharing the same depth buffer "color": "box2_color", ], ], "final_quad": [ "draw": "DRAW_QUAD", "metalVertexShader": "myVertexShader", "metalFragmentShader": "myFragmentShader", "inputs": [ "box1_color": "box1_color", "box2_color": "box2_color", ], "outputs": [ "color": "COLOR" ] ] ] And the metal shader used to display box1_color and box2_color with splitting: fragment half4 myFragmentShader(VertexOut in [[stage_in]], texture2d<half, access::sample> box1_color [[texture(0)]], texture2d<half, access::sample> box2_color [[texture(1)]]) { half4 color1 = box1_color.sample(s, in.texcoord); half4 color2 = box2_color.sample(s, in.texcoord); if (in.texcoord.x < 0.5) { return color1; } return color2; }; Expected Behavior Both passes should clear their color targets to transparent black (0, 0, 0, 0) The depth buffer should be shared between passes for proper occlusion Actual Behavior Both box1_color and box2_color targets contain the scene background instead of being cleared to transparent (see attached image) This happens even when I explicitly set clearColor: "0 0 0 0" for both passes Setting scene.background.contents = UIColor.clear makes the clearColor work as expected, but I need to keep the scene background for other purposes What I've Tried Setting different clearColor values - all are ignored when sharing depth buffer Using DRAW_NODE instead of DRAW_SCENE - didn't solve the issue Creating a separate pass to capture the background - the background still appears in the other passes Various combinations of clear flags and render orders Environment iOS/macOS, running with "My Mac (Designed for iPad)" Xcode 16.2 Question Is this a known limitation of SceneKit when passes share a depth buffer? Is there a workaround to achieve truly transparent clear colors while maintaining a shared depth buffer for occlusion testing? The core issue seems to be that SceneKit automatically renders the scene background in every DRAW_SCENE pass when a shared depth buffer is detected, overriding any clearColor settings. Any insights or workarounds would be greatly appreciated. Thank you!
Replies
1
Boosts
0
Views
478
Activity
8h
SwiftUI View Not Initialized on Background Relaunch (CoreBluetooth / Cold Start?)
I have a question regarding cold start and pre-warming behavior on iOS. I’m developing a SwiftUI app that continuously receives data from a BLE device in the background. We’ve observed that after the BLE stream stops, the OS often terminates our app. Later, when the sensor comes back into range, iOS appears to relaunch (or reinitialize) the app. In our app, we use a WindowGroup like this: WindowGroup { AppView(store: store) } We’ve placed our BLE reconnection logic inside a .task modifier in AppView. What’s confusing is this: Most of the time, when the app is relaunched, AppView is created and the .task runs as expected. However, in about 1 out of 10 cases, AppView is not created at all, so the .task does not execute. I’m trying to understand: Under what conditions does iOS relaunch an app without fully initializing the SwiftUI view hierarchy? Is this related to pre-warming or background relaunch mechanisms (e.g., CoreBluetooth state restoration)? What determines whether the WindowGroup and root view are actually instantiated? Any insight into the system’s relaunch behavior or lifecycle in this scenario would be greatly appreciated.
Replies
1
Boosts
0
Views
52
Activity
19h
NEURLFilter Not Blocking urls
Hi I tried to follow this guide https://developer.apple.com/documentation/networkextension/filtering-traffic-by-url I downloaded the sample app and put our pir service server address in the app. The service is already running and the app is connected to the pir service but the url is still not blocked. We tried to block example.com. Is there anything that we need to do in iOS code? This is the sample when there's dataset This is the sample when there's no dataset
Replies
1
Boosts
0
Views
36
Activity
1d
iOS crash: EXC_BAD_ACCESS in iOS 26+ when mouting/dismounting WebView
I'm experiencing a native crash on iOS 26+ with WebKit with title: EXC_BAD_ACCESS (KERN_INVALID_ADDRESS). The stack trace points to UIKit/WebKit animation and context menu handling, and the crash occurs while a WebView is presented or dismissed. Crashed: com.apple.main-thread 0 WebKit 0x7bcfac <redacted> + 12 1 WebKit 0xaf5c34 <redacted> + 84 2 UIKitCore 0x34ebdc -[_UIContextMenuAnimator performAllCompletions] + 248 3 UIKitCore 0x7f997c block_destroy_helper.72 + 1840 4 UIKitCore 0x7fb4b4 objectdestroy.36Tm + 88 5 UIKitCore 0x7ad354 objectdestroy.3Tm + 30500 6 UIKitCore 0x5c0e5c __swift_memcpy192_8 + 4352 7 UIKitCore 0x21944 block_copy_helper.374 + 40 8 UIKitCore 0x1dc174 -[_UIGroupCompletion _performAllCompletions] + 160 9 UIKitCore 0x35d0c4 -[_UIGravityWellEffectBody .cxx_destruct] + 180 10 UIKitCore 0x215018 -[UIScrollView _contentLayoutGuideIfExists] + 72 11 UIKitCore 0x943e4 NSStringFromUIEdgeInsets + 304 12 UIKitCore 0x94348 NSStringFromUIEdgeInsets + 148 13 UIKitCore 0x8f598 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ + 36 14 UIKitCore 0x1995d8c -[UIViewAnimationBlockDelegate _sendDeferredCompletion:] + 92 15 libdispatch.dylib 0x1adc _dispatch_call_block_and_release + 32 16 libdispatch.dylib 0x1b7fc _dispatch_client_callout + 16 17 libdispatch.dylib 0x38b10 _dispatch_main_queue_drain.cold.5 + 812 18 libdispatch.dylib 0x10ec8 _dispatch_main_queue_drain + 180 19 libdispatch.dylib 0x10e04 _dispatch_main_queue_callback_4CF + 44 20 CoreFoundation 0x6a2b4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 21 CoreFoundation 0x1db3c __CFRunLoopRun + 1944 22 CoreFoundation 0x1ca6c _CFRunLoopRunSpecificWithOptions + 532 23 GraphicsServices 0x1498 GSEventRunModal + 120 24 UIKitCore 0x9ddf8 -[UIApplication _run] + 792 25 UIKitCore 0x46e54 UIApplicationMain + 336 26 - 0xedf88 main + 24 (AppDelegate.swift:24) 27 ??? 0x196686e28 (Missing)
Replies
0
Boosts
0
Views
23
Activity
1d
Static library produced by Xcode 26 causes link error on Xcode 16
When a static library is built with Xcode 26 (with deployment target set to iOS 13) and then linked into an app project compiled with Xcode 16, the build process fails with the following linker error: Undefined symbols for architecture arm64: "_swift_coroFrameAlloc" This occurs even though both the static library and the app project have their deployment targets set to iOS 13.0. The static library works on Xcode 26, but fails to link on Xcode 16. This issue shows up with certain Swift syntax. For example, in my case, using a property getter and setter caused the compiler to emit a reference to _swift_coroFrameAlloc, which in turn triggered the issue. This issue prevents us from distributing pre-built static libraries compiled with Xcode 26 to teammates who are still using Xcode 16. I’ve filed feedback for this issue (FB21130604). Is there any way to work around it? For example, by adding specific Build Settings or something similar? A demo project is available here: https://github.com/Naituw/SwiftLibraryDeploymentTargetIssue The demo project includes: StaticLibraryProject: A simple Swift static library with property getter setter usage AppProject: An iOS app that links against the static library verify_compatibility.sh: An automated script to reproduce the issue Method 1: Manual Build and Verification Open StaticLibraryProject/StaticLibraryProject.xcodeproj in Xcode 26 Build the StaticLibraryProject for iOS device (Release configuration) Locate the built libStaticLibraryProject.a in the build products directory Copy libStaticLibraryProject.a to AppProject/AppProject/ directory Open AppProject/AppProject.xcodeproj in Xcode 16 Build the AppProject for iOS device Method 2: Automated Script Edit verify_compatibility.sh to configure the paths to your Xcode installations: Set XCODE_26_PATH to your Xcode 26 installation path (e.g., /Applications/Xcode.app) Set XCODE_16_PATH to your Xcode 16 installation path (e.g., /Applications/Xcode16.app) Run the script: ./verify_compatibility.sh
Replies
4
Boosts
0
Views
452
Activity
1d
DJI Osmo Mobile 8 — DockKit motor control APIs not working (setAngularVelocity, setOrientation)
I'm developing an iOS app that uses Apple's DockKit framework to control gimbals. I've tested with the Insta360 Flow 2 Pro and the DJI Osmo Mobile 8. The Flow 2 Pro supports all DockKit motor control APIs — setAngularVelocity, setOrientation, setLimits — which lets my app do manual pan/tilt control via a virtual joystick. The Osmo Mobile 8 (model DS308, firmware 1.0.0) connects fine via DockKit and reports as docked, but every motor control API fails with "The device doesn't support the requested operation": setAngularVelocity — fails setOrientation(relative: true) — fails setLimits — fails The only thing that works is Apple's system tracking (setSystemTrackingEnabled(true)) for automatic face/body following. This means there's no way for third-party apps to do manual gimbal control (pan/tilt via joystick) on the Osmo 8 through DockKit — only automatic tracking works. Questions: Is anyone else seeing the same limitation with the Osmo 8 and DockKit? Has DJI confirmed whether manual motor control via DockKit is intentionally unsupported, or is this a firmware issue that might be addressed in an update? Does the DJI Mimo app use DockKit for its tracking, or does it use a proprietary Bluetooth protocol? Running iOS 26.4 on iPhone 15 Pro. Happy to share more technical details if helpful.
Replies
1
Boosts
0
Views
144
Activity
2d
HomeKit support on MacOS
I am currently developing an app for MacOS that needs to control HomeKit devices like lights. However, it seems like MacOS is supported on the official documentation, but not when I try to create an app ID on developer.apple.com. On the link https://developer.apple.com/apple-home/, MacOS is clearly showed as supported for MacOS. But when I try to create an app ID, it shows that it is only compatible for iOS, VisionOS and WatchOS. Could this be clarified? Best regards, orangeidle25
Replies
2
Boosts
0
Views
69
Activity
3d
NSFileWrapper data loss bug in Foundation on macOS Tahoe 26.4.1
There appears to be a data loss bug in NSFileWrapper on macOS 26.4. It may have been around longer but I just never noticed ... So I write a RTFD file wrapper: NSFileWrapper *rtfd = [attributedString RTFDFileWrapperFromRange:NSMakeRange(0, attributedString.length) documentAttributes:@{NSDocumentTypeDocumentAttribute:NSRTFDTextDocumentType}]; Now IF I use -writeToURL:options:originalContentsURL:error: without using the NSFileWrapperWritingAtomic option and I pass in an existing URL, the followings happens: -The method returns NO and populates the NSError with NSFileWriteFileExistsError, as expected. This is what I want. -BUT the existing file is nuked. It just disappears. Foundation kills it. Poof. Another thing I gotta workaround. Getting pretty ridiculous, I must say. Just my lucky day I guess. It would be wonderful if I could work on my own features and fixing my own bugs.
Replies
5
Boosts
0
Views
226
Activity
3d
Does Xcode / Swift Package Manager support custom Git authentication flows for private package distribution?
Hi, We are evaluating Swift Package Manager for distributing private packages to external customers. Our use case requires enterprise-grade authentication beyond standard username/password, personal access token, or SSH key based authentication. Our current authentication model relies on request signing / IAM-based authorization rather than standard Git credentials. From what we can tell, Swift Package Manager does not appear to expose a built-in mechanism for custom authentication hooks during package resolution. Because of that, we started exploring whether a Git-based workaround might be possible, such as: using a custom Git URL scheme handling that scheme through a Git remote helper using a Git credential helper or related Git configuration for authentication We tried a proof of concept along these lines, but Xcode did not seem to recognize or resolve the package correctly. We are trying to understand what is officially supported and what is not. Our questions are: Does Xcode / Swift Package Manager support package dependencies that rely on custom Git URL schemes? During package resolution, does Xcode honor system Git configuration for remote helpers and credential helpers? Is there any difference in support between: adding the package through the Xcode UI resolving through swift package resolve resolving through xcodebuild For private package distribution, is there any Apple-recommended approach when authentication requires request signing or a custom IAM-based flow instead of standard Git credentials? If custom Git authentication is not supported, should we assume the recommended path is to place an authenticated proxy or gateway in front of a standard Git or HTTPS endpoint instead? We are mainly trying to determine whether this direction is fundamentally unsupported in Xcode / SwiftPM, or whether there is a supported way to integrate enterprise authentication into package resolution. Any guidance would be appreciated. Thanks!
Replies
0
Boosts
0
Views
47
Activity
4d
FileManager displayName(atPath:) no effect?
I logged in to macOS with my localization language. try to perform following code. but always get "Documents". What do I miss? Apple Swift version 5.2.4 macOS 10.15.6 Xcode 11.6 code let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) if paths.count &gt; 0 {     let doc = FileManager().displayName(atPath: paths[0])     print(doc) } result Documents
Replies
4
Boosts
0
Views
1k
Activity
4d
How do I identify where my bugs come from
I'm working on an app, and currently, 2 things dont work: account creation and notifications. I want to find the root of why these errors are occurring, and I want to know if these errors are coming from Firebase, certain settings in Xcode not being checked, or my actual written code not being typed correctly. I've tried to run my issue through ChatGPT many times to pretty much no success, so any help on what to do so I can clear certain areas and make sure the bugs aren't from certain spots, and help me narrow down the issue would be great. Otherwise, if there are other guides or threads I can be linked to, and help me fully break down the issue, that would be great. Thank you for your time reading, and I hope I can get some advice.
Replies
0
Boosts
0
Views
33
Activity
4d
Navigation bar flickers when pushing to a different screen
Hi everyone, I’m building a SwiftUI app using NavigationStack and running into a weird nav bar issue. For the setup I have a 'home' screen with a vertical ScrollView and a large edge-to-edge header that extends under the top safe area (using .ignoresSafeArea(edges: .top)). I also have a 'detail' screen with a similar immersive layout, where the header/poster image sits at the top and the ScrollView also extends under the top area. I’m using the native navigation bar on both screens and default back button, not a custom nav bar, and I’m not manually configuring UINavigationBarAppearance, I'm just relying on SwiftUI’s default/automatic toolbar behavior. The problem I’m facing is when I push from home to the detail screen, the top nav area briefly flickers and shows the system navigation bar/material background (white in light mode, black in dark mode). It’s clearly the system material, not the poster/image underneath. The screen initially renders with that nav bar state (white/dark), and only after I start scrolling does it correct itself and visually align with the header/background behind it. What I'm thinking is that maybe the detail screen initially renders with systemBackground, so the nav bar uses its default (standard) appearance on the first frame, and only after layout/interaction, once the image-derived background settles, does it switch to the correct scroll-edge/transparent style. One important thing, if I hide the nav bar on the detail screen using .toolbar(.hidden, for: .navigationBar), the issue disappears completely. So this seems specifically tied to the native nav bar’s initial render/appearance timing during the push, rather than just the layout or image loading. I’d prefer to keep the native nav bar and back button rather than implement a custom approach. Has anyone faced this issue before, or is there a correct way to structure edge-to-edge content under the nav bar so it renders properly on first push? Video of the issue: https://imgur.com/a/OYHtYbp
Replies
1
Boosts
0
Views
82
Activity
5d
On iPad with Swift Playgrounds: How to open chapter as a playground?
Note On a Mac with Xcode installed, or on an iPad with Swift Playgrounds, you can open this chapter as a playground. Playgrounds allow you to edit the code listings and see the results immediately. (Note in page 3) (I would like to open the chapter or book: Swift Programming Language in Swift Playground on iPad) https://books.apple.com/ve/book/the-swift-programming-language-swift-5-7-beta/id1002622538?l=en-GB Best regards
Replies
2
Boosts
0
Views
1.4k
Activity
5d
iPad Pro M4 giving wrong value for layerPointConverted for ultra wide angle
I am using iPad Pro M4 device to apply exposure point to the camera. While converting layerPointConverted from 0 -1 range to device size point it is giving wrong value. But if same code is used for other iPad like Gen2, it gives proper value. In both cases video gravity used is resizeAspectFill. I tried using true depth camera for M4 device but it does not work.
Replies
0
Boosts
0
Views
78
Activity
5d
Navigation bar flickers when pushing to a different screen
Hi everyone, I’m building a SwiftUI app using NavigationStack and running into a weird nav bar issue. For the setup I have a 'home' screen with a vertical ScrollView and a large edge-to-edge header that extends under the top safe area (using .ignoresSafeArea(edges: .top)). I also have a 'detail' screen with a similar immersive layout, where the header/poster image sits at the top and the ScrollView also extends under the top area. I’m using the native navigation bar on both screens and default back button, not a custom nav bar, and I’m not manually configuring UINavigationBarAppearance, I'm just relying on SwiftUI’s default/automatic toolbar behavior. The problem I’m facing is when I push from home to the detail screen, the top nav area briefly flickers and shows the system navigation bar/material background (white in light mode, black in dark mode). It’s clearly the system material, not the poster/image underneath. The screen initially renders with that nav bar state (white/dark), and only after I start scrolling does it correct itself and visually align with the header/background behind it. What I'm thinking is that maybe the detail screen initially renders with systemBackground, so the nav bar uses its default (standard) appearance on the first frame, and only after layout/interaction, once the image-derived background settles, does it switch to the correct scroll-edge/transparent style. One important thing, if I hide the nav bar on the detail screen using .toolbar(.hidden, for: .navigationBar), the issue disappears completely. So this seems specifically tied to the native nav bar’s initial render/appearance timing during the push, rather than just the layout or image loading. I’d prefer to keep the native nav bar and back button rather than implement a custom approach. Has anyone faced this issue before, or is there a correct way to structure edge-to-edge content under the nav bar so it renders properly on first push? Video of the issue: https://imgur.com/a/OYHtYbp NavigationStack { ScrollView { HeroView() } .ignoresSafeArea(edges: .top) .navigationTitle("Cinema") .toolbarTitleDisplayMode(.inlineLarge) .toolbarBackgroundVisibility(.automatic, for: .navigationBar) .navigationDestination(for: Route.self) { route in DetailView(movie: route.movie) } } var body: some View { ScrollView { HeaderPosterView() } .ignoresSafeArea(edges: .top) .navigationBarTitleDisplayMode(.inline) .toolbarBackgroundVisibility(.automatic, for: .navigationBar) } }
Replies
0
Boosts
0
Views
102
Activity
6d
Scheduled events reach threshold almost immediately on iOS 26.2
Hi, we are developing a screen time management app. The app locks the device after it was used for specified amount of time. After updating to iOS 26.2, we noticed a huge issue: the events started to fire (reach the threshold) in the DeviceActivityMonitorExtension prematurely, almost immediately after scheduling. The only solution we've found is to delete the app and reboot the device, but the effect is not lasting long and this does not always help. Before updating to iOS 26, events also used to sometimes fire prematurely, but rescheduling the event often helped. Now the rescheduling happens almost every second and the events keep reaching the threshold prematurely. Can you suggest any workarounds for this issue?
Replies
7
Boosts
2
Views
576
Activity
1w
ManipulationComponent Not Translating using indirect input
When using the new RealityKit Manipulation Component on Entities, indirect input will never translate the entity - no matter what settings are applied. Direct manipulation works as expected for both translation and rotation. Is this intended behaviour? This is different from how indirect manipulation works on Model3D. How else can we get translation from this component? visionOS 26 Beta 2 Build from macOS 26 Beta 2 and Xcode 26 Beta 2 Attached is replicable sample code, I have tried this in other projects with the same results. var body: some View { RealityView { content in // Add the initial RealityKit content if let immersiveContentEntity = try? await Entity(named: "MovieFilmReel", in: reelRCPBundle) { ManipulationComponent.configureEntity(immersiveContentEntity, allowedInputTypes: .all, collisionShapes: [ShapeResource.generateBox(width: 0.2, height: 0.2, depth: 0.2)]) immersiveContentEntity.position.y = 1 immersiveContentEntity.position.z = -0.5 var mc = ManipulationComponent() mc.releaseBehavior = .stay immersiveContentEntity.components.set(mc) content.add(immersiveContentEntity) } } }
Replies
17
Boosts
5
Views
2.6k
Activity
1w
Initial presentation of popover hangs when shown from a button in the toolbar
I have a simple reproducer here: struct ContentView: View { @State private var isOn = false @State private var isPresented = false var body: some View { NavigationStack { Color.blue .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Press here") { isPresented = true } .popover(isPresented: $isPresented) { Color.green .frame(idealWidth: 400, idealHeight: 500) .presentationCompactAdaptation(.popover) } } } } } } When I tap on the button in the toolbar you can see there is a hang then the popover shows. Then every time after there is no longer a hang so this seems like a bug. Any ideas? I'm using Xcode 26.3 and a iPad Pro 13-inch (M5) (26.4) simulator.
Replies
3
Boosts
3
Views
177
Activity
1w
How to add icon and thumbnail image for a Screensaver ?
I have made a screensaver for mac in swift, but couldn't find how to add an icon the logo image that shows up on saver file) and thumbnail (the cover image that shows up in the screensaver catalogue). Currently, it just shows a default blue spiral galaxy thumbnail and no icon image
Replies
7
Boosts
0
Views
624
Activity
1w
iOS 26 TabBar Remove Selected Capsule
I have subclassed UITabBar and created a custom look and feel for it. On iOS 18, the tab bar appears as expected. On iOS 26, however, a default Liquid Glass-style capsule selection indicator appears behind the selected tab item. I tried using UITabBarAppearance, including selectionIndicatorTintColor = .clear and selectionIndicatorImage = nil / empty image, but the capsule-style selected background still appears. Is this selection treatment part of the new default system rendering in iOS 26, and if so, is there any supported way to remove or disable it while still using UITabBar?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
3
Boosts
0
Views
240
Activity
1w