/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
Is it a hassle to get it running quickly on a window? otherwise I will buy a macbook m2
I'm new to Xcode and Swift code in general. I come from a react-native background and I'm trying implement LiveActivies to my app but can't seem to figure out how to get preview working with LiveActivites. I tried asking chatgpt if I can do preview for LiveActivies and it said it was possible but the instructions it gave me did not work.
Is it even possible?
Hey everyone, so straight to the point, I’ve been learning iOS development for a year now and did some tutorials and now I got literally no idea what to do? Do you guys ever got stuck like this. Everything I see or want to build feels like it’s already there or feels like who will use that?
Now with that feeling I’m unable to make anything and so I got nothing, like no projects of my own.
If you have any advice I highly need it.
Hi everyone last couple of days I have been tinkering with SceneKit I just finished swift playgrounds code lessons 1/2 decided to jump into SceneKit but I am struggling in few ways for example since there aren’t many tutorials I stick to the apple documents and chatgpt my status is like I recognize the patterns but when it comes to using frameworks I struggle trying to understand but it’s like a rabbit hole sometimes I just wanna be able to some SceneKit and some controlling to characters simple stuff like that do you think I miss something or it’s not time for me dive in this ocean
I’ve been working on an app using Swift for the client-side (iOS/macOS), and until now, I relied on Firebase Functions (Node.js) for my backend. But with the improvements in Swift on the server (e.g., Vapor) and custom runtimes for Google Cloud Functions (using Docker), I’m starting to wonder: • Can a 100% Swift full stack be a reality for a production app with millions of users? • With Swift’s low cold start times and high performance in serverless environments, does it make sense to transition everything, including real-time features like WebSockets and Firebase integration, to Swift? • Are there any potential pitfalls (e.g., ecosystem size, scalability) for using server-side Swift for all backend logic?
Has anyone successfully built a full-stack app entirely in Swift? Would love to hear your experiences, challenges, or opinions!
If yes, why? If not, which languages would you learn to upskill?
i’m currently a freshmen in college and have a start up project/app i’d like to release between my junior and graduation year; i have some questions and i appreciate any help that anyone can provide
i have some coding experience from highschool but stopped for a while; should i go back and relearn javascript before attempting swift language or just learn swift language on its own and start from there
i’ve seen people reach success by prioritizing ios users and developing their app via swift while not releasing an android version until expansion, what’re ur guys’ thoughts on that and is it recommended
my app concept would function and look similar to a news or social media platform and wouldn’t be too complicated so is using swift for this even recommended? i want to provide the best user experience but at the same time it could be possible to create this app on a no code platform but i dont know
any general advice is appreciated🙌🏽
Has anyone been in the same situation? Can someone let me know where I should go to look for support? I'm desperate :(
This has put us into a very harsh situation. We don't know whether we should continue waiting for it or we should just give up. We were eager to launch the service, then all of a sudden, our enrollment was revoked. The app was there in App Store, but no bugs could be fixed as the update was no longer an option. 3 months, 1 project we truly put our heart into, and multiple people worried about their job positions. We have sent dozens of emails, tried to connect probably 100 hundred times (they never worked but for some reason, if I call from my own account, it always works).
What's the state of Swift on the Server nowadays? How accessible is it? Just for context, I'm familiar with Python's Flask and Rust's Rocket. Also, how is the documentation for it? Last time I checked a few years ago, Vapor's knowledge base seemed to stem from one book by TimOx (spelling).
let colors = repeatElement (Color. rainbow, count: 5). lazy. shuffled().flatMapt { $0 }
I forgot…
Hi,
does anyone check calendar from the terminal on macos?
knowing swift can integrate well with the apple calendar, i wanted to see the calendar events from the terminal.
asked chatgpt and it works well.
if you want to try, i wrote a simple how to in my blog.
https://minho42.com/posts/check-apple-calendar-from-terminal-on-mac/
I'm building a framework similar to SwiftUI, now I'm trying to implement @State
. But I have a problem:
When a struct (like a SwiftUI View) is immutable, how can I implement a property wrapper that stores the data in an external class (like Binding
) that stores the value? Because I cannot do this:
struct MyView: View {
@State private var state = "ABC"
func doesSomething() {
state = "XYZ" // 'self' is immutable
}
}
with this property wrapper:
@propertyWrapper public struct State<T> {
let stateitem: StateItem<T>
public init(wrappedValue: T) {
self.stateitem = StateItem<T>(wrappedValue)
}
public var wrappedValue: T {
get {
stateitem.value
}
set {
stateitem.value = newValue
}
}
}
Does anyone know how to do this or how SwiftUI does this?
Hi, the title says it all.
I wonder if Swift jobs only exist for iOS app development or if It is also being used in other domains.
Would love to help aspiring students and devs wanting to learn iOS.
Edit: AMA ended. Thank you everyone for being patient with the replies. My progress is a direct result of the online resources people put up, free or paid, and selfless help from strangers on reddit, stackoverflow and other forums. It truly is a humbling experience and I hope my little AMA might be useful to at least one person tonight.
I am trying to create an application that every day gets new versions of existing packages and new packages created. Any idea how I can do that in an automated way? Ideally I would like to query an api that gives me all that info but I couldn’t find one.
Any new Swift learners? Wanna learn with me?
If you already know Swift and would like to mentor me, I'd be much appreciated too
I know basics of swift and can make basic apps but still limited on what I can do! I’ve paid for codewithchris and learned a bunch on there but can’t afford the monthly fee anymore.
Any help would be appreciated!
Thank you!
I just wrote the very first article for my "Import Foundation" project (a platform of high-quality Swift & software engineering content), and I would love to have some feedback. The landing page is, well, barebones...(so don't go there ...) but I'm proud of the article design. Most of you will find it familiar and reminiscent of a certain IDE... almost like being at home...
https://importfoundation.com/blog/slimmercode/dictionary-ergonomics-with-identifiable-arrays/
Hi everyone!
I have learned to code by myself during covid and I have ambitions to create a huge app, but also, I want to learn from my own mistakes, and so, when my wife this week told me that she wanted to pay $6.99 per week for an app that show her recipes that are safe for pregnant women, I said F THAT, and told her I would do one myself,
Well, now I have and is still in development, and many more things will be added to the app. It will be 100% free, with an option for a very cheap monthly or yearly subscription later on, but the free version won’t limit the app in any way, the subscription will just help cover the costs for the servers and work and add some tiny features like personalization, but nothing to impact any user.
I would be incredibly happy if some people could beta test my app and give feedback. I hope this app becomes my thank you to the community and help people like my wife. Life is hard on everyone and the last thing I want is to exploit people that could benefit from my app.
Right now I am using only one API, but the idea is to implement many others to keep filling the app with helpful resources. API costs are being covered by me on a monthly basis.
If anyone would like to beta test and give feedback, please add yourself to the list here!
Things to come on upcoming betas:
- Drink recipes
- Multi language support
- Some level of personalization
- Subscription model implementation.
Thank you all! Have an amazing day :)
When app is built using Xcode 16, it replaces the bottom tab bar with a top one instead. I was able to bring back the bottom tab bar using a work around with size classes but the top tab bar is still visible, thus I have 2 tab bars showing on my app. How do I possibly remove the top tab bar using swiftU
Thanks
I recently came across a use case where a menu had multiple buttons, all of which were either showing a share sheet or converting an image from data to UIImage or a PDF.
Using hang detection in the developer mode I noticed that it was taking too long to operate. Then I tried to apply these modifiers .menuOrder(.fixed)
, .menuStyle(.button)
and it actually improved the performance although I am still not sure how and why?
I'm struggling to understand UIViewRepresentable
and UIViewControllerRepresentable
. They both have a feature called Coordinator
, that allows you to implement the delegates of the UIView
or UIViewController
that you are trying to use in SwiftUI.
For UIViewControllerRepresentable
, I can write:
class Coordinator: NSObject {
}
But if I write the same for UIViewRepresentable
, the compiler complains:
CustomCameraView.Coordinator
has an unstable name when archiving via NSCoding
.CustomCameraView.Coordinator
does not conform to the protocol NSCoding
.The system suggests automatic fixes:
objc(CustomCameraView_Coordinator) class Coordinator: NSObject {
func encode(with coder: NSCoder) {
}
required init?(coder: NSCoder) {
}
}
My question is, why are the two Coordinators different from each other and what's with all the extra code you have to write for UIViewRepresentable
's Coordinator?
Edit: Typos
What’s the reasoning and the fix?
Hello to all,
I am learning iOS programming with UIKit. I can understand most of concepts but I am struggling to understand Delegates. Thats why I dont understand VIPER pattern also. Is there any understandable tutorial or book?
Hi, when I try to run my project (python btw) on xcode it says next to my phone: "could not locate device support files". Can someone explain ? Thanks.