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"
                    
                  
                Swift
RSS for tagSwift is a powerful and intuitive programming language for Apple platforms and beyond.
Posts under Swift tag
            
              
                200 Posts
              
            
            
              
                
              
            
          
          
  
    
    Selecting any option will automatically load the page
  
  
  
  
    
  
  
              Post
Replies
Boosts
Views
Activity
                    
                      We are having an issue with our app after upgrading to WatchOS 26. After some time our complication disappears from the watch face. If you go to add it back, our app shows up with an empty icon placeholder and you are unable to tap it to add it back. Sometimes restarting the watch will bring it back, sometimes it does not. Has anyone experienced this? What should we be looking at to figure out why this is happening? Or could this be a bug in WatchOS 26?
                    
                  
                
                    
                      I have a project that leverages XPC and has interoperability between Swift and Objective-C++. I am presently getting a compile-time error in one of our unit test targets, of "Argument passed to call that takes no arguments" on the following code:
let interface = NSXPCInterface(with: XPCServiceDelegate.self)
My XPCServiceDelegate protocol is defined as:
@objc(XPCServiceDelegate) public protocol XPCServiceDelegate {
    //...
}
For the longest time, this code has compiled successfully, and it has not recently changed. There are two confusing things about this error. The first is that I have a different build scheme that will compile correctly other code with the same structure. The  other is that I have team members that are able to compile my failing scheme successfully on the same XCode version, OSVersion, and branch of our repository.
I've attempted numerous things to try to get this code to compile, but I've run out of ideas.
Here's what I've tried:
Clean build both on XCode 16.4 and XCode 26 Beta
Delete DerivedData and rebuild on XCode 16.4 and XCode 26 Beta
Delete and re-clone our git repository
Uninstall and reinstall XCode
Attempt to locate cached data for XCode and clear it out. (I'm not sure if I got everything that exists on the system for this.)
Ensure all OS and XCode updates have been applied.
The interface specification for NSXPCInterface clearly has an initializer with one arguement for the delegate protocol, so I don't know why the compiler would fail for this. Is there some kind of forward declaration or shadowing of NSXPCInterface? Do you have any ideas on what I could try next?
                    
                  
                
                    
                      I have an swift command line tool that changes proxy settings in system preferences via SystemConfiguration framework, does some stuff, and in the end reverts proxy settings back to original.
Here is simplified code:
var authorization: AuthorizationRef?
let status = AuthorizationCreate(nil, nil, [], &authorization)
let prefs = SCPreferencesCreateWithAuthorization(nil, "myapp" as CFString, nil, authorization)
// change proxy setttings
// do some stuff
let prefs2 = SCPreferencesCreateWithAuthorization(nil, "myapp" as CFString, nil, authorization)
// change proxy settings back to original
When I try to change settings for the first time, the system dialog appears requesting permission to change network settings. If I try to change settings again within а short period of time, the dialog does not appear again. However, if it takes more than several minutes after first change, the dialog does appear again. Is there a way to create authorization, so that the dialog appears only once per app launch, no matter how much time passed since the first dialog?
                    
                  
                
                    
                      Is it possible to start screen recording (through Control Center) without user prompt?
I mean to ask user permission for the first time and after that to start and stop recording programmatically only?
I need to record screen only for specific events.
                    
                  
                
                    
                      Hello,
I'm trying to remove a localization from a String Catalog in a Swift Package. How can I do that?
I tried to remove the file and create a new one, but all the languages are back. The only place where I've found a reference to the languages is in Package/.swiftpm/xcode/package.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate
But I don't know how to edit this file to remove a language.
Thank you,
Axel
                    
                  
                
                    
                      Lately I am getting this error.
GenerativeModelsAvailability.Parameters: Initialized with invalid language code: en-GB. Expected to receive two-letter ISO 639 code. e.g. 'zh' or 'en'. Falling back to: en
Does anyone know what this is and how it can be resolved. The error does not crash the app
                    
                  
                
                    
                      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)
            }
        }
    }
                    
                  
                
                    
                      In the iOS Photos app there is a caption field the user can write to.  How can you write to this value from Swift when creating a photo?
