r/swift • u/lanserxt • 4h ago
Tutorial iOS 27: Now Playing Framework
r/swift • u/DuffMaaaann • Jan 19 '21
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.
Please read this before posting!
Tutorials:
Official Resources from Apple:
Swift Playgrounds (Interactive tutorials and starting points to play around with Swift):
Resources for SwiftUI:
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.
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 • u/Swiftapple • 24d ago
What Swift-related projects are you currently working on?
r/swift • u/lanserxt • 4h ago
r/swift • u/Davidotto13 • 10h ago
For the past few months I've been building Lumen, a native macOS browser written in Swift and SwiftUI on top of WKWebView. I wanted to learn Swift properly, and a browser touches everything: UI, performance, storage and security. It's taught me more than any tutorial.
All the releases are from today because I'd already built the whole browser but never put it on GitHub, so I just uploaded all the versions I'd made. (If you see gaps between the uploads, it's because I was running the tests, building the DMGs and so on.)
Some things I ran into:
.equatable() rows that take plain values, and by moving fast-changing state (load progress, pull-to-refresh) into separate small ObservableObjects.WKWebsiteDataStore(forIdentifier:): removing a store while the app is running fails with "in use", and calling it before WebKit has initialised crashed the app. So I erase the data immediately and remove the folder at the next launch.resumeDownload(fromResumeData:) works well, but decide(destination:) is not called again on resume, so you have to keep track of the destination yourself.INSERT OR REPLACE.NSProcessInfoPowerStateDidChange) and on memory pressure (DispatchSource.makeMemoryPressureSource).codesign --verify --deep --strict before replacing itself.Tech: Swift, SwiftUI, WKWebView, SQLite. No Electron, no third-party dependencies.
It's completely free and open source.
Download it from: scadavide55.github.io/Lumen
Code: github.com/scadavide55/Lumen
It's still a work in progress (latest pre-release is 1.5.2), so code review and criticism are very welcome. What would you have done differently?
r/swift • u/fatbobman3000 • 23h ago
r/swift • u/PallavRai • 20h ago
Saw how foldable phones blur the screen while folding and wanted it on my Mac. Turns out MacBooks have a hinge-angle sensor, so I hooked into it.
As the lid closes, the screen blurs and dims with it. Open it again and the blur fades back out. Touch the keyboard and it’s gone.
It’s free and open source, written in Swift. Needs an Apple silicon MacBook on macOS 14 or later.
https://github.com/Pallavrai/LidBlur
Not every MacBook exposes the sensor, so I’m curious which ones work. Let me know if yours does or doesn’t. And if you like it, a star would make my day 🙂
MD QuickLook is a Quick Look extension that renders Markdown in Finder without WebKit. A Rust core produces a compact layout (text plus blocks, paragraphs and styled runs at UTF-16 offsets), and the Swift side turns it into an NSAttributedString and draws it with TextKit 1:
NSTextBlocks with borders and backgrounds; tables are NSTextTables<details> sections work by cutting the folded text out of the storage and re-inserting it on click, since TextKit 1 can't hide paragraphsA typical README is ready in ~30 ms. Source (MIT): https://github.com/armamut/md-quicklook Longer write-up: https://medium.com/@armamut/previewing-markdown-on-macos-in-30-ms-a-rust-core-and-textkit-no-web-engine-1adfa2734f48
Curious whether anyone has tried the same with TextKit 2.
I want to limit the number of threads spawned by Swift's cooperative runtime to a number lower than the number of available CPUs. The reason is because I want to run Swift code in a Linux container that limits scheduling to only 8 CPUs regardless of how many the system has. I've tried setting LIBDISPATCH_COOPERATIVE_POOL_STRICT=n where n is the maximum number of threads, but apparently Swift doesn't use libdispatch on Linux so that does nothing. Can anyone tell whether there's a different environment variable that I can set, or at least a compile-time option or function that I must call in the code in order to set the number of threads spawned by the cooperative rumtime?
r/swift • u/Agreeable_Stable_235 • 2d ago
I built a native macOS menu bar utility in Swift/SwiftUI called PortRadar to manage listening localhost ports without having to run lsof -i :3000 and kill -9 in the terminal, and I'm sharing it 100% free and open-source (MIT).
What's included:
- 📡 Live Dev Port Radar: Shows every listening TCP port right in your menu bar with a live counter badge of active dev servers.
- ⚡ 1-Click Kill (SIGTERM / SIGKILL -9): Free any stuck EADDRINUSE port in a single click.
- 🧠 Smart Framework & Stack Detection: Automatically tags Next.js, Vite, Angular, Node.js, Bun, .NET / Kestrel, FastAPI / Python, Go, Rust, Docker / OrbStack, PostgreSQL, Redis, MySQL, MongoDB, and Ollama — along with live RAM (MB), CPU %, and PID badges.
- 📌 Pinned Watchlist Bar: Pin your core ports (:3000, :5173, :8080, :5000, :5432, :6379) to the top watchlist bar with live green/grey status indicators and 1-click Open in Browser.
- ⌨️ Global Shortcut: Toggle anywhere with ⌃⌘P.
Install via Homebrew:
bash
brew tap joeystdio/tap
brew install --cask portradar
Hope it saves you some time — happy to hear any feedback or feature ideas!
r/swift • u/Classic-Ad5752 • 3d ago
A few days ago, I found a KWorld VS-ATSC 330U USB TV tuner I’d had since 2008. Out of curiosity, I plugged it into my Mac… and nothing happened.
After looking into it, I discovered it had never supported Macs in the first place. As far as my current setup was concerned, it was a dead device.
So I decided to try something a lot of people have been experimenting with lately: I asked Codex for help.
We started with the driver. After researching the hardware, working with the firmware, and testing with a real antenna, we managed to receive live TV on the Mac. Seeing the first picture come through hardware that had spent years sitting in storage was pretty exciting.
Once that worked, I wanted to take it further. I designed a Netflix-inspired interface and, with Codex’s help, gradually turned the experiment into an application called Antena.

