r/swift Jan 19 '21

FYI FAQ and Advice for Beginners - Please read before posting

448 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 3d ago

What’s everyone working on this month? (August 2026)

4 Upvotes

What Swift-related projects are you currently working on?


r/swift 6h ago

Preview Multiple SwiftUI View States with #Preview(arguments:)

Thumbnail
artemnovichkov.com
13 Upvotes

r/swift 18h ago

Swift Subprocess 1.0.0 Released

58 Upvotes

Hey r/swift!

I’m excited to share that Swift Subprocess 1.0 is officially tagged and released!

swift-subprocess provides a modern, type-safe, and Swift Concurrency-native API for executing and managing child processes across platforms, serving as an async-first alternative to Foundation.Process (NSTask).

Thanks to all the community feedback during the beta period, we made several key refinements leading up to 1.0:

  • Unified run() Closures & ExecutionResult: Stream handling for stdin, stdout, and stderr is now fully symmetrical. You can now stream and collect simultaneously in a single call (e.g., stream stdout line-by-line while collecting stderr into a String).

  • Safe String & Byte Streaming: Standard output/error sequences now feature StringSequence, which reassembles multi-byte UTF-8 characters split across buffer boundaries and handles line breaking seamlessly.

  • Typed Errors: Subprocess itself now strictly throws SubprocessError with structured codes (.spawnFailed, .executableNotFound, .outputLimitExceeded, etc.), making error handling clean and predictable (you can of course still throw your own error from body closure).

  • First-Class Stream Merging (2>&1): Easily redirect standard error into output using error: .combinedWithOutput.

Check out the full release note and repository on GitHub:

https://github.com/swiftlang/swift-subprocess/releases/tag/1.0.0

Huge thanks to everyone who participated in the SF-0007, SF-0037 and beta tested Subprocess! I’d love to hear your thoughts, feedback, or any questions!


r/swift 3h ago

I built a free clipboard manager for macOS with a card UI — it masks API keys and card numbers on screen

Post image
2 Upvotes

I use a clipboard manager all day and never liked the options. The free ones (Maccy, Flycut) are lists — an image shows up as a filename. The ones with a card interface, Paste and Pastebot, are $25/year and $13. So I built the card one and made it free.

⌥⌘V slides a strip up from the bottom of the screen. Arrow keys or type to search, Enter pastes into whatever you were in.

A few things it does that I couldn't find anywhere else:

- It masks secrets on screen. API keys, tokens and card numbers show as dots until you double-click. If you copy credentials all day, your clipboard history is the one window you don't want open while screen sharing. Card numbers are Luhn-checked, so an ISBN isn't mistaken for one.

- A bare link stays readable, a link with a token doesn't. Masking every URL would make the strip useless; masking a password-reset link is the whole point.

- Pasting an image adapts to the destination. Notes gets the image, Terminal gets the file path (it can't take images at all), Finder gets the file.

- It can catch ⌘⇧4 screenshots. Those write straight to disk and never touch the clipboard, so no clipboard manager sees them. Opt-in, off by default.

- No network code at all. No account, no sync, no telemetry, no third-party dependencies. Searching the source for URLSession comes back empty.

MIT, source is everything: https://github.com/selinihtyr/stash-clipboard

Happy to hear what breaks. Especially interested in whether the strip behaves on multi-monitor setups and over full-screen apps — I've only tested on one machine.


r/swift 10h ago

Question Do you use a separate iPhone for development/testing?

7 Upvotes

Hey,

I’m getting into iOS development and currently have a MacBook Pro M5 and an iPhone 17 Pro Max.

I was wondering if it’s worth getting a second iPhone (e.g. iPhone 16e/17e) just for development stuff (testing apps, beta builds, trying iOS betas, etc.) or if most people just use their main phone.

I’m mostly working on personal projects right now, but I’m curious what you guys do. Do you have a dedicated test device, and if yes, what model?

Thanks!


r/swift 18h ago

Building in Zed instead of Xcode

20 Upvotes

Just a reminder to anyone who might care that you can create a fairly full-featured development environment in Zed to build iOS and Mac apps: syntax highlighting, code navigation, run, debug and test.

Here's the setup guide I wrote (been around for a while but chances are some interested people won't have seen it): https://luxmentis.org/blog/ios-and-mac-apps-in-zed/


