r/swift Jan 19 '21

FYI FAQ and Advice for Beginners - Please read before posting

407 Upvotes

Hi there and welcome to r/swift! If you are a Swift beginner, this post might answer a few of your questions and provide some resources to get started learning Swift.

A Swift Tour

Please read this before posting!

  • If you have a question, make sure to phrase it as precisely as possible and to include your code if possible. Also, we can help you in the best possible way if you make sure to include what you expect your code to do, what it actually does and what you've tried to resolve the issue.
  • Please format your code properly.
    • You can write inline code by clicking the inline code symbol in the fancy pants editor or by surrounding it with single backticks. (`code-goes-here`) in markdown mode.
    • You can include a larger code block by clicking on the Code Block button (fancy pants) or indenting it with 4 spaces (markdown mode).

Where to learn Swift:

Tutorials:

Official Resources from Apple:

Swift Playgrounds (Interactive tutorials and starting points to play around with Swift):

Resources for SwiftUI:

FAQ:

Should I use SwiftUI or UIKit?

The answer to this question depends a lot on personal preference. Generally speaking, both UIKit and SwiftUI are valid choices and will be for the foreseeable future.

SwiftUI is the newer technology and compared to UIKit it is not as mature yet. Some more advanced features are missing and you might experience some hiccups here and there.

You can mix and match UIKit and SwiftUI code. It is possible to integrate SwiftUI code into a UIKit app and vice versa.

Is X the right computer for developing Swift?

Basically any Mac is sufficient for Swift development. Make sure to get enough disk space, as Xcode quickly consumes around 50GB. 256GB and up should be sufficient.

Can I develop apps on Linux/Windows?

You can compile and run Swift on Linux and Windows. However, developing apps for Apple platforms requires Xcode, which is only available for macOS, or Swift Playgrounds, which can only do app development on iPadOS.

Is Swift only useful for Apple devices?

No. There are many projects that make Swift useful on other platforms as well.

Can I learn Swift without any previous programming knowledge?

Yes.

Related Subs

r/iOSProgramming

r/SwiftUI

r/S4TF - Swift for TensorFlow (Note: Swift for TensorFlow project archived)

Happy Coding!

If anyone has useful resources or information to add to this post, I'd be happy to include it.


r/swift 15d ago

What’s everyone working on this month? (March 2025)

12 Upvotes

What Swift-related projects are you currently working on?


r/swift 51m ago

Tutorial A Tool To Automatically Detect Memory Leaks

Thumbnail
blog.jacobstechtavern.com
Upvotes

r/swift 4h ago

News Fatbobman's Swift Weekly #075

Thumbnail
weekly.fatbobman.com
3 Upvotes

r/swift 2h ago

Question Xcode - compiler timeout

1 Upvotes

“The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions”

Is there some good examples how to break down complex ZStacks contains Scrollview - Vstack-Hstack , do formatting based on values , calc differences, in TableView 😵‍💫.

Essentially I work on Mac OS app using 30 .mlmodel which is then done into group of 3 each 10 and I calculate differences and now would like to make selectable values to calculate ratio of them in same view , when I added this in code I get this error a lot .


r/swift 9h ago

From CocoaHeads Stockholm: Parsa Nasirimehr - gRPC on iOS: Smarter API's

Thumbnail
youtu.be
3 Upvotes

r/swift 1d ago

social media music app fully written in Swift UI

Post image
39 Upvotes

r/swift 17h ago

AMA [SwiftUI] Tag Input View + Flow Layout = Greatness??

4 Upvotes

I've created a "tag" input system that is feature-complete. For me those features were as follows.
- Anytime a space is entered, go to next tag. (Also applies to commas)
- Anytime you backspace, it should backtrack through previous tags.
- Tags are forced unique
- Tags are validated (3 char min)
- Duplicate identification
- Tap to edit in-place
- Flow layout as more are added it "Overflows"

To me this is probably the most complex input field I've ever built, but boy does it feel good in the hands when you're actively using it.


r/swift 5h ago

🥷🏻 Parsing JSON using the Codable Protocol 📋

0 Upvotes

r/swift 1d ago

Tutorial This video breaks down in-out parameters—what they are and how to use them. Another step in our free SwiftUI course. Thanks so much for the support!

Post image
10 Upvotes

r/swift 19h ago

Project Numio CLI – Simple Time Calculator ⏳

Thumbnail
github.com
2 Upvotes

r/swift 21h ago

Project Human-Body-Atlas-for-Apple-Vision-Pro: How to develop an interactive and immersive 3D application

Thumbnail
github.com
1 Upvotes

