r/swift • • Jan 19 '21

FYI FAQ and Advice for Beginners - Please read before posting

446 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 • • 17d ago

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

12 Upvotes

What Swift-related projects are you currently working on?


r/swift • • 5h ago

Question App testing in Testflight or App Store

2 Upvotes

Getting ready to release my first iOS app and will be looking for people willing to test it.

Generally do I ask them to test using TestFlight or do I need to have it on the APP store?

I will expect some bugs and feedback so I am prefer using TestFlight.

Comments or suggestions are appreciated.


r/swift • • 3h ago

Some tips for the Swift Student Challenge 2027

1 Upvotes

I am taking part in this years challenge where the size limit is 500 mb. One thing that i wanted to ask is that should the judged be able to understand the core idea of our the project/ 4pp(reddit is stupid) in under 3 minutes or that they should be able to visit every inch of the 4pp within 3 minutes. My 4pps core idea could be understood in 3 minutes but visiting every inch of the 4pp, that might not be possible. Any suggestions would help a lot. any other tips for the challenge as a whole from experienced participants, winners or distinguished winner would be even more help ! thanks
Just a question how much AI is okay and how much is just not because in 2026 AI can make better things than someone who started learning siwft 3 months ago(me)


r/swift • • 1d ago

Anyone else building Swift apps just to solve random everyday problems?

47 Upvotes

I've been building a little Swift app to keep track of my vegetable garden. Nothing fancy, just UIKit and Core Data. I can map out my beds, move crops around, and log harvests.
Started it because I kept forgetting what I'd planted where and somehow always ended up putting tomatoes in the same spot lol. My wife suggested a spreadsheet, but I figured making an app would be more fun.
It's all local for now, but I'm thinking about adding iCloud sync so we can both use it. Maybe a simple widget for reminders too.
Anyone else using Swift for random personal projects that have nothing to do with the App Store? Curious what you've built and whether you actually finished it or it's still sitting at 80% like half my other projects lol.


r/swift • • 1h ago

Tutorial Choosing a DB is More Nuanced Than You Think

Thumbnail
medium.com
0 Upvotes

r/swift • • 6h ago

Project Modification to Swift 6.4.1

0 Upvotes

Hello everyone.

i made Xwift, a cross-platform toolchain for the swift language based on swift 6.4.1.

you write the code once and the same source builds native apps for macos, linux and windows, plus webassembly for the web.

installers are out now for all three.

baiehclaca.github.io/xwift-web


r/swift • • 6h ago

News I built Snitch, an open-source in-app inspector for network requests and analytics events (PostHog, AppsFlyer)

0 Upvotes

Hey r/swift,

For the past few weeks I've been working on a side project and wanted to share it here for feedback.

Snitch is a debugging tool you add to your iOS app. It shows every network request and every analytics event your app sends, right on the device. Shake the phone (or tap a floating button) and you get a timeline you can search and filter.

Why I built it: at work I kept asking "did that analytics event actually go out, and what was in it?" Answering that meant print statements, setting up a proxy, or staring at gzipped and encrypted payloads.

What it does:

