Discuss Swift.

Swift Documentation

Posts under Swift subtopic

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.6k
Oct ’25
Adding days to a date using the result of a division operation
var testTwo: Double = 0 testDouble = 80 testTwo = 200 var testThree: Int = 0 testThree = Int(testTwo/testDouble) var testDate: Date = .now var dateComponent = DateComponents() dateComponent.day = testThree var newDate: Date = Calendar.current.date(byAdding: dateComponentwith a thread error , to: testDate)! This code works in a playground. However, when I try to use it in Xcode for my app it fails with the following error: Thread 1: Fatal error: Double value cannot be converted to Int because it is either infinite or NaN I printed the value being converted to Int and it was not NAN or infinite.
2
0
917
Nov ’25
Swift Package file - resources .copy rule with nested directories
Does anyone know if the resources .copy rule in a Swift .package file is supposed to recursively copy the full contents if it's pointed at a directory? The docs say… If you pass a directory path to the copy rule, the compiler retains the directory’s structure. …but you can interpret that in a few different ways. It also doesn’t appear to work if the directory you specify only contains directories.
1
0
747
Jan ’26
Why is the Documentation full of Conundrums?
I'm trying to learn and focus on the task and your examples keep having hidden conundrums in them. Here is an example that got me snagged for hours last night going, Well what the F do they want me to name it? What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for... My friend said to me that this is a common thing you will have to do and they were right however... What are you asking me to do? Get stuck on the variable naming problem where I'm going... Yeah those are math terms from 20+ years ago and I have no idea how to classify those terms... Are you asking me that? No. So why is that in the problem. These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.
1
0
112
9h
Attached macro loses generated source file
I’m seeing what looks like a compiler / macro-expansion / build-pipeline issue. Environment: Xcode 26.4 RC (17E192, latest); I believe it is also reproducible on earlier versions. github source code I reduced this to a very small macOS/iOS app plus a local macro package. The app logic is trivial, but app exits immediately on launch with code 138 Important observations: If I inline everything into a single file, the problem disappears. I also see an error like this during investigation: The file path does not exist on the file system: /var/folders/.../swift-generated-sources/@__swiftmacro_18MacroFeedbackRepro20MountActivationState17PreservedRawValuefMm_.swift That makes me suspect this is not an application logic issue, but something in macro expansion / generated source handling / compiler pipeline.
0
0
119
17h
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.6k
Activity
Oct ’25
Adding days to a date using the result of a division operation
var testTwo: Double = 0 testDouble = 80 testTwo = 200 var testThree: Int = 0 testThree = Int(testTwo/testDouble) var testDate: Date = .now var dateComponent = DateComponents() dateComponent.day = testThree var newDate: Date = Calendar.current.date(byAdding: dateComponentwith a thread error , to: testDate)! This code works in a playground. However, when I try to use it in Xcode for my app it fails with the following error: Thread 1: Fatal error: Double value cannot be converted to Int because it is either infinite or NaN I printed the value being converted to Int and it was not NAN or infinite.
Replies
2
Boosts
0
Views
917
Activity
Nov ’25
Swift Package file - resources .copy rule with nested directories
Does anyone know if the resources .copy rule in a Swift .package file is supposed to recursively copy the full contents if it's pointed at a directory? The docs say… If you pass a directory path to the copy rule, the compiler retains the directory’s structure. …but you can interpret that in a few different ways. It also doesn’t appear to work if the directory you specify only contains directories.
Replies
1
Boosts
0
Views
747
Activity
Jan ’26
Why is the Documentation full of Conundrums?
I'm trying to learn and focus on the task and your examples keep having hidden conundrums in them. Here is an example that got me snagged for hours last night going, Well what the F do they want me to name it? What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for... My friend said to me that this is a common thing you will have to do and they were right however... What are you asking me to do? Get stuck on the variable naming problem where I'm going... Yeah those are math terms from 20+ years ago and I have no idea how to classify those terms... Are you asking me that? No. So why is that in the problem. These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.
Replies
1
Boosts
0
Views
112
Activity
9h
Attached macro loses generated source file
I’m seeing what looks like a compiler / macro-expansion / build-pipeline issue. Environment: Xcode 26.4 RC (17E192, latest); I believe it is also reproducible on earlier versions. github source code I reduced this to a very small macOS/iOS app plus a local macro package. The app logic is trivial, but app exits immediately on launch with code 138 Important observations: If I inline everything into a single file, the problem disappears. I also see an error like this during investigation: The file path does not exist on the file system: /var/folders/.../swift-generated-sources/@__swiftmacro_18MacroFeedbackRepro20MountActivationState17PreservedRawValuefMm_.swift That makes me suspect this is not an application logic issue, but something in macro expansion / generated source handling / compiler pipeline.
Replies
0
Boosts
0
Views
119
Activity
17h