I see apps that do this, but there doesn't seem to be any official way to do this using the Photo library through PHAssetCreationRequest or PHAssetResourceCreationOptions or setting EXIF values, I tried settings a bunch of values there including IPTC values but nothing appears in the caption field in the iOS photos app.
There must be some way to do it since I see other apps setting that value somehow after capturing a photo.
                    
                  
                
                    
                      Hello,
I am trying to publish a simple app to the App Store for the first time, and I am getting these 2 errors.
Please note the knowledge base URLs shown in the screenshot are not clickable. I think this should be addressed.
Any guidance on how to correct these issues will be greatly appreciated.
Sincerely,
Anis
                    
                  
                
                    
                      I’m building a macOS document based app using SwiftUI’s DocumentGroup API. By default, when a document based app launches, macOS automatically shows a file open panel or creates a new untitled document window.
However, I want to suppress this default behavior and instead show a custom welcome window when the app starts — something similar to how Xcode or Final Cut Pro shows a “Welcome” or “Start Project” screen first.
So basically, when the user opens the app normally, it should not open the document selector or create a document automatically. Instead, it should show my custom SwiftUI or AppKit window. Here is my Code :-
//MyApp.swift
import SwiftUI
import AppKit
@main
struct PhiaApp: App {
    @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    var body: some Scene {
        DocumentGroup(newDocument: MyDocumentModel()) { file in
            EditorView(document: file.document, filePath: file.fileURL)
        }
        
        Settings { EmptyView() }
    }
}
Current I have this code setup for my MainApp.swift, where I am using the AppDelegate to create a custom recording window using appkit and also defining the DocumentGroup to handle the custom .myapp file opens. However, when I launch the app, its showing my appkit window as well as the macOs native file Selector to select the file I want to open.
I want when the user opens the app normally, it should not open the document selector or create a document automatically. Instead, it should show my custom SwiftUI or AppKit window. However, the app should still fully support opening .myapp documents by double clicking from Finder, using the standard File → Open and File → New menu options, also having multiple document windows open at once.
This is my AppDelegate.swift file :-
import AppKit
import SwiftUI
class AppDelegate: NSObject, NSApplicationDelegate {
    var panel: Panel?
    private var statusItem: NSStatusItem?
    func applicationDidFinishLaunching(_ notification: Notification) {
        showWindow()
    }
    // MARK: - Window control
    func showWindow() {
        if panel == nil {
            let root = RecordingViewMain()
            let newPanel = Panel(rootView: root)
            if let screen = NSScreen.main {
                let size = NSSize(width: 360, height: 240)
                let origin = NSPoint(
                    x: screen.visibleFrame.midX - size.width / 2,
                    y: screen.visibleFrame.midY - size.height / 2
                )
                newPanel.setFrame(NSRect(origin: origin, size: size), display: true)
            }
            panel = newPanel
        }
        panel?.makeKeyAndOrderFront(nil)
    }
    func hideWindow() {
        panel?.orderOut(nil)
    }
    @objc private func showPanelAction() {
        showWindow()
    }
    @objc private func quitAction() {
        NSApp.terminate(nil)
    }
}
                    
                  
                
                    
                      I got several reports about our TestFlight app crashing unconditionally on 2 devices (iOS 18.1 and iOS 18.3.1) on app start with the following reason:
Termination Reason: DYLD 4 Symbol missing
Symbol not found: _$sScIsE4next7ElementQzSgyYa7FailureQzYKF
(terminated at launch; ignore backtrace)
The symbol in question demangles to
(extension in Swift):Swift.AsyncIteratorProtocol.next() async throws(A.Failure) -> A.Element?
Our deploy target is iOS 18.0, this symbol was introduced in Swift 6.0, we're using latest Xcode 16 now - everything should be working, but for some reason aren't.
Since this symbol is quite rarely used directly, I was able to pinpoint the exact place in code related to it. Few days ago I added the following code to our app library (details omitted):
public struct AsyncRecoveringStream<Base: AsyncSequence>: AsyncSequence {
    ...
    public struct AsyncIterator: AsyncIteratorProtocol {
        ...
        public mutating func next(isolation actor: isolated (any Actor)? = #isolation) async throws(Failure) -> Element? {
            ...
        }
    }
}
I tried to switch to Xcode 26 - it was still crashing on affected phone. Then I changed next(isolation:) to its older version, next():
public mutating func next() async throws(Failure) -> Element?
And there crashes are gone. However, this change is a somewhat problematic, since I either have to lower Swift version of our library from 6 to 5 and we loose concurrency checks and typed throws or I'm loosing tests due to Swift compiler crash. Performance is also affected, but it's not that critical for our case.
Why is this crash happening? How can I solve this problem or elegantly work around it?
Thank you!
2025-10-09_17-13-31.7885_+0100-23e00e377f9d43422558d069818879042d4c5c2e.crash
                    
                  
                
                    
                      Hi everyone,
