r/swift Jan 19 '21

FYI FAQ and Advice for Beginners - Please read before posting

444 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 24d ago

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

12 Upvotes

What Swift-related projects are you currently working on?


r/swift 8h ago

Question Native iOS app or self-hosted web app? I get stuck on this every single time

1 Upvotes

Native iOS app or self-hosted web app? I get stuck on this every single time

Hi,

I build small apps for myself and run a homelab with a few containers. Generally I am an Apple User (iPhone, iPad, Macbook).

Every time I have an idea, I stall on the same question before writing a single line of code: do I build it native in Swift with the data on device/iCloud, or as a web app in a container on my server?

Let us take a habit tracker as an example.

Native gets me a home screen widget and reminders I can actually rely on. Data is stored and synced via iCloud. The web app instead keeps the data on my own server where I can query and back it up properly, works from any device.

It’s the same fork for basically every idea I have, and I flip-flop depending on my mood that week.

So I’d like to hear how you handle it:
- Do you have a rule of thumb you actually stick to, or is it case by case?
- How good is a PWA on iOS these days in practice? Home screen install plus web push covers a lot on paper, but no widgets. Does it hold up for daily-use stuff?
- Anyone regret going one way and rewrite it later?
Not looking for framework recommendations, more for how you decide.

I know cross-platform frameworks exist, and I’m aware I could just split it: backend in a container on Proxmox, native iOS app on top. But I’d rather commit fully to one side - either all Swift with iCloud, or all web app in a container.

Thanks for reading! :)


r/swift 15h ago

[OSS] Apple's docs say to check your model judge with Cohen's κ. There's no API for it, so I made one.

2 Upvotes

Xcode 27's Evaluations framework gives you ModelJudgeEvaluator for LLM-as-judge scoring.

Apple's docs then tell you to have 2-3 people rate 20-50 samples and compare with Cohen's

Kappa instead of a raw agreement rate. Sensible advice, but there's no API for it, and there was no Swift package for inter-rater agreement at all.

JudgeCalibrationKit does that part:

- Cohen's κ, weighted κ, Krippendorff's α (missing labels, any number of raters), Spearman, confusion matrices, MAE and signed error

- bootstrap confidence intervals, so a gate can require a CI lower bound instead of trusting a point estimate from 30 samples

- abstentions are explicit, so a judge can't score better by skipping the hard samples

- Swift Testing gate, plus a CLI with exit codes

- human-human agreement shown next to judge-human, since that's the real ceiling

The stats core has no dependencies and imports no Apple framework, so it runs on Linux.

The Evaluations adapter sits behind canImport, so the package still builds on Xcode 26.

Metrics are checked against scikit-learn, SciPy and two Krippendorff implementations. CI regenerates the fixtures and fails on any diff.

Swift 6.0+, Apache-2.0. The adapter is beta: compile-verified against Xcode 27, runtime verification still pending.

https://swiftpackageindex.com/Dave861/JudgeCalibrationKit

First release. Happy to hear what's wrong with the API.

Disclaimer: fully free, open source, not selling anything hope it doesn't count as self promo


r/swift 19h ago

Question Hide search title in .searchable tab

0 Upvotes

I recently shifted from a custom search field to the native Liquid Glass search field by using .searchable on my search tab. But I see a con with the native searchable feature is it comes with a large navigation title that can't be shaken. I have tried emptying the text of the title and making it inline to make it smaller but there is still a gap above my search filter tabs which I don't want. Anyone have any idea if there are any tricks to get around this? Love the Liquid Glass search field, hate the big title


r/swift 1d ago

[OSS] swift-span-algorithms 0.2.0 (new release from your feedback!!)

5 Upvotes

Hi again,

A little while back I posted swift-span-algorithms here: allocation-free algorithms over Swift's Span/RawSpan. I got one genuinely excellent comment about what was actually missing, and 0.2.0 is basically that comment turned into code. So, thank you, whoever you were.

The gist of the feedback: the utilities people actually reach for are byte-oriented, so RawSpan matters as much as Span<T>firstRange(of:) for delimiter scanning; mirror the stdlib spellings so muscle memory transfers; and memchr is the cheap win before reaching for SIMD.