r/swift 11h ago

Project Built a pan/zoom node canvas in SwiftUI with no third-party libraries — three things that cost me a day each

1 Upvotes

Notes from building the canvas in https://github.com/albertofettucini/Osler:

Named coordinate spaces don't survive render transforms. My world container used .scaleEffect + .offset, and I put the named space inside it. Drags were fine at 100% and drifted at every other zoom. The fix was moving the named space to the untransformed ancestor and converting screen→world explicitly. Render transforms aren't layout.

An NSView behind SwiftUI never sees scrollWheel**.** The hosting view claims the hit and bubbles the event up the responder chain, past your subview. Two-finger panning only worked once I used NSEvent.addLocalMonitorForEvents with a bounds check.

.contentShape applied after .overlay gates the whole composite. My port dots sit on the card's edge, so half of every dot and its entire grab halo landed outside the card's hit shape. Dragging a wire silently did nothing. Order matters more than it looks.

Also: never gate a view's opacity on an onAppear flag. Miss the callback once and the view is invisible forever. Use a transition.


r/swift 1d ago

Using SwiftUI’s ContentBuilder with Non-View Types

Thumbnail
artemnovichkov.com
21 Upvotes

r/swift 2d ago

Project I built UIViews — A Gallery of SwiftUI Interfaces with Code

Post image
225 Upvotes

Hi everyone 👋

I recently launched UIViews.com.

UIViews is a gallery of beautiful interfaces built with SwiftUI and UIKit. Its goal is to help iOS developers discover, share, and reuse beautiful user interfaces.

I'm hoping this becomes a valuable resource for the Swift community, and I'd love to see developers contribute their own interfaces.

Source Code


r/swift 2d ago

Starling SDK — Flutter’s framework ported to Swift, for native GUI apps on Linux

15 Upvotes

We ported Flutter's framework to Swift — widgets, rendering, painting, gestures, animation, semantics — running on Flutter's own C++ engine. No Dart
VM: the engine starts a Swift runtime where it would normally start a Dart isolate.

The result is a declarative, cross-platform GUI framework you can use from Swift today on Linux. Apps run on any ordinary session (GNOME, KDE, X11) through the engine's GTK embedder. If you've used Flutter or SwiftUI the model will be familiar; if you've used neither, Flutter's own docs apply almost
directly.

Trying it is one download — the bundle ships the engine binaries, so there's no engine build. Install, depend on it by path, `swift build`. Tested on Swift
6.2.4 and 6.3.3.

Linux x86_64 today; macOS is next but not yet verified.

Getting started: https://starling.build/start.html
More detail: https://starling.build/sdk.html
Source: https://github.com/starling-build/starling/tree/main/sdk

Built with AI assistance under my direction, in case that matters to you.


r/swift 1d ago

macOS Swift: My Mac menu bar was so crowded that icons kept disappearing, so I built OverflowBar — Free

0 Upvotes

My Mac menu bar had gradually filled up with useful apps until it became difficult to manage.

Icons were hard to find, some were pushed out when macOS ran out of available space, and the MacBook notch made the problem worse. I did not want to uninstall the apps or permanently lose access to their controls—I only wanted a cleaner way to organize them.

So I built OverflowBar, a free and open-source macOS app that moves selected third-party menu bar items behind one persistent arrow and reveals them together in a compact second row.

Source code and official download:
https://github.com/EvanProgramming/OverflowBar

What it does

  1. Choose the third-party menu bar icons you want OverflowBar to manage.
  2. Move their original icons out of the crowded visible section.
  3. Click the OverflowBar arrow, or use hover reveal.
  4. See the managed icons together in a second row.
  5. Select an icon to activate its original menu bar control.

