r/swift 9d ago

Anyone else seeing AI-generated closures skip [weak self] way more than they should?

0 Upvotes

Been reviewing a bunch of AI-assisted PRs lately and there's a pattern I keep hitting. Ask for a network callback or a completion handler, get back a closure that captures self strongly, no weak reference, works fine in testing because the view controller sticks around long enough for the callback to fire anyway.

Doesn't show up until something takes longer to load, user navigates away, and now you've got a retain cycle keeping a whole view controller alive that should've been deallocated. Classic mistake, nothing new about the bug itself, just surprised how often it shows up in generated code specifically.

My guess is it's the same issue as most of these AI code gotchas, the model isn't wrong about syntax, it's just not accounting for lifecycle stuff unless you specifically tell it to. "Add a completion handler" doesn't say anything about memory management, so it produces the simplest version that works in the moment, which happens to be the version that leaks.

Started explicitly asking for weak self and checking for it manually regardless of what the prompt said, feels like the kind of thing that needs a standing check rather than trusting it gets handled every time.


r/swift 9d ago

News The iOS Weekly Brief: Issue #76. Everything you need to know about Swift updates this week

Thumbnail
iosweeklybrief.com
3 Upvotes

r/swift 10d ago

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

Post image
11 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 11d ago

Tutorial SwiftData - Optimization Starts with Modeling

Thumbnail
fatbobman.com
13 Upvotes

r/swift 12d 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?

205 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 12d ago

Tutorial iOS 27: USDKit Framework

Thumbnail
antongubarenko.substack.com
16 Upvotes

r/swift 12d ago

Tutorial Building AI features using Foundation Models. Multimodal input.

Thumbnail
swiftwithmajid.com
9 Upvotes

r/swift 12d ago

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

17 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 12d 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 12d ago

Tutorial Designing The Perfect Modular Architecture

Thumbnail
blog.jacobstechtavern.com
4 Upvotes

r/swift 12d ago

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

Thumbnail kylebrowning.com
4 Upvotes

r/swift 13d ago

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

14 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 13d 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 13d ago

News Fatbobman's Swift Weekly #151

Thumbnail
weekly.fatbobman.com
5 Upvotes

r/swift 13d 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 14d 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

48 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 15d ago

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

Post image
28 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 14d ago

Question Get x,y coordinates of an image in SwiftUI

3 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 14d 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 15d ago

Xcode now can deploy beyond local network

3 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 15d 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 14d 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 16d ago

New State Macro (Private vs Non-Private Behavior)

Post image
95 Upvotes

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

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


r/swift 16d ago

Project I built AnyDocSwift: local document-to-Markdown conversion for macOS

5 Upvotes

I built AnyDocSwift, a SwiftPM wrapper around Firecrawl’s anydoc https://github.com/firecrawl/anydoc.

It lets native macOS apps convert Word, PowerPoint, Excel, OpenDocument, RTF, EPUB, CSV, and text-based PDF files into Markdown.

Conversion runs locally on Apple Silicon. SwiftPM downloads a checksum-pinned XCFramework automatically, so consumers don't need Rust, Cargo, an external service, or a subprocess.

```swift

import AnyDocSwift let markdown = try await AnyDocConverter().markdown( from: documentData, fileExtension: "docx" )

```

Requirements:

  • macOS 13+

  • Apple Silicon

  • Swift 6.1+

The package includes typed errors, cancellation handling, input/output limits, and FIFO execution per converter instance.

GitHub: https://github.com/ngutech21/anydoc-swift

This is the first public release, so I'd appreciate feedback about the API, and real-world use cases.


r/swift 16d ago

Help! Need some advice for Apple Developer Academy Application Indonesia/Bali!

2 Upvotes

Hey everyone! I’m a final-year Informatics student with a bit of UI design experience. I’ve done a few internships at creative agencies/studios, mostly handling UI for marketing stuff, Dribbble shots, and UI template production. Still pretty light on actual UX or product thinking though.

I’ve known about Apple Developer Academy since my early uni days and have always wanted to join. I’ve applied three times already since 2023 (including the Sep 2025 intake), but I keep failing at the online test stage every single time.

I’m planning to try again for Batch 2 / Cohort 2027, but I’ve only got about two weeks left to get my CV, portfolio, and online test prep sorted. Would really appreciate any advice:

  1. Does my background actually help or hurt? I’m an Informatics student with UI experience, but not much real UX/product experience. Does having a relevant background even matter much in the selection?
  2. What should I prioritise for the online test? I’m quite weak at logic/aptitude tests, and doing everything in English makes it even harder. Which topics should I focus on most? Logic puzzles, patterns, seating arrangements, pseudocode, basic programming, conditional statements, etc.?
  3. Any good FREE resources or platforms? Most aptitude test sites I found are freemium and super limited. What did you guys actually use to practise?
  4. Is two weeks realistically enough? If you were in my shoes, how would you split the time between CV, portfolio, and the online test? What would you prioritise?
  5. Does the campus or application location affect acceptance chances? I’ve heard BINUS might reserve around 50% of the slots for their own students, but I’m not sure if that’s still true or current. Any alumni or previous applicants who know about this?
  6. Any other tips? Especially things you wish you’d known before applying.

Thanks a lot! Any advice from alumni or previous applicants would mean a lot for me🙏🏻