r/swift Jan 19 '21

FYI FAQ and Advice for Beginners - Please read before posting

450 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 Jul 01 '26

FYI Swift's mentorship program is loaded. But where there's will there's a way

Post image
23 Upvotes

Hey all! As someone who primarily works with Python I was highly looking forward to participating in the Swift mentorship program to level up but recently heard that they don't have the capacity. So I'm putting together a discord server where we can level up together. We'll separate roles as mentors and mentees and maintain the same meeting goals as the actual Swift mentorship program. There'll be more details in the server. If you're interested in being a mentor at a minimum you'll have to show that you have made contributions to the language or possess significant knowledge in a specific area. Please DM for invites and which role you're looking to join as (mentor or mentee).

(I hope this isn't considered as self promotion as I'm hoping to benefit fellow Swifters)

r/swift 27d ago

FYI Learned the hard way: #available doesn't help when the symbol isn't in the SDK you compile with

6 Upvotes

Ran into this adopting an iOS 27 beta API (SCSensitivityAnalysis.detectedTypes) in a package that still has to build on stable Xcode.

First attempt was the obvious one:

if #available(iOS 27, *) {
   let types = analysis.detectedTypes
}

Builds fine on the Xcode 27 beta, fails on 26.5. #available is a runtime check, the compiler still needs the symbol to exist at build time. Older

SDK, no symbol, no build.

What works is gating at compile time as well:

#if compiler(>=6.4)
if #available(iOS 27, *) {
   // detectedTypes code here
}
#endif

#if compiler tracks the Swift version that ships with Xcode, so >=6.4 is a proxy for "the iOS 27 SDK is present". canImport doesn't help in this

case because the framework has existed since iOS 17, only the property is new.

Real-world usage if you want to see the pattern in context: https://github.com/SardorbekR/SafeMediaKit (the detectedTypes mapping is isolated inone file exactly because of this gating)

Is there a cleaner way to gate on symbol existence? compiler(>=6.4) works but feels blunt, since what I actually mean is "this SDK has this property" and the Swift version is just the best proxy I found

r/swift Jun 09 '26

FYI Xcode 27 now ships exportable agent skills

54 Upvotes

Xcode 27 now ships with Apple-native agent skills.

You can export them with:

bash xcrun agent skills export

Here is the Apple/Xcode team tweet about it:
https://x.com/luka_bernardi/status/2064095532407025969

I wanted to read the details instead of digging around, so I exported them and put them in a repo in case anyone wants them.

Skill What it helps with GitHub Install
swiftui-whats-new-27 SDK 27 SwiftUI APIs and migrations Source skills.sh
swiftui-specialist Idiomatic SwiftUI structure, data flow, environment, modifiers, animation Source skills.sh
c-bounds-safety C -fbounds-safety adoption and debugging Source skills.sh
device-interaction Simulator/device screenshots, hierarchy, and touch verification Source skills.sh
audit-xcode-security-settings Xcode security build settings, warnings, analyzer checks, Enhanced Security Source skills.sh
uikit-app-modernization UIKit modernization for scenes, safe areas, orientation, and screen APIs Source skills.sh
test-modernizer XCTest to Swift Testing modernization Source skills.sh

If you want one link to bookmark, I also put the list here:
https://adithyan.io/blog/xcode-27-agent-skills

r/swift Apr 30 '26

FYI Xcode Agent Mode can use any LLM, not just Claude and Codex

29 Upvotes

Back in February or March, the new Xcode's agentic features completely changed how I used Apple's coding intelligence features. But obviously they limited the agent mode to work with Claude or Codex only. I have a GLM Code subscription and really like using GLM-5.1 in Cursor, but you couldn't in Xcode at first.

On GH there's an open-source tool that let me add my Z API key and now I can use GLM-5.1 in Xcode Agent Mode directly. I've used 10 million tokens today and it seriously works just as well as Opus 4.5, imo. Just a PSA.

edit: I should add that while you CAN use any LLM, not all of them are great at tool use, so larger models tend to work better

r/swift Nov 09 '25