I'm encountering an unexpected behavior with modal presentations in UIKit. Here’s what happens:
I have UIViewControllerA (let’s call it the "orange" VC) pushed onto a UINavigationController stack.
I present UIViewControllerB (the "red" VC, inside its own UINavigationController as a .formSheet) modally over UIViewControllerA.
After a short delay, I pop UIViewControllerA from the navigation stack.
Issue:
After popping UIViewControllerA, the modal UIViewControllerB remains visible on the screen and in memory. I expected that dismissing (popping) the presenting view controller would also dismiss the modal, but it stays.
Expected Behavior:
When UIViewControllerA (orange) is popped, I expect the modal UIViewControllerB (red) to be dismissed as well.
Actual Behavior:
The modal UIViewControllerB remains on screen and is not dismissed, even though its presenting view controller has been removed from the navigation stack.
Video example: https://youtube.com/shorts/sttbd6p_r_c
Question:
Is this the expected behavior? If so, what is the recommended way to ensure that the modal is dismissed when its presenting view controller is removed from the navigation stack?
Code snippet:
class MainVC: UIViewController {
  private weak var orangeVC: UIViewController?
  override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = .blue
    let dq = DispatchQueue.main
    dq.asyncAfter(deadline: .now() + 1) { [weak self] in
      let vc1 = UIViewController()
      vc1.view.backgroundColor = .orange
      vc1.modalPresentationStyle = .overCurrentContext
      self?.navigationController?.pushViewController(vc1, animated: true)
      self?.orangeVC = vc1
      dq.asyncAfter(deadline: .now() + 1) { [weak self] in
        let vc2 = UIViewController()
        vc2.view.backgroundColor = .red
        vc2.modalPresentationStyle = .formSheet
        vc2.isModalInPresentation = true
        let nav = UINavigationController(rootViewController: vc2)
        if let sheet = nav.sheetPresentationController {
          sheet.detents = [.medium()]
        }
        self?.orangeVC?.present(nav, animated: true)
        dq.asyncAfter(deadline: .now() + 1) { [weak self] in
           self?.navigationController?.popViewController(animated: true)
        }
      }
    }
  }
}
Thank you for your help!
                    
                  
                
                    
                      Xcode downloaded a crash report for my app that crashed when trying to insert a String into a Set<String>. Apparently there was an assertion failure ELEMENT_TYPE_OF_SET_VIOLATES_HASHABLE_REQUIREMENTS. I assume that this assertion failure happened because the hash of the new element didn't match the hash of an equal already inserted element, but regardless, I don't understand how inserting a simple string could trigger this assertion.