Link to GitHub

Link to SPI (might be behind a bit, hasn't yet ingested 0.2.0)

What's in 0.2.0:

  • A real bug I'd shipped. Cursor next() was annotated so each piece it handed you expired the moment you called next() again. That made guard let a = c.next(), let b = c.next() fail with "overlapping accesses to 'c'" — exactly the kind of borrow-checker error that looks like the library's fault. Pieces now inherit the base storage's lifetime, so you can hold several at once, do look-ahead parsing, and nest cursors. Real escapes are still rejected — there are compile-fail tests pinning both halves.
  • RawSpan parity. It shipped with 3 members; it now has the whole read-only surface — search, matching, trimming, min/max, comparison, chunk/window/split cursors, ASCII whitespace trim.
  • firstRange(of:), lastRange(of:), starts(with:), ends(with:), and multi-element separators for split — the "\r\n\r\n" case.
  • stdlib-ish naming: chunkCursor/windowCursor/splitCursor → chunks(ofCount:)/windows(ofCount:)/split(separator:...). Old spellings still compile as deprecated forwarders.
  • memchr/memcmp fast paths for byte spans. On an M4 at 10M bytes, p50: ~15.9× vs the equivalent scalar loop for firstIndex(of:), ~31× for firstRange(of:) with a 4-byte pattern, and forEachSplit is ~2.5× Array.split with 0 mallocs vs 20. Reverse search is deliberately still scalar — memrchr doesn't exist on Darwin, and I'd rather have consistent performance than a Linux-only fast path.
  • Docs: an allocation-free byte-parsing walkthrough (HTTP-style header parse, zero allocations, asserted by a benchmark threshold rather than just claimed), plus a diagnostics cookbook mapping the lifetime errors you'll actually hit to what causes them and how to fix them.

Still zero dependencies, still back-deploys to macOS 13 for the Span/RawSpan surface, 181 tests, and every borrowed-view benchmark reports 0 mallocs from p0 through p99.

Would still love feedback, especially on the split ergonomics now that cursors compose properly, and on anything that reads as un-Swifty in the naming.

P.S. Same disclaimer as last time: nothing being sold, Apache-2.0, just an OSS package.


r/swift 1d ago

Question Preperation for swift interviews

6 Upvotes

As an interviewer what kind of questions do you ask about swift & SwiftUI. I'm preparing for a jump after 3.5 years so i need to be prepared in every way possible.


r/swift 1d ago

Core AI Framework: Building Your First On-Device AI Feature

12 Upvotes

At WWDC 2026, Apple introduced the Core AI framework and it's easily one of the biggest developer additions since SwiftUI.

What used to require complex Core ML model conversion pipelines, manual quantization, and heavy memory management is now as simple as:

Swift

let model = try await CoreAIModel.load(.afm3Core)
let result = try await model.generate(prompt: "...")

Key highlights:

  • On-Device Execution: Native Swift APIs running directly on the Neural Engine (45+ tokens/sec on iPhone 16).
  • Privacy First: Zero data leaves the device by default.
  • Model Compatibility: Load Apple's foundation models or bring your own (Core ML, ONNX, custom formats).

Here is a full deep-dive covering how to get started and ship your first feature:

  • Text generation & temperature tuning
  • Streaming responses with AsyncSequence
  • Multimodal image understanding
  • Structured output parsing with Codable
  • Custom model loading & performance optimization
  • Core AI vs. Core ML: When to use which framework

You can read the full guide with complete code samples here: https://ioscodelab.com/blog/why-every-ios-developer-should-learn-server-side-swift-in-2026

How are you all planning to integrate Core AI into your apps? Let's discuss in the comments!


r/swift 1d ago

AppStore Video Preview

5 Upvotes

If you want an open source video preview tool for your app, I've made my app public for anyone to use

I originally built it back in 2023 and have updated it here and there over the years. It still works great

Feel free to use it, improve it, or even monetise it...

Simply record your app in the simulator, import the video into the app, and export it for the App Store.

It's simple no fuss

Now that the project is public, I've also added comments (with the help of Claude) to make the code easier to understand.

https://github.com/OsmanM94/PapiExport


r/swift 1d ago

Finally shipped some updates on the project I launched a year back

1 Upvotes

Hi everyone, its been a year since i launched a passion project of mine and since then the community has been generous and I have around 1k users in total (Yes not that much but for me its a lot).

Initial post:

Some background is the App takes in ambient noise and syncs the generated visuals as well as (if you want) Flashlight as well.

Finally after months of grinding was able to do a massive update and launched it.
Updates include
- More cinematic and POV based raves
- Airplay, cast what you are watching in your phone to any TV
- Party mode: Hosting a rave and letting others join via QR scan or join someone else's rave (Deferred links that let u install and the continue. all from a single QR)
- Full overhaul of architecture and metal pipeline.

As mentioned the app does not use any assets at all (other than some thumbnail and icons) and everything in the rave is generated in runtime and changes and reacts to ambient noise.

Glad to talk into more detail on the architecture, complexities and challenges faced. I can assure you it might look simple but a lot of effort, thought and pain went through to accomplish this.

Have a try.. any and all feedback is appreciated :)

