/r/swift

Photograph via snooOG

Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.

ATTN! Looking for work or to hire? Check out r/SwiftJobs!


About:

Dedicated to the Swift programming language released by Apple. More info in the Swift Wiki.

Please, check the FAQs before submitting.


IRC Chatrooms:

General Swift Discussion

irc.freenode.net #swift-lang

Cocoa/Cocoa Touch Discussion

irc.freenode.net #cocoa-init

Related Subreddits:


Keywords: swift, swiftlang, ios, os x, apps, apple, mac, iphone, ipad

/r/swift

123,473 Subscribers

2

Any updates on Vapor 5?

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?

0 Comments
2025/02/04
03:05 UTC

2

Ask your Swift Student Challenge rules questions in Apple's forum, not here

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

0 Comments
2025/02/03
23:08 UTC

2

Swift Student Challenge Device

What devices will the judges be running to simulate the playground?

1 Comment
2025/02/03
22:39 UTC

1

🎩 Using ImageRenderer in SwiftUI 🎨

0 Comments
2025/02/03
21:48 UTC

3

Skip Tools - Build Native iOS and Android Apps Using Swift & SwiftUI

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

1 Comment
2025/02/03
20:48 UTC

1

Sharing source files between projects?

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!

8 Comments
2025/02/03
20:21 UTC

2

Landscape app for swift student challenge

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)

3 Comments
2025/02/03
19:36 UTC

2

Pinterest Clone SwiftUI

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

0 Comments
2025/02/03
15:43 UTC

0

Good (and maintained) fp librairy for Swift

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 ?

🙏

15 Comments
2025/02/03
14:44 UTC

1

Novice: Best Development Path for Two Apps – iOS-First vs. Cross-Platform?

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.

  • App 1 (Similar to Instagram & Pintrest): Primarily targeting iOS users at launch, with very long plans to eventually expand to Android and possibly a web version.
  • App 2 (Basic Payment/Transaction - incorporating Stripe and Apple + Google Wallet): Ideally, available on both iOS and Android from the start for accessibility. (Web Dev not needed)

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:

  1. Should I start with SwiftUI since App 1 is iOS-first and I can still make progress on App 2 with it. Then, deal later with migration/integration to Android ?
  2. Or should I start with React Native/Flutter - learning language for both Apps.
  3. Is there any carryover between Swift, React Native, and Flutter that would make learning one first beneficial for the other?

Since I’m a beginner, I’d love to hear from experienced developers:

  • Which language/framework would provide the easiest learning curve while also being useful for both apps?
  • Any recommendations on the most efficient learning path?
  • Having scanned past reddit posts though, I have noticed noticed some negative comments about React Native, is there anything worth keeping in mind?

Thank you

3 Comments
2025/02/03
13:12 UTC

5

Automatic String Localization/Translation mac app

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:

  • Automatic integration with the app
  • Effortless syncing of new and updated keys
  • Auto-adding translation files to the project
  • Add new languages in seconds
  • Markdown support for blogs
  • Support for plain text files

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

0 Comments
2025/02/03
12:28 UTC

6

How to prepare for WWDC

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.

14 Comments
2025/02/03
08:32 UTC

20

I built a library that makes it easy to push real-time data to iOS apps — without WebSockets, Polling, or a Backend

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:

  • Persistent gRPC streams – No WebSockets, no polling, just a direct connection
  • Handles reconnections – No manual reconnection logic needed
  • Workflows for automation – Trigger data pushes based on events, conditions, or user actions
  • Fully managed infra – No servers to set up, no scaling worries
  • A few lines of code – Quick and easy SDK integration
  • Free tier – Try it out without any upfront costs

If you’re curious or have any questions, I’d love some feedback from other Swift devs. Thanks!

Links:

2 Comments
2025/02/03
06:59 UTC

10

Swift vs C#

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.

15 Comments
2025/02/03
04:27 UTC

86

Swift is chill guy Rust — hear me out

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.

35 Comments
2025/02/03
03:09 UTC

3

Swift for Beginners

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.

9 Comments
2025/02/03
02:46 UTC

0

How long do Apple App appeals take ?

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?

3 Comments
2025/02/03
01:52 UTC

2

How can I get the content view iPhone in Xcode back.

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.

8 Comments
2025/02/03
00:29 UTC

2

Safe ways to store and pass bearer tokens through Swift packages?

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?

6 Comments
2025/02/02
20:17 UTC

2

State won't update when the user moves

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()
}

}

0 Comments
2025/02/02
19:29 UTC

3

Recognizing what the user writes with an apple pencil

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)

2 Comments
2025/02/02
18:57 UTC

4

Is it normal for college students to compete in the Student Swift Challenge?

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.

3 Comments
2025/02/02
18:00 UTC

2

Online playground to run SwiftData code

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

0 Comments
2025/02/02
16:50 UTC

0

Identify Carcinogens in 3,000,000+ Products Using CarcinogenX

2 Comments
2025/02/02
15:05 UTC

2

Screen Time API

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.

2 Comments
2025/02/02
05:26 UTC

1

How can I prioritize posts based on categories that match a user's array of interests, showing those posts first, without filtering out the others?

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?

2 Comments
2025/02/01
21:30 UTC

Back To Top