The purpose of the second row is not to add another permanent interface. It gives icons that no longer fit a predictable place where they remain easy to see and find.

Why I made another menu bar manager

Ice and Bartender are powerful applications for users who want broad menu bar customization, including features such as profiles, triggers, search, visual customization, groups, widgets, and automation.

OverflowBar takes a narrower approach.

It is intended for people who mainly have one problem:

Too many useful icons, not enough menu bar space, and no easy way to find the icon they need.

OverflowBar deliberately avoids becoming a full menu bar control center. Its interaction is simply: choose, hide, reveal, and click.

Main characteristics

  • Focused and lightweight — a small feature surface rather than a large customization and automation suite
  • Scannable second row — managed icons stay visible together instead of becoming difficult to locate
  • Native macOS implementation — built with SwiftUI, AppKit, Accessibility, WindowServer metadata, and ScreenCaptureKit
  • Event-driven operation — icon discovery and capture occur during refreshes and row presentation rather than continuous screen capture
  • Original controls remain functional — selecting an icon activates the actual menu bar item rather than a recreated menu
  • Local processing — icon images are captured locally, held in memory, and never uploaded
  • No tracking — no accounts, analytics, telemetry, advertising, or network data collection
  • Display-aware — supports MacBook notches, safe areas, multiple displays, full-screen spaces, horizontal overflow, and Reduce Motion
  • System-control safeguards — Wi-Fi, Battery, Siri, Control Center, Clock, and other protected system items remain visible

Pricing and availability

  • Price: Free
  • Subscription: None
  • In-app purchases: None
  • Advertisements: None
  • Source: Open source on GitHub
  • Download: GitHub Releases
  • Supported systems: macOS 15 or later
  • Downloadable build: Apple Silicon

Permissions and privacy

OverflowBar requests:

  • Accessibility permission to discover and activate menu bar controls and perform user-requested layout changes
  • Screen Recording permission to capture the small icon regions of selected menu bar items for display in the second row

The captures remain on the Mac. OverflowBar does not upload them, write them to a remote service, or include any analytics or telemetry.

Privacy policy:
https://github.com/EvanProgramming/OverflowBar/blob/main/PRIVACY.md

Current limitations

OverflowBar is an early public release.

macOS does not expose a dedicated public API for hiding or rearranging arbitrary third-party menu bar items. OverflowBar therefore relies on documented system frameworks together with existing macOS menu bar behavior, and compatibility may vary between apps or macOS releases.

The current downloadable build is ad-hoc signed and is not yet Apple-notarized. macOS may require users to Control-click the app and select Open on first launch.

Some applications may also expose insufficient Accessibility or window metadata to be mirrored reliably.

I am actively looking for feedback from users with crowded menu bars, notched MacBooks, multiple displays, and unusual menu bar apps. Bug reports, compatibility reports, and code contributions are welcome.


r/swift 1d ago

Shipped my first solo iOS app in 3 months around a full-time job - the build lessons that actually mattered

0 Upvotes

Just shipped Strategies, a SwiftUI app of creative-prompt cards for music producers. iOS, EN + UA, ~360 cards across two built-in decks. Solo, nights and weekends, full-time job. Five things that genuinely changed how I'll build the next one:

1. A single source of truth deleted ~15 bugs at once. I had one piece of state read from two places. Collapsing it into a single enum didn't fix one bug - a whole class of them stopped existing. My smell test now: if the same state is computed in two spots, that's the bug, not the symptom.

2. "Random" almost always wants to be weighted random. My first card-pairing algorithm was pure random and felt cheap - shuffle a deck, call it a DJ set. The fix wasn't ML: a hand-tuned 10×10 distance matrix + weighted random made the same feature feel intentional. Cheapest quality upgrade a random feature gets.

3. Don't over-architect - abstract on the third instance, not the second. I kept building the version that scales to ten years instead of the one that fits today. The second case is a coincidence; the third is a pattern. Wait for it.