Here is essentially the code that leads to the crash. path is any file system directory, and basePath is a directory higher in the hierarchy, or path itself.
var scanErrorPaths = Set<String>()
func main() {
    let path = "/path/to/directory"
    let basePath = "/path"
    let fileDescriptor = open(path, O_RDONLY)
    if fileDescriptor < 0 {
        if (try? URL(fileURLWithPath: path, isDirectory: false).checkResourceIsReachable()) == true {
            scanErrorPaths.insert(path.relativePath(from: basePath)!)
        return
    }
}
extension String {
    func relativePath(from basePath: String) -> String? {
        if basePath == "" {
            return self
        }
        guard let index = range(of: basePath, options: .anchored)?.upperBound else {
            return nil
        }
        return if index == endIndex || basePath == "/" {
            String(self[index...])
        } else if let index = self[index...].range(of: "/", options: .anchored)?.upperBound {
            String(self[index...])
        } else {
            nil
        }
    }
}
crash.crash
                    
                  
                
                    
                      I am currently developing a macOS app that can show system HUDs in the Notch
Till Sequoia I used to kill the OSDUIHelper process (which displays the default macOS Volume and Brightness control HUDs) - and replaced it with my app's HUDs
But, it is not working on macOS Tahoe anymore as the OSDUIHelper process is no longer there due to the UI changes
Has the process been renamed - or is there any other way to kill the process?
                    
                  
                
              
                
              
              
                
                Topic:
                  
	
		App & System Services
  	
                
                
                SubTopic:
                  
                    
	
		Processes & Concurrency
		
  	
                  
                
              
              
                Tags:
              
              
  
  
    
      
      
      
        
          
            Swift
          
        
        
      
      
    
      
      
      
        
          
            macOS
          
        
        
      
      
    
      
      
      
        
          
            SwiftUI
          
        
        
      
      
    
      
      
      
        
          
            Background Tasks
          
        
        
      
      
    
  
  
              
                
                
              
            
          
                    
                      We are not receving incoming call from blocked numbers below iOS 26 versions but same in iOS 26 onwards we are receiving the incoming call..
Can you please provide any solutions to fix the issue
                    
                  
                
                    
                      I'm developing an iOS application in Swift that performs API calls using URLSession.shared. The requests work correctly when the app is in the foreground. However, when the app transitions to the background (for example, when the user switches to another app), the ongoing API calls are either paused or do not complete as expected.
What I’ve tried:
Using URLSession.shared.dataTask(with:) to initiate the API requests
Observing application lifecycle events like applicationDidEnterBackground, but haven't found a reliable solution to allow requests to complete when backgrounded
Goal:
I want certain API requests to continue running or be allowed to complete even if the app enters the background.
Question:
What is the correct approach to allow API calls to continue running or complete when the app moves to the background?
Should I be using a background URLSessionConfiguration instead of URLSession.shared?
If so, how should it be properly configured and used in this scenario?
                    
                  
                
                    
                      I'm developing an iOS application in Swift that performs API calls using URLSession.shared. The requests work correctly when the app is in the foreground. However, when the app transitions to the background (for example, when the user switches to another app), the ongoing API calls are either paused or do not complete as expected.
What I’ve tried:
Using URLSession.shared.dataTask(with:) to initiate the API requests
Observing application lifecycle events like applicationDidEnterBackground, but haven't found a reliable solution to allow requests to complete when backgrounded
Goal:
I want certain API requests to continue running or be allowed to complete even if the app enters the background.
Question:
What is the correct approach to allow API calls to continue running or complete when the app moves to the background?
Should I be using a background URLSessionConfiguration instead of URLSession.shared?
If so, how should it be properly configured and used in this scenario?
                    
                  
                
                    
                      We are building a CarPlay app and have run into an issue with data updates.
When the app is running on the CarPlay display and the iPhone screen is locked, no data updates are shown on the CarPlay screen. As soon as the phone is unlocked, the data updates appear instantly on the CarPlay display.
Has anyone encountered this behavior before? Is there a specific setting, entitlement, or background mode we need to enable in order to ensure the CarPlay app continues to receive and display data while the iPhone is locked?
Any guidance would be greatly appreciated.
                    
                  
                
                    
                      Hi everyone,
I faced an issue that on IOS 26 removeAnnotation method doesn't remove annotation. This code worked on previous versions (IOS 18, 17) but suddenly stopped working on IOS 26.
Has anyone faced this issue?
guard let document = await pdfView.document else { return }
            
            for pageIndex in 0..<document.pageCount {
                guard let page = document.page(at: pageIndex) else { continue }
                let annotations = page.annotations
                for annotation in annotations {
                    page.removeAnnotation(annotation)
                }
            }
                    
                  
                
                    
                      Hello Apple Developer Forum,
I got the following statement from the AI model. It seems it is also reflecting my real-world experience.
Where do I find an official source that fully describes the array on swiftData model behaviour?
When a SwiftData model contains 
an array of value types, such as [String] or [Int], 
the array's order is preserved