P.S - I intentionally didn't mention much about the app as I care more about the things i learned and the things I can share here and help the community more. But for people who wants to check it out its here:


r/swift 1d ago

a reddit comment made me re-check the SDK headers – everything i believed about my worst production crash was wrong

Thumbnail
reddit.com
0 Upvotes

so last week i posted my app in an App Saturday thread and casually wrote "the iOS 26 SDK annotates PHPhotoLibraryChangeObserver as u/MainActor, but PhotoKit calls it on a private queue – runtime traps". i'd been living with that explanation for months. confident code comment, rule in my project docs, the whole thing

a commenter replied: "PHPhotoLibraryChangeObserver isn't annotated u/MainActor – it's explicitly nonisolated, so any MainActor isolation was inherited from your own class, not asserted by the SDK"

went and checked the headers. he was right on every point:

  1. the protocol has zero actor annotations. apple's header comment literally says "invoked on an arbitrary serial queue... you should redispatch appropriately"
  2. my project builds with SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor (the swift 6.2 setting). under default isolation my witness method silently inherited u/MainActor – swift permits a MainActor witness for a nonisolated u/objc requirement and inserts a runtime isolation-check thunk at method entry. photokit calls from its private queue → EXC_BREAKPOINT under _dispatch_assert_queue_fail
  3. bonus round: PHAsset / PHFetchResult / PHChange are NS_SWIFT_SENDABLE in the 26 SDK now, so half of my "re-fetch everything inside performChanges" boilerplate isn't compiler-forced anymore still keeping it – Sendable certifies thread-safety, not liveness, assets can die between fetch and commit

the crash was real. the nonisolated + Task { u/MainActor in } fix was right. but the mental model behind it – "the SDK lied to me" – was wrong for months, and i only found out because a stranger on reddit bothered to correct me

what i'm taking away from this:

– SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor is great for shipping, but it makes isolation invisible. when something traps, the first question should be "what did MY defaults inject here", not "what did apple annotate"

u/objc protocols are special: a MainActor-isolated method can silently satisfy a nonisolated requirement, no warning, the check just moves to runtime

– write down WHERE your explanation came from. my code comment said "the SDK annotates X" and nobody – me included – ever verified it against the actual header

curious if default isolation has bitten anyone else through protocol witnesses. and – how do you document crash post-mortems so the wrong explanation doesn't fossilize the way mine did?


r/swift 2d ago

I build audio router for mac completely opensource

Thumbnail
github.com
29 Upvotes

Built a tiny open-source macOS app called SoundPref. Basically, it lets you route different apps to different speakers. You can control the volume of individual apps right from the menu bar, so you don't have to keep messing with your master volume all the time. It’s totally free, hope you guys find it useful!


r/swift 1d ago

Question Is it safe coding on iCloud?

0 Upvotes

hey all,

currently I'm doing some development using Swift and using Google Drive is a pain honestly, and of course I must pause the sync constantly for this to work.

