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
3.6k
Oct ’25
Swift 6: Supported AVCaptureSession actor isolation and MainActor preview attachment
I’m developing a SwiftUI camera preview for iPhone and iPad using Xcode 27.2 and Swift 6.4.2. I’m looking for clarification about the supported concurrency boundary between an actor-owned AVCaptureSession and a MainActor-owned AVCaptureVideoPreviewLayer. Environment Xcode 27.2 (27B52) Apple Swift 6.4.2 iPhoneOS SDK 27.2 Deployment target: iOS 26.0 Swift 6 language mode Complete concurrency checking Default actor isolation: MainActor Approachable Concurrency enabled The isolated compiler reproductions also explicitly enable NonisolatedNonsendingByDefault, InferIsolatedConformances, and MemberImportVisibility. Architecture The intended architecture follows the general pattern demonstrated in Apple’s AVCam sample: A capture actor uses a dedicated DispatchSerialQueue executor. The capture actor creates, configures, starts, and stops AVCaptureSession. A MainActor adapter owns AVCaptureVideoPreviewLayer. The preview layer retains the same session after attachment. The capture actor retains its session reference because it must perform subsequent capture operations. Compiler behavior In a minimal reproduction, transferring the retained session directly to the MainActor adapter: await preview.attach(session)produces: Sources/CaptureActor.swift:19:23: error: sending 'session' risks causing data races [#RegionIsolation::SendingRisksDataRace]The compiler identifies a potential race between actor-isolated and MainActor-isolated uses. This reproduction produces one error and zero warnings. A second reproduction uses a small PreviewSource: Sendable value containing a private AVCaptureSession reference, with @preconcurrency import AVFoundation confined to that source file. Its MainActor method attaches the session to the preview layer. Under otherwise identical compiler settings, this second reproduction compiles with zero diagnostics. We understand that compiler acceptance does not establish runtime safety and that the compatibility mechanism does not itself synchronize access to the retained session. Apple AVCam reference Apple’s official AVCam sample demonstrates a similar interoperability pattern: CaptureService.swift: dedicated capture executor and retained preview source. PreviewSource.swift: compatibility import and MainActor attachment. CameraPreview.swift: preview-layer association. Reference: Apple’s AVCam: Building a Camera App sample. Pinned sample SHA-256: 5a1981f90bb30827121324d4b33198d58de9b9d68e3508b64f0aabc18bbc0e53The sample revision date is not established; we are not assuming this archive is identical to the latest downloadable revision. Questions 1. Supported Swift 6 interoperability pattern Is the narrow PreviewSource compatibility approach demonstrated by AVCam the recommended way to associate an actor-retained AVCaptureSession with a MainActor-owned AVCaptureVideoPreviewLayer under complete Swift 6 concurrency checking? Is there a newer recommended API, annotation, or ownership pattern? 2. Capture and preview synchronization Is the following operation sequence supported? Configure and commit the capture session on the dedicated capture executor. Attach the session to the preview layer on MainActor. Call startRunning() on the capture executor. Perform ordinary preview layout on MainActor while capture runs. Call stopRunning() on the capture executor. Detach the session from the preview layer on MainActor. Which preview-layer or preview-connection mutations, if any, must be excluded while startRunning() or stopRunning() is executing? 3. Supported detachment and release sequence After stopRunning() returns and MainActor executes: previewLayer.session = nilis it supported to release the remaining application-held session references once application-owned observers and asynchronous consumers have terminated? Does AVFoundation require or recommend any additional step before those references are released? We are asking about the supported framework lifecycle contract, not assuming that application-level cancellation drains internal AVFoundation work. Sources AVCam: Building a camera app Overview Apple’s official AVCam sample
0
0
19
2h
iOS 26: FloatingBarContainerView overlapping the whole custom ViewController
Hi everyone: I'm experiencing an issue in iOS 26. I've implemented a custom ViewController. It's super simple to edit images with flip, crop, zoom in, and zoom out. My question is that it seems very strange to me. It works without problems in iOS 17.5 and iOS 18. However, when I try to run it with iOS 26, the entire ViewController seems disabled; it doesn't recognize touches or anything. When I checked the UI hierarchy, I saw a strange FloatingBarContainerView overlaying the entire ViewController. I searched the documentation for information about this view, but I couldn't find anything. Any help on how to hide or remove this view in iOS 26? This hasn't been implemented anywhere.
3
0
1.1k
1d
Foundation Models availability in mainland China
Hi, Apple recently announced that Apple Intelligence will launch in mainland China with iOS 27.3. Will the Foundation Models framework also become available to third-party apps in mainland China? If so, will it use the new iOS 27 Apple Foundation Model or an older version? Will the new capabilities and Private Cloud Compute also be supported? Thanks!
2
0
292
2d
XCTest Feature request: Open/close and rotate iPhone Duo devices
Currently, we do not have a way to open, close and rotate iPhone Duo devices via XCUITest test automation. Please provide a way to perform these operations via XCTest. XCUIDevice.shared.orientation has no effect on an iPhone Duo iOS 27.1 simulator. We could open, close and rotate an iPhone Duo simulator manually via the Device Hub at the moment.
1
0
170
3d
Acessing structs from Swift
My latest app communicates, via TCP, with an embedded device. The embedded device is programmed in C and sends my Swift app data encapsulated in "messages" which are actually structures defined like this: { uint16_t sig; uint16_t len; // Total length of message, include header and playload; uint16_t type; uint32_t data; // 32 Bits of data. } MSG_t; In my Swit app they arrive via NWConnection, and are sent to my controller delegate as Data (That's the swift type called Data, not just the general term 'data') So me question for you harties is this: How can I unpack this 'Data' into something resembling my C struct - and acess it's members by name. In Pseudo code I'd like to do something like: if let myData = data { myStruct = <cast myData.bytes onto a struct > if myStruct.sig == CORRECT_MSG_SIG { // do soemthig with the message... } } So is this possible? Is it the wrong approach? Is there a better approach?
3
0
2.0k
1w
tvOS 14.6 fails trying to bind UDP/1900 (succeeds on tvOS Simulator)
I'm working on a tvOS app/library which uses SSDP. The code binds a UDP socket to port 1900 and joins a multicast group using BSD Socket library. I believe this used to work on a previous tvOS version, but specifically as of tvOS 14.6 there is a divergence between the tvOS Simulator and actual devices. Actual devices fail at the call to bind, with an Address Already in Use error. The tvOS simulator binds just fine after throwing up a macOS firewall 'allow incoming connections' dialog. Any ideas what the official situation is here? The com.apple.developer.networking.multicast entitlement seems to be iOS only at this time, is that correct? Also there seems to be no 'local networking' permission dialog in tvOS - is that also correct?
5
0
2.8k
1w
NWConnection/NWListener: .failed, .cancelled, and State Handler Semantics
Hi, I am using Apple's Network.framework APIs, specifically NWConnection and NWListener over UDP, in my project. Both APIs use state-update handlers, and I would like to clarify a few aspects of their lifecycle and callback-delivery semantics. Are .failed and .cancelled delivered only once during the lifecycle? For a given NWConnection or NWListener instance, my understanding is that .failed is a terminal state and the object does not recover from it. Is .failed guaranteed to be delivered at most once during the lifetime of an instance? If the object enters .failed, can I call cancel() on that same instance? If so, will the state-update handler subsequently receive .cancelled? Is .cancelled guaranteed to be delivered at most once per instance, even if cancel() is called multiple times? If the object is in the .waiting state and I call cancel(), causing it to transition to .cancelled, is it guaranteed that .failed will not subsequently be delivered for that instance? Since there is no transition from .cancelled -> .failed? What happens when stateUpdateHandler is replaced while callbacks are pending? Consider the following scenario: I create an NWConnection and assign a stateUpdateHandler (Handler A). The connection's state changes, and a callback for Handler A is enqueued on the connection's associated DispatchQueue. Before that queued callback executes, I replace stateUpdateHandler with Handler B. If the callback for Handler A was already enqueued before the handler was replaced, will Handler A still be invoked? My understanding is Yes, since it was already queued. If the object is in the .waiting state and I call cancel(), causing it to transition to .cancelled, is it guaranteed that .failed will not subsequently be delivered for that instance Can the same state notification be delivered to both Handler A and Handler B, or is it delivered to only one of them i.e., Handler A, since during the state-change Handler A was the one as stateUpdateHandler? Thanks!
3
1
405
1w
Is Data.withUnsafeMutableBytes(_:) safe to rely on long-term for C++ interop?
Hi, in our project we use Network.framework, with NWListener and NWConnection, to send and receive data over UDP. We use the receiveMessage(completion:) API, which delivers the data as a Data object. We assign this Data to a property of one of our classes, which we continue to work with after the completion handler returns. We pass that property's bytes to our C++ code (through Swift–C++ interop) using Data.withUnsafeMutableBytes(_:). The C++ code modifies the bytes in place, and we then continue working with the modified Data in Swift. Since nothing else refers to the Data we received, the bytes are modified in place and no copy is made. However, if another Data value shared the same buffer, just calling withUnsafeMutableBytes(_:) would create a copy, whether or not we actually modified the bytes. Our understanding is that this is because the method is declared mutating, so the call itself is treated as a write and copy-on-write makes the buffer unique before the pointer is handed out. We also understand that ResultType : ~Copyable (along with the typed throws(E)) only relaxes the requirements on the closure's return type and doesn't affect this behaviour. We understand this approach is unsafe and that the pointer "should not be stored and used outside of the lifetime of the call to the closure", so we will take care of that. Since the typed-pointer variants of APIs such as Data.withUnsafeBytes were deprecated in Swift 5, we would also like to confirm that withUnsafeMutableBytes(_:), the variant that takes an UnsafeMutableRawBufferPointer, is the intended long-term API and isn't expected to be deprecated in the same way.
5
1
290
1w
macOS widget stays on the grey placeholder after a Developer ID app is replaced by a Mac App Store build of the same app
I have a macOS app with a WidgetKit widget extension, distributed two ways: a notarised Developer ID download, and a Mac App Store build (same bundle identifiers, same team, different signature). When a user replaces the Developer ID copy in /Applications with the store-signed copy, the desktop widget draws only the grey placeholder and never recovers. The app itself runs normally. What I saw (8 October 2026, macOS 27): An iMac had the Developer ID build 47 (version 1.6.3) in /Applications with the widget on the desktop. I installed build 48 (version 1.6.4), signed for the store, from TestFlight. It replaced the Developer ID copy in /Applications. The app worked. The large widget showed grey placeholder bars and no data, for at least five minutes. killall chronod in Terminal brought the widget back straight away. On a MacBook, updating from one TestFlight build to the next (builds 46, 47, 48) redrew the widget each time. So it is the change from a Developer ID signature to a store signature, not an ordinary update. What I think is happening, and would like confirmed or corrected: the widget process that was started from the Developer ID copy keeps running after the app is replaced, and the system refuses what it draws (or never asks it for a new timeline), while the widget gallery and desktop keep showing that process's placeholder. What I already do: The Developer ID build ships a small helper outside the sandbox that ends the old widget process after an update. The Mac App Store build cannot carry that helper. The widget extension compares the build number in its bundle's Info.plist on disk with the one it started with, and exits if they differ. This ran in the case above (the build numbers were 47 and 48) and did not clear the placeholder. I suspect the check only runs when the system asks the widget for a snapshot or timeline, and the system had stopped asking. I call WidgetCenter.shared.reloadAllTimelines() after the app writes new data. Questions: Is there a supported way for a sandboxed app (or its widget extension) to make the system replace or restart a widget process that belongs to an earlier, differently signed copy of the same app? Without a Terminal command, and without a helper outside the sandbox. Is it expected that chronod keeps the old extension process after the containing app is replaced by a copy with a different signing identity, and that the widget then stays on the placeholder? Is there a log subsystem or predicate that shows why the old extension process was kept, or what the system refused? Thank you.
0
0
287
1w
Xcode 27.1 compilation error possibly due to swift versions discrepancy
Compiling my project using Xcode 27.1 ends with an error: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.0.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64e-apple-macos.swiftinterface:1:1: error: failed to build module 'SwiftUI'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.31.4 clang-2100.3.31.1)', while this compiler is 'Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)'). Please select a toolchain which matches the SDK. 1 | // swift-interface-format-version: 1.0 | `- error: failed to build module 'SwiftUI'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.31.4 clang-2100.3.31.1)', while this compiler is 'Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)'). Please select a toolchain which matches the SDK. 2 | // swift-compiler-version: Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.31.4 clang-2100.3.31.1) 3 | // swift-module-flags: -target arm64e-apple-macos27.0 -enable-objc-interop -target-arch-variant arm64e.x1 -enable-library-evolution -language-mode 5 -O -library-level api -enable-experimental-feature AnyAppleOSAvailability -enable-upcoming-feature InferSendableFromCaptures -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -user-module-version 8.0.84.1.406 -module-name SwiftUI -package-name SwiftUICompiling it with Xcode 27 ends without error. Do you see any other root cause than the one mentionned: Xcode 27.1 uses swiftlang-6.4.0.34.1 clang-2100.3.34.1 while internal sdk was compiled with swiftlang-6.4.0.31.4 clang-2100.3.31.1 ?
1
0
227
2w
Adjusting Spacing in ArrangementView
I am trying to adjust the spacing between the primary and secondary views within a SwiftUI ArrangementView. I haven't been able to find a direct parameter or modifier (like spacing) that controls this distance on the container itself. Is there a standard way to achieve this, or should I be looking into a workaround using padding ?
3
0
443
2w
iOS and Android
I currently have a iOS app live on the App Store but I also want to release it on Android, the whole code is in Swift so would that be possible or would I have to rewrite my whole apps code in a different coding language.
3
0
3.9k
2w
From Bytes to Gigabytes in a readable format
Hi, I’ve been wondering how Apple calculates Gigabytes in Finder, as I haven’t been able to find any function that yields the result shown. I would like to convert 1,303,412,493 Bytes. It says 1.3 GB in the top right corner, which matches my own conversion. let byteCountFormatStyle = ByteCountFormatStyle(style: .file, allowedUnits: .all, spellsOutZero: false, includesActualByteCount: false, locale: Locale.current) let sizeFormatStyle = byteCountFormatStyle.format(Int64(1_303_412_493)) let byteMeasurement = Measurement(value: Double(1_303_412_493), unit: UnitInformationStorage.bytes) let sizeMeasurement = byteMeasurement.formatted(.byteCount(style: .file)) print("sizeFormatStyle: \(sizeFormatStyle), sizeMeasurement: \(sizeMeasurement)")Both are the same: sizeFormatStyle: 1.3 GB, sizeMeasurement: 1.3 GB But how do I arrive at the 1.51 GB figure that appears next to the Byte count? Christian
2
0
378
2w
UIDesignRequiresCompatibility for Xcode27
Hallo everyone, We are building our app with Xcode 27 and noticed that UIDesignRequiresCompatibility still appears to be honored on iOS 26 devices. Questions: Could you confirm whether this key is still supported on iOS 26 when built with Xcode 27? If our deployment target includes iOS 26, should we keep the key for backward compatibility, or is Apple's recommendation to remove it entirely? Additionally, are there any risks associated with removing it for iOS 26 users?
1
0
542
2w
Third-party keyboards get an extra 17pt gap at the top after switching apps on iOS 27 beta.
Feedback submitted: FB24460699 The sample projects are attached to the feedback report. Environment:iOS27 Beta6; iPhone 17Pro Problem:I have encountered a consistently reproducible third-party custom keyboard layout issue in iOS 27.0 beta 1 through beta 6. The custom keyboard initially appears correctly. If I switch apps while the text input remains focused and the keyboard remains visible, and then return to the host app, the system adds a 17-point area above the custom keyboard extension. Steps to reproduce Install and enable a third-party custom keyboard. Switch to the sample custom keyboard and open the host app so that the text editor in the center receives focus. Do not dismiss the keyboard or remove focus from the editor. Return to the Home Screen or switch to another app. Return to the host app. A new blank area now appears above the custom keyboard content. I tested both a system-determined extension view height and an extension view explicitly constrained to 180 points. Both configurations produce exactly the same change. After the foreground transition, the following extension-side values remain unchanged: view.bounds inputView.bounds extension.window.bounds view.safeAreaInsets, which remains {0, 0, 0, 0} The requested 180-point extension height Only the system keyboard frame received by the host app increases by 17 points. I also drew a rounded pink boundary inside the transparent extension root view. When the issue occurs, the new area appears outside that boundary. I tested several third-party keyboards and reproduced the issue with all of them. This suggests that the behavior is caused by iOS rather than by my app. Questions On iOS 27, is it expected behavior for a custom keyboard to gain a 17pt top area after its host app returns from the background? If this is a system issue, is there any workaround that can be used until it is fixed?
9
9
1.6k
2w
I can't write on Run view on Swift Playground
Hi there! I'm pretty new in coding. Right now I'm just vibe coding, trying to understand what happens and how does this works. I made a simple app in Swift Playground on my iPad Mini A17 Pro, and everything works good so far when I tap the Play (Run) button, except text input: every text field only shows the blinking cursor and let me paste, but the virtual keyboard don't appear, and even connecting a physical keyboard has no better outcome. What am I doing wrong? Thanks.
4
1
495
2w
Full screen
Hello. Do you know how to make full screen on SwiftUI? Not like when you tap on green circle placed top-left side in any MacOS app, now my app opens on small window but I need to this app was stretched for horizontal and vertical sides
0
0
1.2k
2w
Adding MCP and connector support to your own Foundation Models apps
Circling back on the LocalLM Lab arc. With v0.7, we've moved from prompt experimentation into real app development on Apple's Foundation Models local AI. The LocalLM Lab SDK lets you build that same on-device model and MCP client this thread has covered directly into your own app, with real tool and data access (Slack, Todoist, GitHub, Notion, Linear, plus Calendar, Reminders, Contacts and Location). And you can ship your app including through the Mac App Store. This is a big improvement over version 0.6, where the localai-cli toolkit needed LocalLM Lab installed and running. On the other hand, the SDK (LocalLMLabSDKCore) doesn't relay through anything; it links FoundationModels and a real MCP client directly into your own binary and is totally self-contained. The example included in the SDK, Plate Today, has actually been built into a sandboxed test app and verified working, with a signed path to a Mac App Store .pkg (Apple Distribution signing + provisioning profile pipeline). That's "verified signable and sandbox-compatible," to be precise. Entitlements (from personal experience: always a complicated topic): com.apple.security.app-sandbox + com.apple.security.network.client for the app itself, plus the standard personal-information entitlements per connector used (com.apple.security.personal-information.calendars, .addressbook, .location) and matching NS*UsageDescription strings in Info.plist. The one worth flagging specifically: the network entitlement is easy to miss and fails silently rather than throwing. Without it, MCP connections and Weather calls just hang with no error surfaced. OAuth handling requires the app delegate callback (application(_:open:)), not SwiftUI's .onOpenURL. Worth knowing before wiring it up if you're SwiftUI-only. Full entitlements list + SDK guide: https://github.com/ancientcomputing/locallm/blob/main/docs/sdk-guide.md Feature page: thisbrain.ai/locallm/sdk.html I hope the availability of the SDK (free, Apache 2.0 license) will give folks further incentive to explore local AI-enabled applications on the Mac. What else would you want to do that the SDK doesn't currently support? File picker? Calendar/Reminders/Contacts edits & writes?
7
1
4.5k
3w
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
3.6k
Activity
Oct ’25
Swift 6: Supported AVCaptureSession actor isolation and MainActor preview attachment
I’m developing a SwiftUI camera preview for iPhone and iPad using Xcode 27.2 and Swift 6.4.2. I’m looking for clarification about the supported concurrency boundary between an actor-owned AVCaptureSession and a MainActor-owned AVCaptureVideoPreviewLayer. Environment Xcode 27.2 (27B52) Apple Swift 6.4.2 iPhoneOS SDK 27.2 Deployment target: iOS 26.0 Swift 6 language mode Complete concurrency checking Default actor isolation: MainActor Approachable Concurrency enabled The isolated compiler reproductions also explicitly enable NonisolatedNonsendingByDefault, InferIsolatedConformances, and MemberImportVisibility. Architecture The intended architecture follows the general pattern demonstrated in Apple’s AVCam sample: A capture actor uses a dedicated DispatchSerialQueue executor. The capture actor creates, configures, starts, and stops AVCaptureSession. A MainActor adapter owns AVCaptureVideoPreviewLayer. The preview layer retains the same session after attachment. The capture actor retains its session reference because it must perform subsequent capture operations. Compiler behavior In a minimal reproduction, transferring the retained session directly to the MainActor adapter: await preview.attach(session)produces: Sources/CaptureActor.swift:19:23: error: sending 'session' risks causing data races [#RegionIsolation::SendingRisksDataRace]The compiler identifies a potential race between actor-isolated and MainActor-isolated uses. This reproduction produces one error and zero warnings. A second reproduction uses a small PreviewSource: Sendable value containing a private AVCaptureSession reference, with @preconcurrency import AVFoundation confined to that source file. Its MainActor method attaches the session to the preview layer. Under otherwise identical compiler settings, this second reproduction compiles with zero diagnostics. We understand that compiler acceptance does not establish runtime safety and that the compatibility mechanism does not itself synchronize access to the retained session. Apple AVCam reference Apple’s official AVCam sample demonstrates a similar interoperability pattern: CaptureService.swift: dedicated capture executor and retained preview source. PreviewSource.swift: compatibility import and MainActor attachment. CameraPreview.swift: preview-layer association. Reference: Apple’s AVCam: Building a Camera App sample. Pinned sample SHA-256: 5a1981f90bb30827121324d4b33198d58de9b9d68e3508b64f0aabc18bbc0e53The sample revision date is not established; we are not assuming this archive is identical to the latest downloadable revision. Questions 1. Supported Swift 6 interoperability pattern Is the narrow PreviewSource compatibility approach demonstrated by AVCam the recommended way to associate an actor-retained AVCaptureSession with a MainActor-owned AVCaptureVideoPreviewLayer under complete Swift 6 concurrency checking? Is there a newer recommended API, annotation, or ownership pattern? 2. Capture and preview synchronization Is the following operation sequence supported? Configure and commit the capture session on the dedicated capture executor. Attach the session to the preview layer on MainActor. Call startRunning() on the capture executor. Perform ordinary preview layout on MainActor while capture runs. Call stopRunning() on the capture executor. Detach the session from the preview layer on MainActor. Which preview-layer or preview-connection mutations, if any, must be excluded while startRunning() or stopRunning() is executing? 3. Supported detachment and release sequence After stopRunning() returns and MainActor executes: previewLayer.session = nilis it supported to release the remaining application-held session references once application-owned observers and asynchronous consumers have terminated? Does AVFoundation require or recommend any additional step before those references are released? We are asking about the supported framework lifecycle contract, not assuming that application-level cancellation drains internal AVFoundation work. Sources AVCam: Building a camera app Overview Apple’s official AVCam sample
Replies
0
Boosts
0
Views
19
Activity
2h
iOS 26: FloatingBarContainerView overlapping the whole custom ViewController
Hi everyone: I'm experiencing an issue in iOS 26. I've implemented a custom ViewController. It's super simple to edit images with flip, crop, zoom in, and zoom out. My question is that it seems very strange to me. It works without problems in iOS 17.5 and iOS 18. However, when I try to run it with iOS 26, the entire ViewController seems disabled; it doesn't recognize touches or anything. When I checked the UI hierarchy, I saw a strange FloatingBarContainerView overlaying the entire ViewController. I searched the documentation for information about this view, but I couldn't find anything. Any help on how to hide or remove this view in iOS 26? This hasn't been implemented anywhere.
Replies
3
Boosts
0
Views
1.1k
Activity
1d
Foundation Models availability in mainland China
Hi, Apple recently announced that Apple Intelligence will launch in mainland China with iOS 27.3. Will the Foundation Models framework also become available to third-party apps in mainland China? If so, will it use the new iOS 27 Apple Foundation Model or an older version? Will the new capabilities and Private Cloud Compute also be supported? Thanks!
Replies
2
Boosts
0
Views
292
Activity
2d
XCTest Feature request: Open/close and rotate iPhone Duo devices
Currently, we do not have a way to open, close and rotate iPhone Duo devices via XCUITest test automation. Please provide a way to perform these operations via XCTest. XCUIDevice.shared.orientation has no effect on an iPhone Duo iOS 27.1 simulator. We could open, close and rotate an iPhone Duo simulator manually via the Device Hub at the moment.
Replies
1
Boosts
0
Views
170
Activity
3d
Acessing structs from Swift
My latest app communicates, via TCP, with an embedded device. The embedded device is programmed in C and sends my Swift app data encapsulated in "messages" which are actually structures defined like this: { uint16_t sig; uint16_t len; // Total length of message, include header and playload; uint16_t type; uint32_t data; // 32 Bits of data. } MSG_t; In my Swit app they arrive via NWConnection, and are sent to my controller delegate as Data (That's the swift type called Data, not just the general term 'data') So me question for you harties is this: How can I unpack this 'Data' into something resembling my C struct - and acess it's members by name. In Pseudo code I'd like to do something like: if let myData = data { myStruct = <cast myData.bytes onto a struct > if myStruct.sig == CORRECT_MSG_SIG { // do soemthig with the message... } } So is this possible? Is it the wrong approach? Is there a better approach?
Replies
3
Boosts
0
Views
2.0k
Activity
1w
tvOS 14.6 fails trying to bind UDP/1900 (succeeds on tvOS Simulator)
I'm working on a tvOS app/library which uses SSDP. The code binds a UDP socket to port 1900 and joins a multicast group using BSD Socket library. I believe this used to work on a previous tvOS version, but specifically as of tvOS 14.6 there is a divergence between the tvOS Simulator and actual devices. Actual devices fail at the call to bind, with an Address Already in Use error. The tvOS simulator binds just fine after throwing up a macOS firewall 'allow incoming connections' dialog. Any ideas what the official situation is here? The com.apple.developer.networking.multicast entitlement seems to be iOS only at this time, is that correct? Also there seems to be no 'local networking' permission dialog in tvOS - is that also correct?
Replies
5
Boosts
0
Views
2.8k
Activity
1w
NWConnection/NWListener: .failed, .cancelled, and State Handler Semantics
Hi, I am using Apple's Network.framework APIs, specifically NWConnection and NWListener over UDP, in my project. Both APIs use state-update handlers, and I would like to clarify a few aspects of their lifecycle and callback-delivery semantics. Are .failed and .cancelled delivered only once during the lifecycle? For a given NWConnection or NWListener instance, my understanding is that .failed is a terminal state and the object does not recover from it. Is .failed guaranteed to be delivered at most once during the lifetime of an instance? If the object enters .failed, can I call cancel() on that same instance? If so, will the state-update handler subsequently receive .cancelled? Is .cancelled guaranteed to be delivered at most once per instance, even if cancel() is called multiple times? If the object is in the .waiting state and I call cancel(), causing it to transition to .cancelled, is it guaranteed that .failed will not subsequently be delivered for that instance? Since there is no transition from .cancelled -> .failed? What happens when stateUpdateHandler is replaced while callbacks are pending? Consider the following scenario: I create an NWConnection and assign a stateUpdateHandler (Handler A). The connection's state changes, and a callback for Handler A is enqueued on the connection's associated DispatchQueue. Before that queued callback executes, I replace stateUpdateHandler with Handler B. If the callback for Handler A was already enqueued before the handler was replaced, will Handler A still be invoked? My understanding is Yes, since it was already queued. If the object is in the .waiting state and I call cancel(), causing it to transition to .cancelled, is it guaranteed that .failed will not subsequently be delivered for that instance Can the same state notification be delivered to both Handler A and Handler B, or is it delivered to only one of them i.e., Handler A, since during the state-change Handler A was the one as stateUpdateHandler? Thanks!
Replies
3
Boosts
1
Views
405
Activity
1w
Is Data.withUnsafeMutableBytes(_:) safe to rely on long-term for C++ interop?
Hi, in our project we use Network.framework, with NWListener and NWConnection, to send and receive data over UDP. We use the receiveMessage(completion:) API, which delivers the data as a Data object. We assign this Data to a property of one of our classes, which we continue to work with after the completion handler returns. We pass that property's bytes to our C++ code (through Swift–C++ interop) using Data.withUnsafeMutableBytes(_:). The C++ code modifies the bytes in place, and we then continue working with the modified Data in Swift. Since nothing else refers to the Data we received, the bytes are modified in place and no copy is made. However, if another Data value shared the same buffer, just calling withUnsafeMutableBytes(_:) would create a copy, whether or not we actually modified the bytes. Our understanding is that this is because the method is declared mutating, so the call itself is treated as a write and copy-on-write makes the buffer unique before the pointer is handed out. We also understand that ResultType : ~Copyable (along with the typed throws(E)) only relaxes the requirements on the closure's return type and doesn't affect this behaviour. We understand this approach is unsafe and that the pointer "should not be stored and used outside of the lifetime of the call to the closure", so we will take care of that. Since the typed-pointer variants of APIs such as Data.withUnsafeBytes were deprecated in Swift 5, we would also like to confirm that withUnsafeMutableBytes(_:), the variant that takes an UnsafeMutableRawBufferPointer, is the intended long-term API and isn't expected to be deprecated in the same way.
Replies
5
Boosts
1
Views
290
Activity
1w
macOS widget stays on the grey placeholder after a Developer ID app is replaced by a Mac App Store build of the same app
I have a macOS app with a WidgetKit widget extension, distributed two ways: a notarised Developer ID download, and a Mac App Store build (same bundle identifiers, same team, different signature). When a user replaces the Developer ID copy in /Applications with the store-signed copy, the desktop widget draws only the grey placeholder and never recovers. The app itself runs normally. What I saw (8 October 2026, macOS 27): An iMac had the Developer ID build 47 (version 1.6.3) in /Applications with the widget on the desktop. I installed build 48 (version 1.6.4), signed for the store, from TestFlight. It replaced the Developer ID copy in /Applications. The app worked. The large widget showed grey placeholder bars and no data, for at least five minutes. killall chronod in Terminal brought the widget back straight away. On a MacBook, updating from one TestFlight build to the next (builds 46, 47, 48) redrew the widget each time. So it is the change from a Developer ID signature to a store signature, not an ordinary update. What I think is happening, and would like confirmed or corrected: the widget process that was started from the Developer ID copy keeps running after the app is replaced, and the system refuses what it draws (or never asks it for a new timeline), while the widget gallery and desktop keep showing that process's placeholder. What I already do: The Developer ID build ships a small helper outside the sandbox that ends the old widget process after an update. The Mac App Store build cannot carry that helper. The widget extension compares the build number in its bundle's Info.plist on disk with the one it started with, and exits if they differ. This ran in the case above (the build numbers were 47 and 48) and did not clear the placeholder. I suspect the check only runs when the system asks the widget for a snapshot or timeline, and the system had stopped asking. I call WidgetCenter.shared.reloadAllTimelines() after the app writes new data. Questions: Is there a supported way for a sandboxed app (or its widget extension) to make the system replace or restart a widget process that belongs to an earlier, differently signed copy of the same app? Without a Terminal command, and without a helper outside the sandbox. Is it expected that chronod keeps the old extension process after the containing app is replaced by a copy with a different signing identity, and that the widget then stays on the placeholder? Is there a log subsystem or predicate that shows why the old extension process was kept, or what the system refused? Thank you.
Replies
0
Boosts
0
Views
287
Activity
1w
Xcode 27.1 compilation error possibly due to swift versions discrepancy
Compiling my project using Xcode 27.1 ends with an error: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.0.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64e-apple-macos.swiftinterface:1:1: error: failed to build module 'SwiftUI'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.31.4 clang-2100.3.31.1)', while this compiler is 'Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)'). Please select a toolchain which matches the SDK. 1 | // swift-interface-format-version: 1.0 | `- error: failed to build module 'SwiftUI'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.31.4 clang-2100.3.31.1)', while this compiler is 'Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)'). Please select a toolchain which matches the SDK. 2 | // swift-compiler-version: Apple Swift version 6.4 effective-5.10 (swiftlang-6.4.0.31.4 clang-2100.3.31.1) 3 | // swift-module-flags: -target arm64e-apple-macos27.0 -enable-objc-interop -target-arch-variant arm64e.x1 -enable-library-evolution -language-mode 5 -O -library-level api -enable-experimental-feature AnyAppleOSAvailability -enable-upcoming-feature InferSendableFromCaptures -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -user-module-version 8.0.84.1.406 -module-name SwiftUI -package-name SwiftUICompiling it with Xcode 27 ends without error. Do you see any other root cause than the one mentionned: Xcode 27.1 uses swiftlang-6.4.0.34.1 clang-2100.3.34.1 while internal sdk was compiled with swiftlang-6.4.0.31.4 clang-2100.3.31.1 ?
Replies
1
Boosts
0
Views
227
Activity
2w
Adjusting Spacing in ArrangementView
I am trying to adjust the spacing between the primary and secondary views within a SwiftUI ArrangementView. I haven't been able to find a direct parameter or modifier (like spacing) that controls this distance on the container itself. Is there a standard way to achieve this, or should I be looking into a workaround using padding ?
Replies
3
Boosts
0
Views
443
Activity
2w
iOS and Android
I currently have a iOS app live on the App Store but I also want to release it on Android, the whole code is in Swift so would that be possible or would I have to rewrite my whole apps code in a different coding language.
Replies
3
Boosts
0
Views
3.9k
Activity
2w
From Bytes to Gigabytes in a readable format
Hi, I’ve been wondering how Apple calculates Gigabytes in Finder, as I haven’t been able to find any function that yields the result shown. I would like to convert 1,303,412,493 Bytes. It says 1.3 GB in the top right corner, which matches my own conversion. let byteCountFormatStyle = ByteCountFormatStyle(style: .file, allowedUnits: .all, spellsOutZero: false, includesActualByteCount: false, locale: Locale.current) let sizeFormatStyle = byteCountFormatStyle.format(Int64(1_303_412_493)) let byteMeasurement = Measurement(value: Double(1_303_412_493), unit: UnitInformationStorage.bytes) let sizeMeasurement = byteMeasurement.formatted(.byteCount(style: .file)) print("sizeFormatStyle: \(sizeFormatStyle), sizeMeasurement: \(sizeMeasurement)")Both are the same: sizeFormatStyle: 1.3 GB, sizeMeasurement: 1.3 GB But how do I arrive at the 1.51 GB figure that appears next to the Byte count? Christian
Replies
2
Boosts
0
Views
378
Activity
2w
UIDesignRequiresCompatibility for Xcode27
Hallo everyone, We are building our app with Xcode 27 and noticed that UIDesignRequiresCompatibility still appears to be honored on iOS 26 devices. Questions: Could you confirm whether this key is still supported on iOS 26 when built with Xcode 27? If our deployment target includes iOS 26, should we keep the key for backward compatibility, or is Apple's recommendation to remove it entirely? Additionally, are there any risks associated with removing it for iOS 26 users?
Replies
1
Boosts
0
Views
542
Activity
2w
Third-party keyboards get an extra 17pt gap at the top after switching apps on iOS 27 beta.
Feedback submitted: FB24460699 The sample projects are attached to the feedback report. Environment:iOS27 Beta6; iPhone 17Pro Problem:I have encountered a consistently reproducible third-party custom keyboard layout issue in iOS 27.0 beta 1 through beta 6. The custom keyboard initially appears correctly. If I switch apps while the text input remains focused and the keyboard remains visible, and then return to the host app, the system adds a 17-point area above the custom keyboard extension. Steps to reproduce Install and enable a third-party custom keyboard. Switch to the sample custom keyboard and open the host app so that the text editor in the center receives focus. Do not dismiss the keyboard or remove focus from the editor. Return to the Home Screen or switch to another app. Return to the host app. A new blank area now appears above the custom keyboard content. I tested both a system-determined extension view height and an extension view explicitly constrained to 180 points. Both configurations produce exactly the same change. After the foreground transition, the following extension-side values remain unchanged: view.bounds inputView.bounds extension.window.bounds view.safeAreaInsets, which remains {0, 0, 0, 0} The requested 180-point extension height Only the system keyboard frame received by the host app increases by 17 points. I also drew a rounded pink boundary inside the transparent extension root view. When the issue occurs, the new area appears outside that boundary. I tested several third-party keyboards and reproduced the issue with all of them. This suggests that the behavior is caused by iOS rather than by my app. Questions On iOS 27, is it expected behavior for a custom keyboard to gain a 17pt top area after its host app returns from the background? If this is a system issue, is there any workaround that can be used until it is fixed?
Replies
9
Boosts
9
Views
1.6k
Activity
2w
I can't write on Run view on Swift Playground
Hi there! I'm pretty new in coding. Right now I'm just vibe coding, trying to understand what happens and how does this works. I made a simple app in Swift Playground on my iPad Mini A17 Pro, and everything works good so far when I tap the Play (Run) button, except text input: every text field only shows the blinking cursor and let me paste, but the virtual keyboard don't appear, and even connecting a physical keyboard has no better outcome. What am I doing wrong? Thanks.
Replies
4
Boosts
1
Views
495
Activity
2w
Full screen
Hello. Do you know how to make full screen on SwiftUI? Not like when you tap on green circle placed top-left side in any MacOS app, now my app opens on small window but I need to this app was stretched for horizontal and vertical sides
Replies
0
Boosts
0
Views
1.2k
Activity
2w
Adding MCP and connector support to your own Foundation Models apps
Circling back on the LocalLM Lab arc. With v0.7, we've moved from prompt experimentation into real app development on Apple's Foundation Models local AI. The LocalLM Lab SDK lets you build that same on-device model and MCP client this thread has covered directly into your own app, with real tool and data access (Slack, Todoist, GitHub, Notion, Linear, plus Calendar, Reminders, Contacts and Location). And you can ship your app including through the Mac App Store. This is a big improvement over version 0.6, where the localai-cli toolkit needed LocalLM Lab installed and running. On the other hand, the SDK (LocalLMLabSDKCore) doesn't relay through anything; it links FoundationModels and a real MCP client directly into your own binary and is totally self-contained. The example included in the SDK, Plate Today, has actually been built into a sandboxed test app and verified working, with a signed path to a Mac App Store .pkg (Apple Distribution signing + provisioning profile pipeline). That's "verified signable and sandbox-compatible," to be precise. Entitlements (from personal experience: always a complicated topic): com.apple.security.app-sandbox + com.apple.security.network.client for the app itself, plus the standard personal-information entitlements per connector used (com.apple.security.personal-information.calendars, .addressbook, .location) and matching NS*UsageDescription strings in Info.plist. The one worth flagging specifically: the network entitlement is easy to miss and fails silently rather than throwing. Without it, MCP connections and Weather calls just hang with no error surfaced. OAuth handling requires the app delegate callback (application(_:open:)), not SwiftUI's .onOpenURL. Worth knowing before wiring it up if you're SwiftUI-only. Full entitlements list + SDK guide: https://github.com/ancientcomputing/locallm/blob/main/docs/sdk-guide.md Feature page: thisbrain.ai/locallm/sdk.html I hope the availability of the SDK (free, Apache 2.0 license) will give folks further incentive to explore local AI-enabled applications on the Mac. What else would you want to do that the SDK doesn't currently support? File picker? Calendar/Reminders/Contacts edits & writes?
Replies
7
Boosts
1
Views
4.5k
Activity
3w