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 2d ago

What’s everyone working on this month? September 2026)

11 Upvotes

What Swift-related projects are you currently working on?


r/swift 4h ago

Project CoreDataBrowser is now live on the Mac App Store – A free & open-source tool to inspect CoreData, SwiftData, Userdefaults on your Simulator

8 Upvotes

Quick update on CoreDataBrowser: it's officially live on the Mac App Store!

A few months ago I shared a side project I’ve been working on to solve a common iOS dev headache: inspecting local data in the Simulator without digging through nested AppData folders or writing custom scripts.

It lets you inspect: • Core Data databases • SwiftData storage • UserDefaults values

It’s completely free, native for macOS, and 100% open-source

If you want to give it a try or share feedback, you can download it here:https://apps.apple.com/app/coredatabrowser/id6807113765

GitHub repo:https://github.com/kyletaylor94/CoreDataBrowser


r/swift 21h ago

enriched-markdown-ios v0.2.0 - now with GitHub Flavored Markdown (GFM) support

Post image
7 Upvotes

I just released v0.2.0 of enriched-markdown-ios - SwiftUI Markdown renderer powered by TextKit 2.

New in this release:
🔸 GFM Tables
🔹 Task lists
🔸 Superscript & subscript support

💎 Available via Swift Package Manager!

.package(
  url: "https://github.com/software-mansion-labs/enriched-markdown-ios.git", 
  from: "0.2.0"
)

Added a quick demo video in the comments so you can see it in action!

GitHub & Docs:https://github.com/software-mansion/enriched-markdown/blob/main/packages/enriched-markdown-ios/README.md

What features or syntax support would you like to see next? I'd love to hear your thoughts! If you find the library useful, a ⭐️ on GitHub is always appreciated.


r/swift 1d ago

Tutorial SwiftData - Optimization Starts with Modeling

Thumbnail
fatbobman.com
10 Upvotes

r/swift 2d ago

Boss wants to switch our 100K+ user native apps to Flutter for "3x faster" delivery — am I actually biased, or is this a bad call?

202 Upvotes

Long-time mobile/product lead here. Looking for outside perspective because I'm now questioning myself after a long argument with my boss.
Context: I work on external client apps as well as our main customer portal app — the one used by the majority of our customer base. Our mobile apps are native, built about 6 years ago:
Android: Java/Kotlin + XML
iOS: Swift + UIKit
Web: React
100K+ users. Zero limitations adding features or maintaining these apps over the years.
What's happening: We have a full revamp of the apps and portal coming up, and we're updating our tech stack too. My plan:
Android → Kotlin + Compose
iOS → SwiftUI
Web → (TBD, staying on modern React-based stack)
I already have multiple Android, iOS, and web devs trained on this stack.
The conflict: My boss wants to consolidate to Flutter — one team, one codebase, covering web/Android/iOS. His argument: if I put 6 frontend devs on one Flutter codebase instead of splitting across native platforms, we ship 3x faster.
My pushback:
We have zero Flutter training on the team right now
Native apps perform better and feel more premium due to platform specific UIs.
We have built Flutter apps before, but only for external client projects, not our own flagship product
He thinks I'm biased toward native because it's my background. Might be some truth to that, but I don't think that's the whole story.
Anyone actually shipped a migration like this — native to Flutter, or vice versa, at similar scale? Did the "one codebase, ship faster" promise hold up? Would love real-world experience, not theory.


r/swift 2d ago

Tutorial iOS 27: USDKit Framework

Thumbnail
antongubarenko.substack.com
17 Upvotes

r/swift 2d ago

Question How does this magic (StoreKit price formatting) works?

3 Upvotes

Let's say we have a StoreKit product with monthly subscription: let product: Product

If we print price it shows the price and nothing more: print(product.displayPrice) // "$9.99"

But if we put it in SwiftUI Text, magic happens: Text(product.displayPrice) // "$9.99/mo"

How does it works? How could I access "$9.99/mo" string programmatically and, for example, print it?


r/swift 2d ago

Tutorial Building AI features using Foundation Models. Multimodal input.

Thumbnail
swiftwithmajid.com
9 Upvotes

r/swift 2d ago

Project I created a native Calculus of Inductive Constructions kernel in Swift

16 Upvotes

Hi everyone. I want to share a project I have been working on called Axiom.

It is a Calculus of Inductive Constructions kernel written in pure Swift. You give it terms and it tells you if they type check. Think of it like a tiny Lean that lives directly inside your iOS or macOS app instead of running as a separate tool.

I built this because I wanted real proof checking on Apple devices without dealing with external programs. You just import Axiom and check proofs right next to your UI or your machine learning models.

The coolest part for me is the AI angle. Local models hallucinate math constantly. Axiom acts as a strict filter for this. The model proposes a proof step, the kernel verifies it, and only the valid math gets through. Right now it handles universes, dependent types, lambdas, inductive types and pattern matching.