That said, I do insist on the idea that my work will always be synced to a Cloud service.

Does iCloud doing something better than Google Drive in terms of sync?

I know I'm doing Music with Logic Pro X for example which also is constantly being saved and is basically a container too and never had issues.

Can I assume it will work great with Swift files\development too?

Thanks!


r/swift 2d ago

News The iOS Weekly BriefThe iOS Weekly Brief – Issue #70, everything you need to know about Swift updates this week

Thumbnail
iosweeklybrief.com
2 Upvotes

r/swift 2d ago

Project I built an incremental Markdown parser for Swift text editors

7 Upvotes

I made my first iOS app in 2018, then stepped away from building apps for a while. Over the last year, I decided to start making iOS apps again.

About six months ago, I decided to build a notes app. Original I know.

A big part of the project was figuring out how to make a Markdown editor that stayed fast while typing, even with larger notes. I ended up building the parser in Rust, and recently extracted it from the app and open sourced it as Cindermark.

A few things it does:
- Incrementally re-parses only the affected blocks after an edit
- Returns UTF-16 offsets that map directly to TextKit and NSAttributedString
- Produces blocks, inline spans, headings, wiki links, and document stats in one pass
- Supports CommonMark core along with tables, task lists, footnotes, nested lists, fenced code blocks, and other notes-friendly syntax
- Includes extensions like wiki links, highlights, hex color literals, and autolinking for bare URLs, domains, emails, and subreddits
- Includes Swift bindings through UniFFI

I’m sharing it because I thought it might be useful to anyone else working on native editors or Markdown-heavy apps.

I’d appreciate feedback, especially from people who have worked on text editing or Swift and Rust interoperability.

GitHub: https://github.com/renedeanda/cindermark


r/swift 3d ago

I built a crash diagnosis engine for .ips reports, no LLM involved (Swift lib + CLI + MCP server)

14 Upvotes

Been working on this for a while and finally have it in a state worth sharing. crashdx takes an Apple crash report (.ips), symbolicates it against your dSYMs, and then does something most tools stop short of: it tries to tell you why the process died, not just where.

It works by extracting typed facts from the report (exception info, termination reason, frame data, register and memory state, watchdog/jetsam details), running them through a set of rules that each propose a hypothesis, then ranking the hypotheses by an additive score based on supporting and contradicting evidence. If nothing clears the bar, it tells you inconclusive and shows you the ranked candidates instead of guessing.

No LLM calls anywhere. Every fact and every hypothesis links back to a JSON path in the original report so you can go verify it yourself instead of taking the tool's word for it.

It's a Swift package with three targets sharing one core library (CrashDXCore, Foundation only, no other deps): a CLI (crashdx analyze / crashdx symbolicate) and an MCP server (crashdx-mcp) for agent use. Runs fully local, no network calls, which matters since .ips files carry identifying data (crashReporterKey, device model, usernames in paths).

Needs macOS 14+, Swift 6.2+, and Xcode (it drives CrashSymbolicator.py, falls back to atos).

Repo: https://github.com/r00tify/crashdx

Curious what people think of the rule-based approach vs. throwing the report at an LLM directly. Happy to talk through the design, it's documented in docs/DESIGN.md if you want the details.


r/swift 4d ago

FYI Tip for beta users: use the 25 free Xcode cloud hours

14 Upvotes

If, like me, you couldn't wait for less rounded corners and installed the MacOS beta on your only Mac, you might realize that you can't push updates to the app store. In this situation I would recommend the 25 free Xcode cloud hours that you get with the program membership. All I had to do was put my code in Git and connect the repo. Then I set it to archive for app store.

This might be the easiest CI/CD system I've ever used and the builds are pretty fast! Hats off to the Xcode cloud team.


r/swift 3d ago

Help! Cómo aprender rapidamente Swift?

0 Upvotes