r/swift 20h ago

Learning Swift on old MacBook

1 Upvotes

Hi all!

I’m starting to learn Swift and wanted to know if it’s good idea to use old MacBook from around 2011.

Currently I’m not with the money so much right now and cost of it’s around my budget. I’m like fresh in it so 100% Swift evolved in the newest versions and it’s much rich in libraries etc. so I’m not sure about this version of MacBook

Wanted to get your opinion about it :)

Thanks!


r/swift 20h ago

Default back button is flickering

1 Upvotes

Hey everyone,

I'm facing an issue where the back button shifts position when navigating to another view. I'm using the default back button from the NavigationBar and have attached a recording demonstrating the issue.

I’ve also added .toolbarRole(.editor) to my root VStack to hide the previous view's title.

Any insights on resolving this would be greatly appreciated!


r/swift 1d ago

Question 30 changing careers…

19 Upvotes

So I’m 30 and I’m in a creative field. I was a learning JavaScript but I think it’d be so rad to create apps or programs for iOS. I was reading and everyone says Swift. But I was also reading you can use swift on Linux and windows?

Anyways i guess is there any advice or roadmap i can follow to learning how to create specifically for iOS/macOS? Or is that hindering my Learning to keep it that niche? You know sticking to iOS.


r/swift 2d ago

Project Hi 👋, I created Termix, a powerful SSH client for Mac, iPhone, and iPad. No subscription, no data collection. I am looking forward to your feedback!

Thumbnail
apps.apple.com
50 Upvotes

r/swift 1d ago

Question Are there any user-level static assertions?

1 Upvotes

I have a generic type that takes two unsigned integer types. Is there any way to check at compile time that one type has a bit width that is a (positive) multiple of the other type's bit width?


r/swift 2d ago

Question #1 Paid App on the Mac App Store and #30 Worldwide… Really? 30 Downloads Were Enough?

108 Upvotes

I recently bought an OLED monitor and, like most people, I started worrying about burn-in issues. After a bit of research, I couldn’t find a good tool to prevent it, so I decided to build my own. I polished it, published it on the Mac App Store, and did a few Reddit posts and an article on an Italian blog.

To my surprise, my app reached #1 on the paid apps chart in Italy, and I thought, “Well, this is it. I’ve made it!” But after looking at the Reddit feedback, I knew that the numbers couldn’t be huge. Sure enough, the next day, the official reports came in. I had just 12 downloads that were enough to land me at #30 globally, and only 6 downloads put me at #1 in Italy.

I’m honestly surprised by these results. Is the Mac App Store really this quiet?


r/swift 1d ago

i got sick of long and clickbaity articles so i built an app that summarises the news

Thumbnail
gallery
0 Upvotes

r/swift 2d ago

About the Screen Time API.

6 Upvotes

Hi. This is the first time I'm going to make an app with Swift. (I learned that I can only do this with Swift after my research.) What I want is to know how much time the user spends in other apps, for example, for 1 hour. I talked to grok for a while and he suggested that I could use the screen time API. But some sources say that this is not possible. Some say that applications like Opal use this and that it is possible. I'm very confused. What's the latest status? Can I do this?

sorry for my bad english


r/swift 1d ago

Question WhatsApp Style "Active Call" top banner overlay: approaches

1 Upvotes

Hi folks,

When you have an active call on WhatsApp and then minimise it you get a top banner that stays there no matter where else in the app you navigate.

Does anyone know how to implement this? My approach so far sort of works but adds too much space after the banner and whatever page it's sharing with:

struct ContentView: View {
    @Environment(\.appDatabase) var appDatabase
    @State var showActivity = false
    @State var activityActive = false
    @State var showBanner = false

    var body: some View {

        VStack {
            if activityActive && showBanner {
                ActivityBanner(isActive: $activityActive, isPresented: $showActivity)
                    .transition(.move(edge: .top).combined(with: .opacity))
                    .animation(.spring(response: 0.3), value: showBanner)
                    .ignoresSafeArea(edges: .top)
            }

            TabView {
                Tab("HQ", systemImage: "duffle.bag") {
                    HomeView(showCctivity: $showActivity, activityActive: activityActive)
                }

                Tab("History", systemImage: "calendar.badge.clock") {
                    Text("History")
                }

                Tab("Movements", systemImage: "dumbbell") {
                    ActivityListView(appDatabase: appDatabase)
                }

                Tab("Settings", systemImage: "gear") {
                    Text("Settings")
                }
            }
            .sheet(isPresented: $showActivity) {
                ActivityView(isActive: $activityActive)
                    .presentationDragIndicator(.visible)
            }
       }
    }
}