On the testing side I tried to hit the things that usually break CIC kernels: universe hierarchy (no Type : Type), strict positivity on inductives, structural termination, capture free substitution with de Bruijn indices, and classic paradox patterns like Girard and Hurkens. I also run differential checks against Lean 4’s kernel on random terms, and so far Axiom has not accepted anything Lean rejects.

I know I am not replacing Lean or Coq with this. But for the Swift ecosystem it is a really solid start. My long term plan is to build a local proof playground. You ask a math question in plain English, a local model turns it into formal math, Axiom checks it, and you get the answer back entirely on device.

Repo: https://github.com/acemoglu/Axiom

Would love to hear your thoughts or feedback!


r/swift 2d ago

Updated I updated LocalLM Lab for macOS 27 beta

4 Upvotes

The latest LocalLM Lab SDK lets your app offer a choice of using Apple's on-device model, Claude or a fully local open-weight model per task in your app. Some of you may have seen an earlier version of this SDK. 1.0.0-beta.1 adds the model layer that makes this multi-way choice possible.

``````swift
let lab = LocalLMLab(configuration: .init(providers: [
    SystemModelProvider(), ClaudeModelProvider(auth: .apiKey(key)), MLXModelProvider(),
]))
lab.models.route(.heavy, to: ModelID("mlx:mlx-community/Qwen3-8B-4bit")!)
lab.models.route(.light, to: .system)
let session = try lab.makeSession(route: quickTask ? .light : .heavy, tools: myTools)

MLXModelProvider handles the download lifecycle (preflight against available RAM before pulling weights, progress stream, a post-download capability probe since not every downloaded model reliably tool-calls) and residency (how many models stay warm at once, eviction events).

Two new reference apps are included: code-buddy, a CLI coding agent using .heavy/.light MLX routes plus Workspace tools and an MCP docs server; repo-qa-local, the minimal version.

More details on Swift Forums: https://forums.swift.org/t/locallm-lab-1-0-0-beta-one-model-calling-api-across-apples-on-device-model-claude-and-local-open-weight-models/89319

Guide: https://github.com/ancientcomputing/locallm/blob/main/docs/sdk-guide.md

Feature page: thisbrain.ai/locallm/1.0.0-beta


r/swift 2d ago

Connecting two iOS simulators over BLE ( or 1 sim to a BLE device )

Thumbnail kylebrowning.com
3 Upvotes

r/swift 2d ago

Tutorial Designing The Perfect Modular Architecture

Thumbnail
blog.jacobstechtavern.com
1 Upvotes

r/swift 3d ago

News A no-third-party-libraries iOS Hackathon — curious how far people push pure SwiftUI

12 Upvotes

There's a hackathon running Sept 18–27 with a rule I haven't seen elsewhere: 100% native Swift/SwiftUI, no external dependencies allowed. No Firebase, no third-party UI kits — just Apple's own frameworks.

Solo or teams up to 3, submission via GitHub (no App Store listing needed). Judged on functionality, code quality, creativity, and how well you use Apple's native APIs.

Mostly curious what people build when the safety net of third-party libs is gone — MapKit, Core Data, on-device AI, whatever native tools you'd normally skip.

Here's the link if you want the details / to register: https://acoding.academy/hackaton26/


r/swift 3d ago

Swift/macOS + visionOS developers: looking for feedback on a two-app spatial asset workflow

1 Upvotes

I’ve been building Reality Prep Pro in Swift for macOS, alongside Reality Prep Preview for visionOS.

The workflow is:
1. Prepare and optimise assets on Mac;
2. Verify the USDZ on Vision Pro;
3. Bring the device-side validation evidence back into the Mac app.

I’d really value feedback from Swift/Apple developers on the workflow, reliability and any edge cases you hit with real assets.

Both apps are intended to be used together.

Reality Prep Pro: https://apps.apple.com/us/app/reality-prep-pro/id6767673652?mt=12

Reality Prep Preview: https://testflight.apple.com/join/ySbVmz6b

Thanks very much to anyone willing to give them a spin.


r/swift 3d ago

News Fatbobman's Swift Weekly #151

Thumbnail
weekly.fatbobman.com
7 Upvotes

r/swift 3d ago

The willThrow Tax: A hidden 36x slowdown and 2.1KB memory leak per throw in test frameworks.

Thumbnail
gallery
0 Upvotes

A few days ago I posted about the hidden cost of throw in XCTest. I didn't stop there and decided to dig way deeper to see what else was lurking behind that hook.

Spoiler: it's not just XCTest. Swift Testing has the hook too (although it's quite a bit cheaper). And the worst part isn't just the slowness, it's that every throw gobbles up ~2.1 KB of memory that isn't freed until the test ends. With millions of throws (like in my Kalego fuzzing), that turns into an instant OOM crash.

In the report (12 pages, 21 experiments) I've got the assembly analysis, the fixes table, and the reasoning behind every result.

Link to the repo with all the reproducible code here: https://github.com/MagicYassin/xctest-throw-cost

A big shoutout to u/ThatGuy739 and u/Dry_Hotel1100 for pushing the research forward in the last thread. You guys are absolute legends. 👨🏻‍💻☁️🌌