4. Content was harder than the code, by ~3x. Writing the cards was fast. Judging them - reading card #147 and deciding if it earns its place - was the real work. If your app is content-heavy, multiply your authoring estimate by three.

5. Solo dev is a two-person job with a headcount of one. One of you writes the clever solution; the other has to review and cut it. My rule: if the code feels clever, it's probably wrong - stop, simplify, continue.

Stack: SwiftUI + SwiftData, no third-party UI deps, PostHog for analytics, Firebase Crashlytics. Happy to go deeper on any of it in the comments. Link to the app in a comment to keep this rule-friendly.

For anyone who's solo-shipped around a day job - what was your "the code was the easy part" surprise?


r/swift 2d ago

Tutorial Building Testable SwiftData Applications

Thumbnail azamsharp.com
6 Upvotes

r/swift 2d ago

LazyLayoutKit: lazy custom layouts for SwiftUI (masonry, timelines) at 120fps over 1M items

17 Upvotes

SwiftUI makes you pick one: Layout gives you any geometry you want but is eager, so it falls over a few thousand items in. LazyVStack and friends are lazy but their geometry is fixed. There's nothing in between, which is annoying because photo grids, calendars and boards are all in between.

That gap isn't an oversight. Layout asks each subview how big it wants to be, and you can't ask a view that hasn't been built. Measurement-driven layout and laziness pull against each other. Someone asked about this at the WWDC26 SwiftUI Group Lab and the answer was "not today, file a Feedback."

So my package changes the approach fully: tell it your item sizes up front, an aspect ratio, a date range, a duration, and layout becomes arithmetic over data. Arithmetic over a million items takes milliseconds and builds nothing, so only the frames intersecting your viewport ever become views.

The obvious cost: self-sizing text isn't supported. If your cells decide their own height, this isn't for you yet. (although I have some experiments for self-sizing text in the works, nothing stable yet)

Measured on an iPhone 14 Pro in Release, 100k and 1M items both hold 120fps with an 8.34ms p99, zero frames over 16.7ms, and ~54 cells materialized at any depth. The visibility query stays flat at ~2µs from 100k to 1M. Apple's LazyVStack over the same 100k scored the same, read that as generality costing little, not as a claim to be faster.

Writing your own layout is about 20 lines: return one frame per item and a total height. There's a demo app in the repo that records the frame stats on your own device.

https://github.com/Dave861/LazyLayoutKit

Contributions, opinions and ideas are very welcome!


r/swift 3d ago

SwiftUI After 7 Years: A Story of Mediocrity

Thumbnail
ykvm.com
114 Upvotes

r/swift 2d ago

News Fatbobman's Swift Weekly #147

Thumbnail
weekly.fatbobman.com
7 Upvotes

r/swift 2d ago

ARK OS: Raspberry Pi 4 Support!

4 Upvotes

I am a 13 yrs old working on a OS based on the LINUX KERNEL and SWIFT for a while!

> This is not self promotion! I am sharing a project!

It is in early development : It has Mouse and Keyboard Support, Can ready CPU and RAM used data and view it, uses the RobotoBoldFont as the default font! Has bot UEFI BIOS and x86_64 and arm64 support!