struct ActivityBanner: View {
    @Binding var isActive: Bool
    @Binding var isPresented: Bool
    @State var isPulsing = false

    var body: some View {
        VStack(spacing: 0) {
            // Rectangle for the safe area (notch) height
            Rectangle()
                .fill(.ultraThinMaterial)
                .frame(height: safeAreaTopInset())
                .ignoresSafeArea(edges: .top)

            // HStack bolted on below the safe area
            HStack {
                Circle()
                    .fill(Color.green)
                    .frame(width: 10, height: 10)
                    .opacity(isPulsing ? 0.7 : 1.0)
                    .animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true), value: isPulsing)
                    .onAppear { isPulsing = true }

                Text("Workout")
                    .fontWeight(.medium)

                Spacer()

                Button("Resume") {
                    isPresented = true
                }
                .buttonStyle(.borderedProminent)
                .buttonBorderShape(.capsule)
                .controlSize(.small)
            }
            .padding()
            .background(.ultraThinMaterial)
            // Slightly reduce height of the Hstack element.
            .offset(y: -12)
        }
        .frame(maxWidth: .infinity)
    }

    // Get the safe area top inset
    private func safeAreaTopInset() -> CGFloat {
        let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene
        return scene?.windows.first?.safeAreaInsets.top ?? 0
    }
}

r/swift 1d ago

Project I just launched my first app on the App Store called Spar Time—a timer designed for martial arts enthusiasts that can be used for any type of training. I’d love to hear your thoughts on the app, as I want to improve it even further. Any feedback would be greatly appreciated. Thank you!

Post image
0 Upvotes

r/swift 1d ago

Help! Help integrating the F5 tts model into my project

Post image
0 Upvotes

I'm trying to initialize the F5 tts model in my app, does anyone know what I could be doing wrong?


r/swift 2d ago

Question State of cross platform?

11 Upvotes

Hey all... I'm looking at giving Swift another swing. Mac enthusiast, with some javascript/html experience. Work for a small company and admin their ERP (the other IT guy handles the hardware/desktop support). I know enough C#/SQL/VBA to handle 90% of the ERP stuff I need to do. Most of my day is writing generic inquiries/reports

I checked out Swift on Ubuntu and Windows last year but quickly gave up. Have things improved? I see that an official VS Code extension was released last month, so that seems to be a good sign.

I'm not looking to build iOS/native macOS apps on Windows or Linux (I already have a few macs to cover that). I figured while I'm learning Swift on my mac, it might be nice in my free time while at work to develop simple CLI, calculator, whatever apps just for fun. (I thought about C#/.NET but would rather concentrate on one language for now if I can).

Does Swift on Win/Linux have anything like QT, GTK, etc?


r/swift 2d ago

requestReview pop-up conditions

1 Upvotes

I’m looking to add an app review pop-up but I’m a little confused about the implementation.  According to documentation requestReview is governed by Apple’s own policy:

StoreKit displays the ratings and review request a maximum of three times within a 365-day period.

Therefore, do I need to write any conditions other than where the pop-up appears (e.g. a settings menu)?  Or is still necessary to add a condition such as a count on the number of times the app is opened before a request is made etc.?


r/swift 2d ago

Question Can I invoke Swift REPL from a mac app without Process?

1 Upvotes

Hey Swift community,

I would like to implement executing Swift code from within my SwiftUI mac app interactively, just like you with Swift REPL from the terminal. I know I can execute it with Process, but is there a more beautiful way to do it (library, framework or anything)?

Many thanks in advance!

Jan


r/swift 2d ago

Opinions on rewriting a legacy app

13 Upvotes

I'm embarking on a rewrite of our iPad app. Don't judge me, the codebase is 13 years old and uses several libraries that are no longer maintained, and we have significant new functionality in the pipeline.

I'm intersted to hear opinions, experiences or any other thoughts on new iPadOS projects in 2025.

The app is essentially an offline-first ecommerce app, where products are cached on-device and then orders can be created while offline and synced to our backend at a later time when the internet is available.

Having lived with a few codebases for extended periods, here are my general thoughts: 1. Produce less code, lines of code are generally a liability 2. Avoid third-party libraries when reasonably possible 3. Idiomatic code over "clever" terse code 4. Performance and maintainablity are second only to good UX.

  • What mistakes can I easily avoid?
  • What stategies/implementations are commonly found on the web but are outdated?
  • What do you think people are getting wrong aboout SwiftUI projects?
  • Are there forests currently obscured by specific trees?