It now lets me:
What started as “I wonder if this thing still works” became a working application on macOS 27 with Apple Silicon, receiving actual over-the-air channels here in Montréal.
It’s still an experimental project for this particular tuner, and reception depends on the antenna and local signal. But a device I thought was obsolete is useful again.
I brought the idea, UI design, and hands-on hardware testing; Codex helped me research and implement the driver and application. There was plenty of troubleshooting along the way, and I learned a lot.
Has anyone else brought old hardware back to life this way? I’d love to hear what you rescued.
r/swift • u/ahstanin • 2d ago
Hi r/swift,
I wanted to share some architecture notes and open-source libraries from StealthOS, a private desktop operating environment on iOS that we recently updated to support the new foldable iPhone Duo.
Standard UIKit and SwiftUI navigation hierarchies assume single-pane viewports. For the foldable iPhone Duo, we designed a custom window manager in Swift that dynamically tracks display changes between the single cover screen and the inner dual-display layout.
Where data moves across the network, we open-sourced our Swift packages:
Feedback on our Swift P2P networking protocols or foldable window manager implementation is welcome.

r/swift • u/yezicheng2011 • 3d ago
MockMini is a small, auditable proxy core in C and Swift. It speaks Shadowsocks AEAD, VMess, Trojan and VLESS over TCP, TLS or WebSocket, on top of its own bounded userspace TCP/IP endpoint that you feed from utun on macOS 13+.
Known limits (1024 flows, no SACK/ICMP, no Reality or gRPC) are listed honestly in the README. v0.1.0 is the first tagged release. Reviews and bug reports are very welcome.
r/swift • u/Dull-Connection5879 • 3d ago
Hey everyone!
A little while ago, I shared Graffle, an open-source diagramming and vector graphics app I built for macOS using Swift, AppKit and Claude Code.
Now I've been working on its companion app: Graffle for iPad.
The idea was to bring the project to iPad while preserving what makes it useful on the Mac. The iPad version uses SwiftUI and UIKit, with shared code from the original macOS project.
Some of the things it supports:
.graf document format used by the Mac versionBoth projects are open source under the MIT License.
Graffle for iPad:
https://github.com/yahirvitelugardo/Graffle-iPad
Original Graffle for macOS:
https://github.com/yahirvitelugardo/Graffle
This has been a fun opportunity to explore how much of a native macOS app can be reused while adapting the experience to a very different device and interaction model.
I'd love to hear feedback from Swift and Apple-platform developers.
If you were building a diagramming app for iPad, what would you prioritize? And what would you expect to work differently with Apple Pencil compared with a mouse and keyboard?
Thanks for checking it out!
r/swift • u/pickandplate • 3d ago
Passing two collections to @Test generates every combination. For example, @Test(arguments: ["cat", "swift"], [3, 5]) creates four cases, including ("cat", 5) and ("swift", 3).
That is useful for testing every configuration. For input/expected-output cases, keep each pair together:
```swift import Testing
@Test(arguments: [ ("", 0), ("cat", 3), ("swift", 5) ]) func characterCounts(input: String, expected: Int) { #expect(input.count == expected) } ```
This creates three cases. Swift Testing unpacks each tuple into the function’s two parameters.
@Test(arguments: zip(inputs, expected)) also pairs values, but zip stops at the shorter sequence). An accidentally missing expected value can therefore omit a case. A single array of pairs keeps the values together when adding or removing cases.
Apple’s parameterized testing guide explains combinations and paired arguments.
r/swift • u/IllBreadfruit3087 • 3d ago
r/swift • u/Smart_Appointment927 • 6d ago
I’d like to share Noctule, a plugin I made for cross-platform Swift development in JetBrains IDEs and Android Studio.
It’s a freemium plugin: most editor features and the Swift Package Manager integration are free, while Xcode integration and a few other features are paid.
Version 4.0 finally adds a debugger, which completes the edit-test-debug cycle.
I hope my contributions to the swift-book repository over the past three years count as enough community participation that this first post about Noctule doesn’t get me banned 😉 Thanks!
https://github.com/swiftlang/swift-book/issues?q=is%3Aissue++author%3A%40jansorg
szt (short for sizetree) scans a folder and prints a tree of where the space went: biggest first, every folder with the total of everything inside it, opened up only where the space is.
Swift turned out to be a great fit for it. Scanning a 123 GB folder of 667,000 files on a Mac Studio (M2 Ultra), every tool with its default settings (warm cache, median of five runs):
szt Swift 2.4 s
dua Rust 2.6 s
dust Rust 8.1 s
diskus Rust 11.4 s
gdu Go 11.6 s
du C 17.2 s
ncdu Zig 17.5 s
What made Swift work so well here:
import Darwin, no bindings or wrapper library, and the unsafe pointer APIs read the raw buffer it fills. The rest of the code is ordinary Swift.The biggest surprise was threads. On this 24-core machine, 24 threads took four times as long as 8, because opening folders goes through locks the whole kernel shares. So szt starts one thread per performance core, up to 8. They're plain threads rather than async/await, since the work is blocking system calls and the count has to be exact.
About 1,600 lines of Swift, a 581 KB universal binary (the Swift runtime ships with macOS), macOS 15 or later, MIT licensed.
brew install urtti/szt/szt
Source: https://github.com/urtti/szt Benchmarks and a script to run them on your own Mac: https://urtti.com/szt
to keep it clear, I’m a 17 year old high school student, and my dream job would be to be a programmer. as of now I can write basic code in both C++ and HTML, and I was interested in learning swift just for the sake of it and was wondering if it could actually be useful in an hypothetical future where my dream would come true. thanks in advance to anyone replying to this post
r/swift • u/Familiar-Ad9128 • 6d ago
A few weeks ago I shared TactileBar here, and way more people saw it than I expected. Thank you to everyone who commented, gave it a star, or opened an issue. Some of that feedback went straight into the last few releases, so here's what's new.
Quick recap: TactileBar is a free, open-source (GPLv3) menu bar app that puts 26 daily macOS toggles and live system telemetry in one panel. It covers Keep Awake, Dark Mode, Hide Desktop Icons, Mute Mic, Bluetooth audio switching, ejecting disks, purging Xcode DerivedData and more. The design borrows from Dieter Rams / Braun and Teenage Engineering. It's pure Swift with zero dependencies and uses 0% CPU when closed.
What's new
🎯 Tactile Ring (⌃⌥Space), experimental. A radial launcher that opens right at your cursor, so you don't have to go up to the menu bar.
- Hold the shortcut, flick toward a switch, release. Done.
- Tap it instead and the ring stays open, so you can use 1–8, the arrow keys or the mouse.
- Your pinned switches always stay in the same spots, so muscle memory kicks in fast.
- On the Bluetooth slice, push past the edge to fan out your paired devices and pick one (AirPods → speakers → DualSense in one gesture).
- Destructive actions like the cache purges need a short hold, so you can't fire them by accident.
- It needs no Accessibility or Input Monitoring permission.
📌 Pinned Daily Deck (⌘P). The app now opens on just the 4–6 switches you actually use. Pin or unpin any card with one click or a right-click. The full catalog is still there in the tabs.
🍺 Homebrew install. No Gatekeeper popups:
brew tap tr0drigues/tactilebar https://github.com/tr0drigues/TactileBar.git && brew install --cask tactilebar
GitHub: https://github.com/tr0drigues/TactileBar
This is a solo side project, so feedback really helps. Which switch do you wish existed? Does the ring feel natural or awkward? Bug reports are welcome too.
r/swift • u/Comfortable_Cat_6207 • 6d ago
I'm exploring menu-bar interaction design for my macOS project, SummonOS.
The requirements I'm interested in are keyboard access, focus while another app is active, window ordering and content that changes while the panel is open.
I'm considering SwiftUI's MenuBarExtra and an NSStatusItem/NSPanel approach. I'm not assuming one framework is broken or that the lower-level option automatically solves everything.
For those who've built similar tools, which specific behavior made you choose one approach over the other? Concrete examples and the macOS versions involved would be especially useful.
These are my project research notes:
Would love your (respectful) feedback on my app. I’m not here to promote.
How do you like the editing experience? Does it provide the features you need? Is everything intuitively clear?
https://www.flowstate-interactive.com/kabaal/
Thank you. 🙏
ran into this while working on a small mac utility, figured someone else might hit it too
i wanted to know when the user has something full screen (youtube in chrome, a movie, a game etc) so the app gets out of the way. the usual trick is CGWindowListCopyWindowInfo and checking if a window matches the screen frame. works fine on external monitors, but on a notched macbook full screen windows start below the notch and the strip above it is just painted black. so the window is like 32-38pt shorter than the screen, which is pretty much where a normal zoomed window starts too. can't just loosen the check
what ended up working is asking the window server which space each display is on. full screen apps get their own space and its type is 4
```swift
typealias MainConnection = u/convention(c) () -> Int32
typealias CopyDisplaySpaces = u/convention(c) (Int32) -> Unmanaged<CFArray>?
let cg = dlopen("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics", RTLD_NOW)
let mainConnection = unsafeBitCast(dlsym(cg, "CGSMainConnectionID"), to: MainConnection.self)
let copySpaces = unsafeBitCast(dlsym(cg, "CGSCopyManagedDisplaySpaces"), to: CopyDisplaySpaces.self)
func fullScreenDisplays() -> Set<String> {
let displays = copySpaces(mainConnection())?.takeRetainedValue() as? [[String: Any]] ?? []
var result = Set<String>()
for display in displays {
let current = display["Current Space"] as? [String: Any]
if (current?["type"] as? Int) == 4, let id = display["Display Identifier"] as? String {
result.insert(id)
}
}
return result
}
```
the ids are display uuids (or "Main" if you turned off separate spaces per display), you can map them with CGDisplayCreateUUIDFromDisplayID
it's private api so no app store, but it needs zero permissions. AXFullScreen works too but then you need accessibility. i just run it on activeSpaceDidChangeNotification and once more ~0.4s later since the space animates in
anyone know a public way to do this? would rather not rely on CGS stuff
r/swift • u/felltrifortence • 6d ago
At any given moment I have 4 or 5 projects going, and each one has its own little cluster of terminals: a dev server, a log tail, an SSH session to some box, a shell for git.
In iTerm2 that meant a pile of windows I kept losing track of. ⌘` cycling through ten windows that all look the same. Tabs named "zsh", "zsh", "zsh (2)". Splits I'd set up carefully, gone after a restart. Arrangements I could save but never remembered to. I'd spend the first few minutes of every morning rebuilding my layout, and then lose it again by the afternoon.
One day I closed the wrong window and killed a long-running job, and that was it. I wanted a terminal where windows themselves were something you could manage: a list you can see, name and jump between, instead of a stack you dig through.
So I built Trellis.
The idea
- A left sidebar lists your windows like a project list. Every window has its own renameable, color-labeled tabs, and every tab can hold nested splits
- The whole layout comes back after a restart. Sessions restore as stopped so nothing reruns by surprise, or you can opt in to keep them running in the background and reconnect on the next launch
- Shell integration (zsh, bash, fish, with no dotfile edits) means a new split opens in the directory you're already in, so you stop typing cd all day
- Closing a pane with something running asks first. I'd been burned before
- Tabs show when something is busy, waiting for a password, or finished a long command while you weren't looking
- Saved SSH hosts, a trellis CLI and a local API, so a script (or an agent like Claude Code via the optional MCP server) can set up a whole layout for you
The Swift side
It started as a weekend "how hard can it be" and turned into a proper project:
- Swift 6.2 with strict concurrency, SwiftUI + AppKit, SwiftPM only (swift build works offline)
- The workspace model is an actor. Every change, whether from the UI, the CLI or the API, goes through one command service, which is what keeps windows → tabs → split trees consistent
- PTY I/O runs off the main thread, a small C target handles process-group spawning, and the terminal engine is a vendored SwiftTerm with patches, plus an opt-in Metal renderer
The hardest part was making UI fits my workflow 😨
Open Source, MIT licensed, macOS 14+
- Download: https://bearstouch.com/trellis
- Source: https://github.com/bearstouch/trellis
If you've ever had iTerm2 window sprawl, I'd love to hear whether this fixes it for you, or what's still missing . Contributions are more than welcome 👐
r/swift • u/fatbobman3000 • 7d ago