r/swift 4d ago

Built a custom LLM inference engine in Swift/Metal (no llama.cpp/MLX) — streams MoE experts from SSD to run 61GB models on 16GB Macs

46 Upvotes

I've been building TUFF, a native macOS app for running local LLMs, and the inference engine is written from scratch in Swift with Metal 3.2+ — it doesn't wrap llama.cpp or MLX.

The interesting part from a Swift-engineering angle: it keeps the shared parts of a mixture-of-experts model resident in memory, then streams the experts it needs from SSD through a bounded cache, reusing them across requests. That's how a 61 GiB checkpoint can run on a 16 GB MacBook Air without touching swap. Requires macOS 15+ and Swift 6.2+ to build.

Just shipped 3.0.0: rebuilt the chat interface around a unified conversation model (images persist across turns, files attach as typed objects rather than raw text), added two new Gemma 4 variants, fixed architecture-based routing for optional image packs, and squashed several catalog/stability bugs.

It's Apache-2.0 and started as a fork of drumih/turbo-fieldfare. Source: https://github.com/rexmhall09/TUFF — site: https://rexmhall09.github.io/TUFF/

Happy to talk through the Metal/Swift side of the inference engine if anyone's curious — and if you find it interesting, a star helps.


r/swift 5d ago

Help! What’s the secret of making the preview work in Xcode?

Post image
29 Upvotes

This literally never worked properly for me since its existence, multiple computers, multiple xcodes, that’s why i never use it, first thing i do in a new project is to hide the preview column. But today i wanted to and it pissed me off. First, if it works, i basically wait for the whole app to compile, then i either get an error, either the preview. I change something, i wait again for the whole app to compile, actually i can launch the app faster than i wait for the preview to come with a result or an error. It is freaking slow and it barely works, sometimes.


r/swift 4d ago

Question Get x,y coordinates of an image in SwiftUI

4 Upvotes

I am making a simple game. Image 1 has to move towards image 2. Image 2s movement is random (not relevant to my question).

Is there a way to get image 2s coordinates so that I can update image1s position with .position(x: ,y: )? Or am I approaching this problem the wrong way?


r/swift 4d ago

I built sandbox in Swift: run coding agents in VMs whose network egress they can't bypass (Containerization + Virtualization.framework)

0 Upvotes

Coding agents (Claude Code, Codex, Gemini CLI) work best unattended, but giving them that freedom on your own machine is the risk. I wanted VM isolation with a real enforcement boundary, in Swift, open source — so I built it.

The core trick: Apple's Containerization package exposes a public VZInterface protocol. Instead of the stock NAT attachment (which gives the guest a real route out), sandbox supplies a conformer returning VZFileHandleNetworkDeviceAttachment — a virtio-net device whose wire is a datagram socket held by the sandbox process. The VM gets exactly one network device, so every TCP dial, DNS query and UDP datagram terminates at a userspace gateway enforcing a default-deny allowlist. Root inside the guest changes nothing, because the enforcement is outside the guest.

API keys never enter the VM either: the agent sees a sentinel value and the gateway injects the real credential at the TLS boundary, only for verified upstreams.

Numbers, measured not guessed: ~60 MB of host processes per sandbox, ~0.5 s warm starts, and zero marginal disk (rootfs is an APFS copy-on-write clone — starting a sandbox changes free space by nothing).

Apache-2.0, early (0.1.x) but verified by ~165 end-to-end acceptance tests against live VMs. Would love feedback from anyone who knows Virtualization.framework's darker corners.

Repo: https://github.com/satishbabariya/sandbox


r/swift 5d ago

Xcode now can deploy beyond local network

0 Upvotes

I’ve found a way that Xcode can deploy remotely to an iPhone instead of being limited to local Wi-Fi. Please check out my repo on GitHub:

https://github.com/zjz-connect/xcode-deploy-link-deploy-beyond-local-network

If you have better ideas, feel free to leave comments!


r/swift 5d ago

Xcode now can deploy beyond local network

2 Upvotes

I’ve found a way that Xcode can deploy remotely to an iPhone instead of being limited to local Wi-Fi. Please check out my repo on GitHub:

https://github.com/zjz-connect/xcode-deploy-link-deploy-beyond-local-network

If you have better ideas, feel free to leave comments!


r/swift 4d ago

The hidden cost of throw in XCTest: 40x slower than in an executable

Thumbnail
gallery
0 Upvotes

Found this while fuzzing my encrypted messenger.

XCTest installs a global observer on every throw, making it 40x slower (16.8s vs 0.42s). try?does NOT avoid the cost.

Full breakdown, minimal reproduction code and fix here: https://github.com/MagicYassin/xctest-throw-cost

Do check the numbers on your own machine. 👨🏻‍💻☁️🌌


r/swift 6d ago

New State Macro (Private vs Non-Private Behavior)

Post image
96 Upvotes

I always keep my @.State private but this was interesting to know.

Source: https://x.com/pointfreeco/status/2093052971890229285?s=20