/r/swift
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
Dedicated to the Swift programming language released by Apple. More info in the Swift Wiki.
Please, check the FAQs before submitting.
General Swift Discussion
irc.freenode.net #swift-lang
Cocoa/Cocoa Touch Discussion
irc.freenode.net #cocoa-init
Keywords: swift, swiftlang, ios, os x, apps, apple, mac, iphone, ipad
/r/swift
I am looking to get into server side swift and after some research Vapor seems to be the framework of choosing. Now I only recently got into Swift, specifically Swift 6 to build an app and now Vapor 4 seems to be built on older version of the Swift language. Vapor 5 would be fully built on Swift 6. It seems like there is no info online or even a hint, when Vapor 6 could come out, only some announcements that it is in development and that is 5 months ago. So anything new?
I've seen a few questions about rules for the Swift Student Challenge. Your best best for definitive answers is to ask these in Apple's developer forums - there's one specific to the Swift Student Challenge here: https://developer.apple.com/forums/topics/community/community-swift-student-challenge
What devices will the judges be running to simulate the playground?
Skip framework allows you to create native iOS and Android applications in Swift & SwiftUI.
Here are few resources to get you started.
- What is Skip Tools? https://youtu.be/ts0SuKiA5fo
- Installing and Running Your First Step App https://youtu.be/o6KYZ5ABIgQ
- Displaying Maps Using Skip https://youtu.be/Cq17ZlKdz0w#iosdev
Does anyone have a best practice for sharing a few (code) files between multiple projects?
I've got a light weight chat view/socket that I would like to share between 3 apps, but copy/pasting them seems like a horrible way to manage it. My initial thought it to create a small repo for them and include them but I have yet to do something like that in swift/Xcode.
Any recommendations? Thanks!
I was making this app for swift student challenge but I was wondering since I cannot forcibly lock orientation in swift playgrounds, can I make app in landscape and put a note or instructions to hold device in landscape?
I actually made my app as Xcode project but I saw the requirements and they ask to make swift playgrounds app (.swiftpm)
Excited to launch my new SwiftUI Pinterest Clone tutorial series! I'll be building a Pinterest-style app using SwiftUI, Firebase & Cloudinary! 🔥
âś… Basic & advanced UI implementations
âś… Google & Facebook Sign-In
âś… Email/Password Authentication
âś… iOS 17's Observation framework for state management
âś… Multi-language support with String Catalogs
✅ …and a lot more!
Watch here 👉 https://www.youtube.com/watch?v=93NclDIZrE8
Hello!
I just started Swift, I have no experience with it, but I have an FP background and I wish to translate the knowledge I have to swift (mostly FP + DDD).
I have seen that Swift natively have Result, Optional types, ADT that is very nice for functional programming but I need a little bit more (applicatives, traversable...), so I checked many librairies on the internet, same observation, they all look abandoned (swift prelude, bow...)
So my question is, what to use to do FP in Swift in 2025 ?
🙏
Hi everyone,
I'm a beginner looking to develop two different apps, but I'm unsure about the best approach in terms of learning and choosing a development framework/language. I have a few months worth of learning with Python and have completed a handful of small projects as well as making decent progress on FreeCodeCamp. I have a lot of free time (similar to a full-time role + weekends), so I i'd like to focus on 'mastering' one language and incorparating it into my projects.
From my research, I see that Swift is great for iOS development and supposedly has an easy-to-learn UI system. However, I've also come across React Native and Flutter, which seem better for cross-platform development.
I’m conflicted about the best way to proceed:
Since I’m a beginner, I’d love to hear from experienced developers:
Thank you
Hey everyone,
I started with a simple Python script that grew into a full AI product with its own backend and website!
I was tired of spending hours manually updating translation files every time I added a new screen. It was error-prone and the existing solutions were either too complicated or just didn't work for me. So, I built my own.
Now, translating is easy:
I’d love to hear your feedback—whether it's about the product, the website, or anything I can improve. Thanks for checking it out!
website: https://www.easilytranslate.com/ app store: https://apps.apple.com/in/app/easily-translate-strings/id6740238083?mt=12
Every year I like to watch the WWDC. After that I want to watch the developer sessions. But I find it overwhelming. It feels like they are talking about things everybody knows, but I don't...
Same for watching the developer sessions of previous WWDC... I don't even know where to start... I don't recognize an entry point or an order to watch the videos.
I would like to ask the community:
how is your feeling around this? how do you prepare for it? if you even do... and do you have some advice for me?
I am a junior web and mobile developer.
And I want to become a proficient iOS developer.
Thanks in advance for your responses.
Hey everyone! Just wanted to share a Swift library I’ve been working on that simplifies pushing real-time data (not Apple Push Notifications in the usual sense) to iOS apps using gRPC streams. It’s great for scenarios where you need state synced across devices or want to update your UI in real time—think live order tracking, location sharing, or instant deals. Unlike standard push notifications, you have full control over structured JSON data, so you can send it in any format and handle it however you need within your app.
Some highlights:
If you’re curious or have any questions, I’d love some feedback from other Swift devs. Thanks!
Links:
I was wanting to hear the opinion of people who have transitioned to Swift from C#.
Are their language features that you miss?
Do you try to solve problems the same that you would in .NET and realize it doesn’t jive well in swift?
How long did it take for you to become comfortable with the nuance between the languages?
or any other opinion you may have one way or the other.
Swift’s strong type system, especially its handling of optionals make it genuinely difficult to write some bugs is very reminiscent of rust.
However, automated reference counting makes writing it so much less obtuse to write Rust
I think the primary reason swift isn’t more widely adopted is because of the stigma it has gained as a domain specific language for Apple platforms.
Hi everyone, I'm a designer looking to learn Swift and hopefully start iOS development on my own. I'm curious if you have any tips or advice you would've appreciated when you first started. Are there any online courses that you'd recommend? YouTube is usually my friend when I start learning something but appreciate anything you can share.
Also, if I end up being serious about it, is the new Mac Mini M4 pro sufficient? Thanks in advance for your response.
Its been around 2 weeks since I've sent out my appeal to apple after my 3rd rejection for spam. So far, I have received absolutely nothing. What should i do?
Cursor deleted my content view iPhone for some reason in Xcode. Now I can only test the app I am creating by launching on a virtual phone after each code change. How do I get that default content view phone back? I have no coding knowledge so please explain it like I’m 5.
I need to integrate a feature module into my application. This feature module consumes a private API, which requires passing a bearer token.
The authentication will be handled in the app, and the token should be passed to the module. What are some safe ways to do this? Would using the keychain be sufficient?
I am working on a very simple app to get user location, display the latitude and longitude, and update the values as the user moves. The code compiles and runs on a physical but the values don't seem to change even if I move a significant enough distance that they should.
Also the checkIfLocationServicesIsEnabled threw this warning " This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization:
callback and checking authorizationStatus
first." So it's currently not being used.
I am still getting used to apple user location so any help with any aspect of that would be greatly appreciated.
import SwiftUI
import MapKit
struct ContentView: View {
@StateObject private var viewModel = ContentViewModel()
var body: some View {
VStack {
Text("Latitude is \(viewModel.locationManager?.location?.coordinate.latitude ?? 0.0)")
Text("Longitude is \(viewModel.locationManager?.location?.coordinate.longitude ?? 0.0)")
}
.onAppear(){
//viewModel.checkIfLocationServicesIsEnabled()
viewModel.makeManager()
}
.padding()
}
}
#Preview {
ContentView()
}
final class ContentViewModel: NSObject, ObservableObject, CLLocationManagerDelegate{
@Published var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0), span: MKCoordinateSpan(latitudeDelta: 0.0, longitudeDelta: 0.0))
var locationManager: CLLocationManager?
func checkIfLocationServicesIsEnabled(){
if CLLocationManager.locationServicesEnabled(){
locationManager = CLLocationManager()
locationManager!.desiredAccuracy = kCLLocationAccuracyBest
locationManager!.delegate = self
} else {
print("Error no location on")
}
}
func makeManager(){
locationManager = CLLocationManager()
locationManager!.delegate = self
}
private func checkLocationAuthorization(){
guard let locationManager = locationManager else {return}
switch locationManager.authorizationStatus{
case .notDetermined:
locationManager.requestWhenInUseAuthorization()
case .restricted:
print("Restricted")
case .denied:
print("Denied")
case .authorizedAlways, .authorizedWhenInUse:
region = MKCoordinateRegion(center: locationManager.location!.coordinate, span: MKCoordinateSpan(latitudeDelta: 0, longitudeDelta: 0))
@unknown default:
break
}
}
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
checkLocationAuthorization()
}
}
I’m developing an app where the user can hand write sheet music and the app will recognize what they wrote and input it as actual notes, how could I go about doing this? (If you’d like a reference, i’m trying to make something similar to StaffPad)
I'm thinking of working on a project and competing in the student swift challenge. I'm in my last year of university and I was curious if it's normal for college students to compete in this challenge.
I want to test some simple SwuftData encoding and decoding code I’ve written. The Xcode playground keeps crashing. I’ve tried various online playgrounds and all crap out on the “import SwiftData” line saying “No such module”
Anyone have any ideas? Many thanks
I’ve tried jdoofle, swiftplayground.run, swiftfiddle, programiz and others
I'm using the Screen Time API and I'm asking the user to select apps they want to temporariliy shield with familyActivityPicker. Instead, is there a way to make the app shield all apps without asking the user to select which ones? E.g. here:
class MyMonitor: DeviceActivityMonitor {
override func intervalDidStart(for activity: DeviceActivityName) {
super.intervalDidStart(for: activity)
let model = MyModel()
let applications = model.selectionToDiscourage.applications
store.shield.applications = applications.isEmpty ? nil : applications
}
I want it to just shield everything without having to ask the user.
static func fetchFeedPostsWithPagination(lastDocument: DocumentSnapshot?, limit: Int) async throws -> (posts: [Post], lastDocument: DocumentSnapshot?) {
let uid = Auth.auth().currentUser?.uid
let currentUser = try await UserService.fetchUser(withUid: uid ?? "")
let userCategories = currentUser.categories?.keys.map { $0 } ?? []Â // Convert keys to an array
var query: Query = postsCollection
if !userCategories.isEmpty {
query = query.whereField("category", in: userCategories)
}
query = query.order(by: "timestamp", descending: true)
query = query.limit(to: limit)
if let lastDocument = lastDocument {
query = query.start(afterDocument: lastDocument)
}
let snapshot = try await query.getDocuments()
var posts = try snapshot.documents.compactMap { try $0.data(as: Post.self) }
for i in 0 ..< posts.count {
let ownerUid = posts[i].ownerUid
let postUser = try await UserService.fetchUser(withUid: ownerUid)
posts[i].user = postUser
}
let lastDoc = snapshot.documents.last
return (posts, lastDoc)
}
 I’ve tried using .order to prioritize posts based on categories in a user’s array of interests, but I can’t figure out how to implement it correctly. Additionally, I want to maintain pagination since there will be a large number of posts, and I don’t want to fetch them all at once. How can I achieve this?