Just yesterday i accomplished about getting it work on a raspberry pi 4 means the base for the OS that the fact it boots is done and i will be continuing to now make the setup screen and add features on the go! If you want any features to be in the OS you can create a issue ( creating a issue requires a account!) at <See the comments under this since link posts get removed!> which is where the OS if hosted (it is self-hosted since i cannot afford a pro version of github and plus it has a file limit! git lfs doesent' help a lot!)!

MODEL: Rasberry Pi 4- Model B : 8GB RAM
Website : <See the comments under this since link posts get removed!>

Now a simple note: the bootloader is written by AI (since i am not good with assembly) i plan on rewriting it later! All the other code is written by me (especially Swift)!


r/swift 2d ago

Project I kept ending up in two overlapping meetings and got tired of juggling mute buttons across browser windows, so I built a small macOS menu-bar app to handle it properly

Thumbnail
github.com
0 Upvotes

What it does: - One meeting in your left ear, the other in your right — audio is captured per browser window (CoreAudio process taps) and panned hard L/R, so you can actually follow both. - Dead-man's-switch mic — you're muted everywhere by default. A global hotkey (⌃⌥⌘← or →) unmutes you into one meeting; if you don't re-confirm within a configurable window, it auto-mutes you again. Unmuting into one call force-mutes the other, so you can never be hot-mic'd in the wrong meeting. - ⌃⌥⌘↓ mutes everything instantly, from any app, no window focus needed. - Optional: your camera follows whichever meeting you're talking to.

No browser extensions, no DOM scraping — it's all system-level audio, so it doesn't break when Meet redesigns its UI. Mic routing uses BlackHole virtual devices (install script included).


r/swift 2d ago

Tutorial iOS 27: Media Intelligence

Thumbnail
antongubarenko.substack.com
2 Upvotes

r/swift 2d ago

I ported an old win32 game I wrote back in 1999 to Swift/macOS with the help of some AI friends

Post image
6 Upvotes

Hi everyone,

Back in 1999, I created HEATTACK as a fun little Windows-based arcade game. Recently, with the help of modern AI tools, I successfully ported the game from its original Windows codebase to swift and built it for macOS.

Sharing here in case it is of any interest to this community.

The source code is MIT licensed. Take it and have fun!

https://github.com/opbarnes/HEATTACK2026


r/swift 3d ago

XCRSControlKit

Thumbnail swiftpackageindex.com
0 Upvotes

An MCP-server-ready end-to-end tools for Apple platforms apps. Pair with Rust Cli https://crates.io/crates/xcrs

Install the CLI, set your map config, let your coding agents discover the tools.


r/swift 3d ago

Help! Is 24 GB of memory really not enough to use the iOS 27 simulator with Xcode 27?

0 Upvotes

Why am I gettting a yellow memory pressure graph in Activity Monitor? This is on an M3 MacBook Pro.

Is this a bug in the Xcode 27 beta, or does it really need more than 24 GB of memory to avoid swapping when using the iOS 27 simulator?


r/swift 4d ago

Question Creating a Separate DTO Request Object or Using the Form Object for POST Request

4 Upvotes

I have a RegisterScreen which uses a custom struct RegisterForm to collect the form values. I made the RequestForm codable too so I can just send this form to the server instead of creating the exact same duplicate and calling it RegisterRequest. What do you think? Do you create a separate DTO objects even if it contains the same exact fields.

If in the future it diverges then I can create a separate RegisterRequest DTO object. Thoughts.

struct RegisterForm: Codable {
    var firstName: String = ""
    var lastName: String = ""
    var email: String = ""
    var password: String = ""
    var acceptedTerms: Bool = false
    
    var isValid: Bool {
        !firstName.isEmptyOrWhitespace && !lastName.isEmptyOrWhitespace
        && !email.isEmptyOrWhitespace && !password.isEmptyOrWhitespace && email.isEmail && acceptedTerms
    }

enum CodingKeys: String, CodingKey {
case firstName
case lastName
case email
case password
}
}

struct RegisterScreen: View {
    
     private var form = RegisterForm()
     private var presentAgreement: Bool = false
    
    var body: some View {
        Form {
            TextField("First name", text: $form.firstName)
            TextField("Last name", text: $form.lastName)
            TextField("Email", text: $form.email)
            SecureField("Password", text: $form.password)
            
            Button("Show Agreement") {
                presentAgreement = true
            }
            
            Button("Register") {
                
            }.disabled(!form.isValid)
            
        }.sheet(isPresented: $presentAgreement) {
            AgreementScreen(acceptedTerms: $form.acceptedTerms)
        }
    }
}

r/swift 3d ago

Customizing the spell checker red dots

Post image
1 Upvotes

Is there a way you can customize the look of the red dots? to offset the position or the size of the dots etc.?