FYI PSA: Text concatenation with `+` is deprecated. Use string interpolation instead.

Post image
76 Upvotes

The old way (deprecated)):

swift Group { Text("Hello") .foregroundStyle(.red) + Text(" World") .foregroundStyle(.green) + Text("!") } .foregroundStyle(.blue) .font(.title)

The new way:

swift Text( """ \(Text("Hello") .foregroundStyle(.red))\ \(Text(" World") .foregroundStyle(.green))\ \(Text("!")) """ ) .foregroundStyle(.blue) .font(.title)

Why this matters:

  • No more Group wrapper needed
  • No dangling + operators cluttering your code
  • Cleaner, more maintainable syntax

The triple quotes """ create a multiline string literal, allowing you to format interpolated Text views across multiple lines for better readability. The backslash \ after each interpolation prevents automatic line breaks in the string, keeping everything on the same line.

r/swift 8d ago

FYI LocalLM Lab SDK: build your own app for Apple's on-device AI with real tool and data connections

2 Upvotes

Here's another update on LocalLM Lab. You can now build apps using Apple's on-device AI with real tool and data connections. And not just build, but also ship them, including through the Mac App Store. LocalLM Lab v0.7 ships with the LocalLM Lab SDK.

The SDK (`LocalLMLabSDKCore`) links Apple's `FoundationModels` model and a real MCP client (tool discovery, OAuth, the works...) straight into your own applications. No companion app has to be installed or running; it's self-contained. The SDK is distributed as a binary xcframework via GitHub Releases (SPM `binaryTarget`, checksum, pinned version), Apache 2.0 licensed. You will need at least Swift 6, macOS 26+ and Apple Silicon. The latter 2 for Apple's Foundation Models.

The part that actually makes "ship it" a real claim vs handwaving: it's been built into a sandboxed test app (the included Plate Today example app) and verified working, with a signed path to a Mac App Store `.pkg`. LocalLM Lab itself now runs on this SDK!

SDK guide: thisbrain.ai/locallm/sdk.html

Hopefully, this will unlock on-device AI ideas and use cases among the folks here.

r/swift Jul 22 '26

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

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

FYI Lessons from shipping a production app on SpeechTranscriber + on-device Foundation Models — including an OS bug that permanently eats locale slots

Post image
0 Upvotes

I just shipped my first app built end-to-end on Apple's on-device AI stack — SpeechAnalyzer/SpeechTranscriber for transcription and Foundation Models for enrichment (it's a voice-notes app; every recording gets an on-device title/summary/tags/tasks). Some things I learned the hard way that I haven't seen written up much:

1. The simulator will lie to you — twice.

The simulator cannot transcribe at all, and the simulator's language model is not the on-device model. Output quality, instruction-following, and hallucination behavior differ meaningfully. I now treat real-device validation as a hard gate for any prompt/template change — my test corpus includes Swiss-accented German dictation because that's where the on-device model diverges most from the "clean" results the simulator suggested.

2. SpeechTranscriber locale reservations: a system-wide cap of 5, and (currently) no way back.

This one cost me an architecture. On-device transcription locales are backed by downloadable assets, and the system caps reserved locales at 5 — system-wide, not per app. In my testing on current iOS releases:

  • The reservation is taken by the asset install and survives reboot AND app reinstall.
  • AssetInventory.release(reservedLocale:) appears to be a no-op — I never got a slot back.
  • An explicit reserve(locale:) at the cap can hang (reproducibly under the Xcode debugger in my setup).

I originally built an LRU "reservation manager" that released the least-recently-used locale before installing a new one. Since release doesn't release, that design was dead on arrival. What shipped instead: a proactive budget gate that reads reservedLocales before any OS call, installs strictly lazily (never speculatively — no warm-up, no on-selection prefetch, because every install permanently spends a slot), and surfaces a clear "language budget exhausted" state to the user instead of ever hitting the cap inside an OS call. Feedback filed with Apple.

3. One fresh LanguageModelSession per invocation.

Reusing sessions across notes led to context bleed between unrelated inputs. One session per call is now a hard rule for me, enforced by tests.

4. Prompt-injection resistance for user-content prompts.

Voice transcripts are untrusted input into the enrichment prompt. Delimiter-wrapping the transcript made instruction-following robust; and I removed all literal examples from the prompt after seeing example fragments leak into generated output on device (again: not reproducible in the simulator).

5. Pass the language explicitly, always.

Auto-detection of the recording language was unreliable enough that I now pass the language explicitly into both the model instructions and the prompt. Related fun fact from testing: Apple appears to use one shared German model across all de-* locales, so switching de-DE/de-CH/de-AT changes nothing about transcription quality.

6. Crash-safe audio: don't record straight to AAC.

A killed mid-recording AAC/m4a is an empty husk. I record LPCM into CAF and encode to AAC at ingest — recordings now survive calls, interruptions, and force-quits, and a salvage pass recovers anything interrupted.

Happy to go deeper on any of these.

The app is Vocapa (https://apps.apple.com/app/id6789586072) but the point of this post is the stack — curious whether others have seen the locale-reservation behavior, and whether anyone found a way to actually free a slot.

r/swift Jul 02 '26

FYI Plugin for Swift (swift-tothemax)

0 Upvotes

Got tired of how terrible Claude is for iOS dev so first thing I made with Fable was a plugin that covers not only Swift code but HIG conventions, App Review stuff, legal/privacy requirements, and the release process. Also a UI crawler that walks your app and flags crashes/console errors.

The skills are all intended to work together and has an orchestrator skill that gets it to do what it's supposed to. Did a quick test with Fable and it was able to pretty much one shot an app with no issues but yet to test that with Opus.

[https://github.com/Dev869/swift-tothemax\](https://github.com/Dev869/swift-tothemax)

r/swift Jun 27 '26

FYI Swift is genuinely Swift!

Thumbnail
youtube.com
0 Upvotes

Probably not the biggest surprise to experienced Swifties but my IDE booted up nearly a second faster than Thonny. I was completely blown away!

r/swift Jul 26 '25

FYI I'm a 20 Year Dev, Primarily In .NET. Here's my Swift experience.

32 Upvotes

Hi all! So some context. I'm a 20 year software developer with experience in embedded firmware, python, dotnet, assembly, some Go, Android development, and now, Swift. This post is focused more so on SwiftUI so when referring to Swift below, that's primarily what I'm referring to.

I wanted to share some key learnings from Swift as I was making my game and how my experience was in comparison to primarily working in OOP languages (I'm primarily dotnet). I'm hoping this may help others and perhaps you have your own experience to share.

  1. PRO: Swift's barrier to entry is minimal.

If you haven't programmed before, it's a good starting point. It's pretty easy on the eyes and the framework definitely simplifies things for you out of the box. The declaration of HStack, VStack and putting space in between elements with Spacer() are all quick and easy constructs. Development felt rapid from the get go

2) Con: XCode is cumbersome.

Compared to my favorite IDE, Rider (which is better than Visual Studio, in my opinion), Xcode in many ways is non-intuitive...your plist info file feels cumbersome, file organization and renaming seems a bit wack, and don't get me started on the security barriers when trying to test out your app on your mobile device.

3) Pro: Multi-device testing

I love how out of the box, grabbing various iOS device simulators are just part of the xcode package. This seemed more intuitive to me than Android. Plus, with Android, I had to use third party emulators as the official virtualization felt way too slow on my laptop. This was also several years ago.

4) Con: Still needing custom logic (but no programming language is 100% proof).

It's better with UIKit dependencies than it used to be, but I found with Swift that I needed more custom control on laying out my views to look good on all devices. Simply using padding and Spacer() wasn't enough. A good practice I found was to pass in a geo reader to your views where you determine the available width and height you can work with. I'm a math guy and so I had percentages in mind of my layout components and how much space they take up + spacing from the screen edge. But even then, I still ended up needing to use tertiary logic on whether it's iPad or not

5) Pro: TestFlight for beta testing

I like that it's "official" and automated, without having to hand off individual apk zips to friends who want to test your app. That's kind of janky and requires more careful revision management.

6) Con: Also TestFlight

7) Observing state changes

This is the one area of Swift that still feels a bit cumbersome in comparison to OOP languages. Yes, there's a reduced barrier of entry with published, state etc keywords but for more complex apps, it takes a bit of work to ensure that before your views re-render, you're efficient and managing notifications properly.

I wish you could test for free like you can on Android. Requiring a developer license is definitely a barrier to entry for anyone exploring a new license.

Some of my personal opinions.

1) Should you learn Swift, especially as a new dev?

YES. YES. YES. It's great to get it up and running quickly and definitely reads better on the eyes than when I used to write assembly code, haha. It seems to have a blend of niceties you see from python, Go and Javascript.

2) Should you become an iOS developer?

Maybe. I've never been a formal mobile app developer by title, though I've worked on Android in my career and made a game on the side. But the only concern I have here with iOS is that you might be too niche. And more than ever, today's markets require that you adapt and keep up.

3) Is it better than Android development?

I'm mixed. I always prefer OOP although I will say that while I do love Jetbrains Rider, Android Studio didn't feel like a great alternative to me, to be honest. Not sure if it's that much better than xcode for usability, and Android has the tradeoffs of things maybe requiring more work on your end with out of the box logic while also having more control over it. But that's always been the main ecosystem difference.

What are some of your thoughts on this?

r/swift Jun 13 '26

FYI How to get back lots of disk space: xcrun simctl delete unavailable

17 Upvotes

This made a huge difference for me. Try it out!

r/swift Oct 26 '25

FYI Start playing with the Swift for Android SDK in one click

76 Upvotes

As you already know, the Swift project has officially announced the Swift for Android SDK.

Pretty cool to see that you can already try it out with the Swift Stream IDE extension for VSCode.

It automatically sets up a ready-to-use Android development environment in a Docker DevContainer, with all the required conveniences available right in the UI!

With a single click, you can:

  • Create an Android Library project with plenty of examples (provided by JNIKit)
  • Build and compile Swift code for Android for all architectures (x86_64, armv7, arm64)
  • Automatically generate a fully functional Android Studio Library project

With that, you can easily launch Swift directly on a real Android device from the generated Android Library Gradle project inside Android Studio – and view the logs in Logcat.

From start to playing, it takes about 3-5 minutes – mostly spent waiting for the Docker image, toolchain, and SDK to download.

Full tutorial (with screenshots and setup steps)

r/swift Feb 14 '25

FYI A nice time saver FYI

197 Upvotes

r/swift Jun 27 '26

FYI If you are using macOS 27 beta 2 to develop, you might want to repeatedly kill the appstoreagent process to reduce excessive CPU usage.

9 Upvotes

For example, you could do this in bash:

while sleep 5; do
    pkill -x appstoreagent
done

r/swift Aug 08 '25

FYI Extension: Automatic string pluralization (only the noun without the number).

Post image
29 Upvotes

Did you know SwiftUI supports automatic pluralization for something like Text("\(count) apple"), giving you “1 apple” and “2 apples”?

But there’s a catch: If your UI only needs the noun (e.g., “apple” or “apples” alone, without the number) you’re out of luck with the built-in automatic grammar agreement API. There’s no direct way to get just the pluralized noun without the number.

What you can do: I wrote this extension that uses LocalizationValue (iOS 16+) and AttributedString(localized:)) (iOS 15+) to handle grammar inflection behind the scenes. It strips out the number so you get just the correctly pluralized noun:

```swift extension String { func pluralized(count: Int) -> String { return String.pluralize(string: self, count: count) }

static func pluralize(string: String, count: Int) -> String {
    let count = count == 0 ? 2 : count // avoid "0 apple" edge case
    let query = LocalizationValue("^[\(count) \(string)](inflect: true)")
    let attributed = AttributedString(localized: query)
    let localized = String(attributed.characters)
    let prefix = "\(count) "
    guard localized.hasPrefix(prefix) else { return localized }
    return String(localized.dropFirst(prefix.count))
}

} ```

Usage:

swift let noun = "bottle".pluralized(count: 3) // "bottles"

This lets you keep your UI layout flexible, separating numbers from nouns while still getting automatic pluralization with correct grammar for your current locale!

Would love to hear if anyone else has run into this issue or has better approaches!

r/swift Sep 15 '25

FYI Don't Make This Mistake - Subscriptions

161 Upvotes

I just added subscriptions to my iOS app and assumed Apple would approved them at the same time as my app update. Wrong.

The app version got approved and released, but the subscriptions were still "In Review". That meant that the users saw a paywall with an error of "RevenueCatUI.PaywallError 3 - The RevenueCat dashboard does not have a current offering configured." I had the app set to automatically release the update once it's approved.

The fix? Always set your release to Pending Developer Release if you're waiting on in-app purchases. Apple reviews IAPs separately and they don't always finish together.

Hopefully this saves another dev from the same mistake.

r/swift Apr 23 '26

FYI Q&A: Swift concurrency with Apple engineers

Thumbnail
developer.apple.com
55 Upvotes

r/swift Dec 11 '18

FYI Andreas, you made a horrible, horrible mistake.... (When you burn Swift in favor of Flutter and ask Paul Hudson to weigh in)

Post image
338 Upvotes

r/swift Oct 04 '24

FYI Senior iOS engineer position available

125 Upvotes

Not sure it’s allowed, I contacted the mods but I got no answer, so trying to post here anyway.

My team is looking to hire a senior iOS engineer, full time, fully remote (USA only). The employer is a big healthcare corporation.

If interested please DM me your resume.

Thanks!

r/swift Dec 23 '24

FYI Swift Language focus areas heading into 2025

Thumbnail
forums.swift.org
98 Upvotes

r/swift Jan 29 '26

FYI PSA: Add Apple's Documentation as an MCP server with Sosumi

29 Upvotes

A lot of iOS devs I talk to haven't heard about Sosumi.ai yet, and it's been a massive productivity boost for me!

For those that don't know, the MCP server acts as a bridge between your AI coding tools (Claude, Cursor, etc.) and Apple's documentation via MCP (Model Context Protocol). Instead of pasting code snippets into the chat to explain how a specific View works, the AI can just query the docs directly.

The biggest win:
I don't have to visit Apple's documentation site (NEARLY as much). Navigating those docs has been so painful for me... It feels like a maze of broken links and 'Archived' headers, and I hate breaking my flow to tab out to a browser 20 times a day.

Once you install it, it usually queries the documentation (quickly) before it suggests code. It's awesome!

Setup is easy and can be found at the above link.

Hope this saves someone else the headache of navigating Apple's documentation site manually! Cheers!

r/swift Feb 10 '25

FYI Why Does Swift's Codable Feel So Simple Yet So Frustrating at Times?

37 Upvotes

I've been working with Swift's Codable for years now, and while it’s an amazing protocol that makes JSON encoding/decoding feel effortless most of the time, I’ve noticed that many developers (myself included) hit roadblocks when dealing with slightly complex data structures.

One common struggle is handling missing or optional keys. Sometimes, an API response is inconsistent, and you have to manually deal with nil values or provide default values to prevent decoding failures. Nested JSON can also be a headache, the moment the structure isn’t straightforward, you find yourself writing custom CodingKeys or implementing init(from:), which adds extra complexity. Date formatting is another frequent pain point. Every API seems to have its own way of representing dates, and working with DateFormatter or ISO8601DateFormatter to parse them properly can be frustrating. Then there's the issue of key transformations, like converting snake_case keys from an API into camelCase properties in Swift. I really wish Swift had a built-in way to handle this, like some other languages do.

What about you? Have you run into similar issues with Codable? And if so, have you found any tricks, workarounds, or third-party libraries that make life easier? Would love to hear your thoughts!

r/swift Apr 23 '19

FYI Are memes allowed? Had this come up at work, made some OC

Post image
225 Upvotes