- Captures URLSession traffic via URLProtocol, with headers, pretty-printed JSON bodies, search and filters
- Works with your own URLSessions and keeps their settings, so cookies, caching and SSL pinning still behave normally (auth challenges are forwarded to your session's delegate)
- PostHog events through its beforeSend hook, and each event links to the batch request that uploaded it (Snitch unzips the gzip body and matches event IDs)
- AppsFlyer events with zero code changes: it finds the SDK at runtime and wraps its public logEvent methods, so there's no AppsFlyer dependency
- Copy as cURL, pause recording, light and dark mode, Liquid Glass on iOS 26 with a fallback to iOS 16
- Debug-only: every call is a no-op without DEBUG, and nothing leaves the device

The core has zero third-party dependencies. Setup is one line: Snitch.start()

GitHub: https://github.com/BachoOnn/snitch

I also shared the story behind it on LinkedIn, with a few slides showing it in action:
Linkedin post

It's still early, so I'd really appreciate feedback, bug reports, or ideas for which SDK to support next (Firebase? Mixpanel?). Happy to answer questions about how any of it works.


r/swift • • 6h ago

SwiftExoPlayer

Thumbnail
github.com
1 Upvotes

I’ve been working on SEPlayer, a framework for building media players with almost all playback logic running entirely in userspace. Only decoding, video rendering, and audio playback are handled by the system.

I’ve spent two years researching and experimenting with different playback pipelines. Initially, I followed ExoPlayer’s approach, but its high-frequency timer-based pipeline isn’t particularly power-efficient.
I think I’ve finally found a better solution: an event-driven pipeline that only does work when necessary.
The project is still in alpha, and there’s a lot left to implement.

Currently supported:
Progressive MP4, fMP4, and MPEG-TS playback
HLS

Planned:
MPEG-DASH
Additional containers and formats, including Matroska, AVI, MP3, and raw AAC streams
More stability improvements, error handling, and tests

One of the main goals is extensibility. Unlike AVPlayer, SEPlayer allows you to implement your own demuxer, use different renderers, or replace the ABR algorithm, much like ExoPlayer.

There’s still a long way to go, but I wanted to share what I’ve been working on.
I’d be interested in hearing feedback, especially from anyone who’s worked on media playback pipelines or video players.


r/swift • • 16h ago

I built an open-source tool that gives SwiftPM a single global APFS store across all projects and worktrees (like pnpm for Swift)

4 Upvotes

If you work on multiple iOS/macOS apps, client repos, or Git worktrees (especially with AI coding agents spinning up branches), you have probably noticed what happens to your disk and build times:

Every workspace path gets its own DerivedData/<App>-<Hash>/SourcePackages folder. Have 4 projects or worktrees using firebase-ios-sdk, stripe-ios, grpc-swift, or swift-syntax? You download, checkout, and store the exact same gigabytes four times.

I built spmx (open source, MIT) to fix this without changing how you run Xcode, swift, or xcodebuild.

How it works

  1. One global store (~/.spmx/store): Stores each (package, version) checkout, binary XCFramework artifact, and Swift macro prebuilt once, alongside shared bare Git repositories. Different projects keep their exact Package.resolved versions without forcing upgrades.
  2. Zero-copy APFS hydration: Lightweight PATH shims for swift, xcodebuild, and flutter clone matching packages from ~/.spmx/store into your project's SourcePackages using macOS APFS clonefile(). It takes milliseconds and uses zero additional physical disk blocks.
  3. Shared LLVM CAS compilation cache: Configures ~/.spmx/compilation-cache when supported by your toolchain so clean builds across worktrees share compiler outputs.
  4. Retroactive deduplication (spmx link): Run spmx link to scan your existing DerivedData and project folders across your Mac. It prints the full plan and estimated GB saved before asking for confirmation to replace duplicates with APFS clones.

Benchmarks (Apple M4 Pro, swift-composable-architecture fixture)

  • Warm package resolution in a new worktree: 42.3s (native) -> 0.46s with spmx hydrate
  • Extra physical disk per worktree/project: ~0 MB (shared APFS blocks)

Current limitations (what is still rough)

  • macOS 13+ on APFS only: No Linux support since it relies on clonefile() and DerivedData layout.
  • Xcode GUI doesn't read shell PATH: If you build strictly via the Play button in Xcode GUI instead of CLI, you need to enable the opt-in Git hook (spmx hooks enable --global) so packages hydrate on git checkout / git worktree add, or run spmx link.
  • SwiftPM only: It does not deduplicate legacy CocoaPods (ios/Pods).

Try it

curl -fsSL https://get.spmx.io | sh
spmx setup
spmx link

(Or via Homebrew: brew install LuisRibeiroo/tap/spmx)

If you want to exclude a specific repo from the global store, run spmx unlink <path>.

  • GitHub: https://github.com/LuisRibeiroo/spmx
  • Website & Benchmarks: https://spmx.io/benchmarks

Would love feedback from anyone juggling multiple Swift repos or worktrees, especially if spmx link hits any edge cases on your DerivedData setup.


r/swift • • 16h ago

How can I get rid of all the extra space at the top?

Post image
2 Upvotes

r/swift • • 23h ago

Help! Glass background widgets

Post image
6 Upvotes

hey friends, coming to you after spending days trying to figure out how on earth muse & chatgpt pulled off the glass background on their widgets because as far as apple’s docs are concerned, liquid glass rendering is entirely delegated to the system, and on paper, widget glass comes from the home screen’s clear and tinted styles but these are working in default and dark styles

HOW???


r/swift • • 1d ago

What is the equivalent to a HTML div in swiftui?

10 Upvotes

I want to separate specific groups of items in a HStack without applying spacing to all the items. New to Swift


r/swift • • 1d ago

Project DoomMail: Another project on opensource

Thumbnail
gallery
0 Upvotes

I'm a fan of doomscrolling, so in addition to the DoomSurf project that I've published on the iOS App Store, I built a DoomMail project which I am opensourcing. It's on github at ancientcomputing/doommail-oss . Let me know if y'all want the full URL.

The concept of DoomMail is that rather than have an eye chart of emails on your email app, each email resides on its own card and you doomscroll through the email cards. I am old enough to remember email clients in the 1990s and the basic list of emails have not changed. At all.

I used Apple Intelligence (aka the on-device model, for privacy/security) to summarize each email for the card, it's only when you tap on the card that you can read the whole email. There are additional actions that you can take like reply, delete, star, archive the email. Feel free to guess what the rabbit icon is about 🤫

One thing I had to workaround was dealing with the "censorship" that the on-device model practices e.g. it will refuse to summarize some emails because of what it deems to be "sensitive" topics in the email.

I personally think that this is potentially useful as the basis for a new type of UI/UX paradigm, but don't want to go further with this. Currently, this supports Gmail. However, you do have to go through some hoops to enable it. Fully documented in the /docs folder.

In addition, if you do want to make this available beyond TestFlight e.g. actually publish this in the App Store, you have to jump through a bunch of Google-mandated security approvals (and pay a yearly fee). So as an indie project, it may not be useful. However, please feel very free to take this and run with it. Maybe at least use a friendlier name...! 🤓


r/swift • • 1d ago

Tutorial iOS 27.1: ReservedRegion

Thumbnail
antongubarenko.substack.com
5 Upvotes

r/swift • • 2d ago

News Fatbobman's Swift Weekly #162

Thumbnail
weekly.fatbobman.com
10 Upvotes

r/swift • • 2d ago

i've been writing swiftui on windows and running it on my iphone, no mac

Post image
28 Upvotes

built it because i didn't want to buy a mac just to learn swiftui. edit, hit run, it's on the phone in about 30 sec. you can control the phone from the pc too

still early, only tested on my iphone so far. would love people to try it

its free + open source https://github.com/Dadon-11/SwiftWin-Studio


r/swift • • 3d ago

Project Wish me luck getting my Internet Archive for tvOS approved

Thumbnail
gallery
42 Upvotes

I had this project idea on my desk for a while now, because I'm a total history buff. Now, I finally got to build it. My biggest fear is that Apple would reject it for the obvious reasons of the Internet Archive being flooded with "inappropriate content". I builtin a ton of filters and safeguards to block any nsfw content, and tbh it works fairly well. Please keep your fingers crossed for me.

Did anyone of you ever publish a similar app and do you have any tips?


r/swift • • 2d ago

I built an open-source PDF scanner for iPhone, iPad and Mac. No cloud, no ads, no subscriptions

0 Upvotes

I built Beaver because I wanted a simple way to scan documents and turn photos into PDFs without uploading anything to the cloud.

Contracts, receipts, visa documents, medical papers. I didn't want any of that sitting on someone else's server, and I was tired of scanner apps full of ads and subscriptions.

It started about three years ago as a small Mac tool I built for myself. I open-sourced it in 2025 and this year I started working on an iOS version. That eventually turned into rebuilding most of the app.

Here's what Beaver can do now:

  • Works on iPhone, iPad and Mac
  • Scans documents and converts photos to PDF
  • Splits and merges PDFs
  • Exports pages as PDF, PNG or JPEG
  • OCR that runs entirely on-device

No accounts, no tracking, no ads, no subscriptions. Everything stays on your device.

Why open source but $1.99?

The entire source code is on GitHub. You can inspect it or build the app yourself for free. The $1.99 App Store version is for people who prefer to install it directly and receive updates. It's a one-time purchase.

Links:

I'd genuinely appreciate feedback, especially if there's something missing that would make it more useful for your document workflow.


r/swift • • 4d ago

AMA Architecture write-up: XPC service as the single writer, one LaunchServices-launched process per VM

Thumbnail
scaleninja.com
7 Upvotes

Hi r/swift,

At ScaleNinja, we build MacVisor, Mac Virtualization Platform written largely in Swift for Apple Silicon Macs, and wrote up its process layout.

MacVisor runs macOS, Windows, Linux & FreeBSD VMs on Apple's Virtualization.framework (not QEMU or any emulator) and enables users to run Mac as virtualization hosts (like Proxmox). It does automatic VM setup with account, ssh keys, guest tools, and brings snapshots, firewall & VLANs, VM auto-start & high availability, schedule backups and other advanced features.

Typical desktop virtualizers for macOS don't offer process isolation and all the VMs it runs are not isolated (killing the app for example, kills all the VMs). We've taken a different path in MacVisor's design and architecture https://scaleninja.com/macvisor/#architecture

The design question is which process owns each VM. Ours: a per-user background service is the only writer of VM state, and each running VM gets its own runner process. The app and the CLI are just clients. So quitting or crashing the app stops nothing, and one VM's crash doesn't take the others down. The service can even restart and reconnect to running VMs.

The post includes a table of what survives what (app crash, service restart, update, power cut) and what the design costs.

https://scaleninja.com/blog/one-process-per-vm/

I'm curious if there are others who have adopted such architecture and use XPC in your apps.


r/swift • • 5d ago

Question Im building my FIRST ever SwiftUI App, and I have questions...

Post image
50 Upvotes

Hello everyone, I just started building my first iOS app, it's still in early development.

Im not a real developer, in fact I just started learning python this summer and decided to move to Swift and SwiftUI since I want to build an app for my iPhone.

Im currently working on a simple Habit Tracker, I would love if anyone could check out my code, or just give me general tips when building with SwiftUI!

Here is the repository
Thanks!


r/swift • • 4d ago

Built MultiScreenDock in pure Swift & AppKit (zero dependencies): 120Hz cosine Dock wave, Folder Stacks, and zero-permission Window Dodge across stacked monitors

0 Upvotes

I work on a 5-monitor MacBook Pro setup (with two 27" monitors stacked on an upper row above my 16" MacBook Pro and two 15.6" portable side displays). On macOS, WindowServer only shows the native Dock on one screen at a time, and on upper stacked displays you can never summon the bottom Dock at all because moving the pointer down crosses into the lower monitor.

I built MultiScreenDock in pure Swift and AppKit (zero third-party dependencies, ~0.0% idle CPU, 2,066 automated assertions) to put a live, synced replica of the macOS Dock on every connected display simultaneously.

A few interesting AppKit / CoreGraphics problems solved in v1.4.2:

  1. Zero-permission Smart Auto-Hide ("Dodge Windows"): Third-party apps cannot reserve NSScreen.visibleFrame insets like Apple's system Dock.app without requesting intrusive Accessibility permissions to forcibly resize user windows. To solve this without any permissions, v1.4.2 uses public CGWindowListCopyWindowInfo([.optionOnScreenOnly, .excludeDesktopElements], kCGNullWindowID) metadata to inspect layer-0 window bounds, translates Quartz global coordinates (top-left origin on primary display) into AppKit multi-monitor coordinates (primaryHeight - (quartzY + height), including negative Quartz Y on upper stacked monitors), and automatically hides the Dock per-monitor only when a window overlaps its footprint.
  2. 120 Hz Raised-Cosine Magnification Wave with Piecewise-Linear Focal Lock: When icons magnify on hover, the total pill width expands from the center. Without compensation, hovering an icon near the left or right end causes that icon to drift sideways away from the pointer. MultiScreenDock maps rest knot coordinates to expanded knot coordinates at 120 Hz and shifts the pill origin by cursorX - mappedExpandedX so the hovered icon stays locked directly under the cursor.
  3. Cross-Monitor File Drag-Out from a Non-Activating Fan Stack Panel: On a .nonactivatingPanel, child NSImageView / NSTextField subviews return acceptsFirstMouse == false by default, which swallows mouseDragged before NSDraggingSession can start. Overriding hitTest(_:) on the custom NSControl row and transitioning the panel to ignoresMouseEvents = true (with alphaValue = 0) during the active drag session instead of calling panel.close() keeps the AppKit drag source alive across all monitors.

r/swift • • 5d ago

We built MotionSwift: an open-source native Swift alternative to Remotion with a built-in timeline editor

28 Upvotes

Hey everyone,

We just open-sourced MotionSwift, something we put together to get native rendering performance without relying on Remotion and headless Chrome.

We've been using it in our day-to-day video production pipeline, and so far we're seeing roughly 10–20x faster renders while using only about 10% of the memory compared to the Remotion + Chrome setup. We also brought a visual editor and timeline preview directly into Swift, so you can inspect and adjust agent-generated compositions natively on both iOS and macOS.

The eventual goal is 100% compatibility with Remotion, but we're still working our way there. There's still plenty of room to improve the APIs, rendering speed, and overall platform support.

Here's the repo if you want to check it out:

https://github.com/rxtech-lab/MotionSwift

Curious to hear your thoughts, especially if you've run into similar memory or performance bottlenecks with web-based video rendering. Happy to answer any questions!


r/swift • • 4d ago

App beginner tutorial broken?

Post image
2 Upvotes

I decided to use the beginner app tutorial and it won’t accept me changing the text, nothing seems to work! And the next one on the list is greyed out so I’m not sure what I’m meant to be able to do to actually learn as this is task 1 that’s broken

Help!