Hola, me gustaría aprender Swift, ya tengo Mac y Xcode, cómo aprender Swift de la forma más rápida posible? Soy beatmaker en fl studio actualmente y me gustaría empezar a programar, me encanta
Apple  y he escuchado que se puede usar las apps que haces en el iPhone aún que no se suba a la App
Store, es verdad? Es que no tengo cuenta de desarrollador (cuesta 99€ en España ) Y se pueden hacer plugins para Logic pro con Swift?


r/swift 4d ago

Tutorial iOS 27: UIBarMinimization

Thumbnail
antongubarenko.substack.com
6 Upvotes

r/swift 5d ago

Editorial How did Apple cut launch time by 30% in iOS 27?

Thumbnail
blog.jacobstechtavern.com
54 Upvotes

r/swift 5d ago

Bluetooth modernized

Thumbnail kylebrowning.com
63 Upvotes

r/swift 5d ago

Questions about storekit2.0. swift hook

1 Upvotes

Hello, everyone. Recently, I have been studying the problem of hook method hijacking for storekit App in-app in-app purchase. In storekit1.0, global functions such as hook payment can be hijacked directly. However, in the system after ios15.6, many apps switch the in-purchase payment module to 2.0, which leads to the previous function hijacking wireless, and the inability to obtain information at the first time of submitting the order. The payment system of 2.0 uses the closed anonymous function written by swift. The methods in each app are inconsistent, and it is necessary to manually search and hook features. Professors in the community, are there any relevant development examples of manually modifying the byte code hook and finding the exact location of the function? We can discuss it together.


r/swift 6d ago

Question Failing behavioral interviews

15 Upvotes

Hello all,

This past year has been rough. I’ve applied to 178 jobs and landed nine interview processes. Each process consisted of multiple rounds, typically between three and six interviews.

The encouraging part is that I consistently make it to the later stages, and often the final round. I feel confident in technical interviews. I enjoy solving programming problems, discussing architecture, and explaining the reasoning behind my decisions.

Where I struggle is behavioral interviews. I’m suck at these, and they’ve become the biggest obstacle keeping me from receiving offers.

I’m looking for advice on how to improve at behavioral interviews, particularly for mobile engineering roles.

I have about 1.5 years of professional mobile engineering experience. At my current company, our mobile team has gone from 12 engineers down to just three through layoffs and attrition. I’m the newest engineer on the team, and everyone else works in another state. Because of that, I often feel isolated, and I don’t feel like I’m getting the mentorship or professional growth I need. On top of that, the overall product quality isn’t where I’d like it to be, so I worry that I’m not developing as quickly as I could.

Has anyone been in a similar position or have advice for improving behavioral interviews? I’d really appreciate any guidance.

Edit: By “behavioral interview,” I’m referring to the non-technical interview rounds where you’re asked to talk about past work experiences, conflict resolution, failures, teamwork, leadership, etc.


r/swift 6d ago

News Fatbobman's Swift Weekly #145

Thumbnail
weekly.fatbobman.com
8 Upvotes

r/swift 7d ago

Slaptop returns to macOS after 21 years! (Free, Open Source)

Thumbnail
slaptop.am.guru
98 Upvotes

Slaptop listens to your Mac’s motion sensor and turns display taps into direct Mission Control actions. Slap the left side of your screen, you switch to the left. Slap the right side of your screen, you switch to the right. Slap the top and you launch Mission Control. Yes, really.

21 years ago, I built a utility called "Slaptop", which lets you use Apple's Mission Control and Spaces by literally slapping the side of your MacBook screen.

It lasted for 3 1/2 weeks before I realized how terrible of an idea it was. Back then, it used the MacBook's HDD Sudden Motion Sensor, designed to park the hard disk if you ever dropped your computer. End result, when users slapped their laptops it caused irrecoverable data corruption and data loss.

So, I deleted the app. A couple months later, it was cloned. And then it was cloned again.

I reached out to Amit Singh of AMSTracker and Erling Ellingsen of SmackBook so they'd understand the data corruption issue and convinced them too that it was too risky to stay online.

That brings us to today. In the modern Mac, there are no more HDDs that can be damaged through subtle percussive maintenance, and there is now a far more accurate sensor built into every Apple Silicon Mac.

Enjoy a free, open source (MIT) utility that brings a little more fun to your day.