AVAudioPlayer is very laggy, am I using it wrong or should I look for another solution?
The sound is firing off every 100ms and it is causing lag in animations. Am I doing something wrong or should I look for a different way to play this audio?
The sound is firing off every 100ms and it is causing lag in animations. Am I doing something wrong or should I look for a different way to play this audio?
I've been developing Numerical Solver, a native scientific computing application for macOS and iOS, using Swift and SwiftUI.
One of the most interesting challenges has been implementing a numerical solver for nonlinear boundary value problems.
The numerical engine combines:
One important architectural improvement was moving from dense Jacobian matrices using dgesv_ to banded matrices using dgbsv_.
By reorganizing the unknowns and exploiting the structure of the discretized differential equations, I was able to avoid storing and solving unnecessarily large dense matrices — especially as adaptive mesh refinement increases the number of grid points around steep boundary layers.
Swift is often associated with application development, but I've found it very capable for implementing numerical algorithms as well.
I'm currently porting the updated numerical engine to the Windows version of the application, which brings its own interesting challenges, particularly replacing Accelerate.
The latest macOS version is now available.
Website: https://numericalsolver.com
I'm curious whether other developers here are using Swift for scientific computing or numerical analysis:
I want to prevent the double tap quirk that takes you to the top of a view.
r/swift • u/yoshiboarder • 1d ago
I made an app for the iOS engineers. You can find a job listing, track your progress, learn data structures and algorithms, and find mock interview peers.
I'm new to Swift so sorry for the basic question. .onChange fires off when I change the tab, presumably updating active, but it doesn't update active in the FeedView.

Something weird is happening when I call onAppear. It is basically taking the first value it gets for active and never updating it. When .onDisappear is called it rightfully says that active is false. I also set up a ternary to change some text and it responds when active is false. Not sure what is happening.

This flashes false when I click to another tab but the loop in onAppear still prints true
r/swift • u/V0RT3X_L33T_ • 1d ago
Our codebase has hundreds of `@Environment` call sites. Any one of them can crash in production with "No Observable object of type X found" if a view gets shown without the value injected somewhere above it, and the compiler can't see it. Every fix I found started with "first, change all your call sites."
So I built Snagless, a SwiftPM/Xcode build plugin. It reads your SwiftUI source with SwiftSyntax, works out which view shows which across modules, and fails the build when a view can appear without a value it needs. Zero code changes, about 90 ms on a 431-file app.
Built with Claude Code, and the write-up is upfront about every time the AI was wrong and what caught it.
Write-up: https://tarek-builds.dev/p/swiftui-environment-crashes-compile-just-fine-so-i-made-them-fail-the-build/
Repo: https://github.com/tareksabry1337/snagless
Happy to answer questions.
r/swift • u/Super-Storage6685 • 1d ago
I build for SwiftUI, AppKit and UIKit on Mac, iPhone and iPad, and my layout used to start with a workspace. A project template can create and open a project, but it can't leave you in an open workspace.
What I moved to: one Xcode project at the root, a thin target per platform and UI framework, and one local package with each feature as a target.
It has costs: every target resolves all of the package's dependencies, target names must be unique, and splitting features into targets changes what has to be "package" instead of "internal".
r/swift • u/soumyaranjanmahunt • 1d ago
I wanted a live view of a running iOS app in the browser for a design/QA tool, with its element tree, and click-to-highlight working in both directions. ReplayKit was the obvious choice, but it means a consent dialog every session, a broadcast extension, and capturing the whole system when I only wanted my own app.
It turns out you can skip it entirely, with no consent dialog and no extension, and secure content still stays hidden.
I wrote up how it works and the trade-offs. Has anyone tried something similar?
I was using AudioServicesPlaySystemSound but the documentation says
"Sounds play at the current system audio volume, with no programmatic volume control available"
r/swift • u/sergio_dev • 1d ago
The pro subscription in MobileCodeAI is available for $1 today bc of Cyber Monday.
I've been using this app to build and iterate on iOS apps directly from my phone, which has been a new but great experience.
Over the past 12 days I built Ribbonpage, an offline Safari-to-Markdown article reader for iPhone and Mac. I just finished splitting the internal engines into three public SwiftPM repositories and wrote up the devlog.
Full write-up: https://oozoofrog.dev/blog/ribbonpage-12-day-devlog-en/
The three packages:
All standalone package tests pass locally, though I have not yet verified runtime execution on physical iOS 16 / macOS 13 devices.
r/swift • u/ThanhDongNguyen • 2d ago
Three things I keep doing in Swift, mostly in Mac apps. The last one is AppKit, because I have not found a SwiftUI modifier that does the same.
If a Task does work in the background and then updates the UI, I wrap that update in MainActor:
Task {
let data = await loadData()
await MainActor.run {
self.statusText = data.title
}
}Or I mark the type that owns the UI as @MainActor. I think this is the usual reason a label or a SwiftUI view updates late, or a warning shows up under Swift 6.
2. Use Logger instead of print
import os
let log = Logger(
subsystem: Bundle.main.bundleIdentifier ?? "MyApp",
category: "sync"
)
log.info("Refresh started")In Console.app you can filter by subsystem or category. print just disappears into the system log. I would use a short static message, or be careful with interpolated values, because Logger can redact them.
3. For a floating utility, use NSPanel, not a normal window
.windowLevel(.floating) can put the window on top, but a click on it still activates your app and the other app loses the keyboard. This is the pattern that does not steal focus:
final class UtilityPanel: NSPanel {
override var canBecomeMain: Bool { false }
init() {
super.init(
contentRect: .zero,
styleMask: [.titled, .closable, .nonactivatingPanel],
backing: .buffered,
defer: false
)
isFloatingPanel = true
becomesKeyOnlyIfNeeded = true
level = .floating
collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
}
}.nonactivatingPanel only works on NSPanel. I still put SwiftUI inside the panel for the content.
If you have a pure SwiftUI way to get the same nonactivating behaviour, I would like to know.
r/swift • u/fatbobman3000 • 2d ago
r/swift • • 3d ago
Hey r/swift! Estou lançando a beta pública v1.0.0-beta do InelCode, um IDE nativo para macOS (Apple Silicon) desenvolvido do zero combinando Swift / AppKit na interface, C++23 (libInelCodeCore) no motor de processamento e uma VM Lua 5.4 embarcada para automação.
libInelCodeCore): Gerenciamento de buffers, indexação e busca vetorial local via USearch, integrado a Swift.99.1 ms, RAM em torno de ~196.9 MB e instalador .dmg de 5.1 MB.git log), ocorrências no workspace e exemplos de uso via IA.Instale via Homebrew Cask:
Ou baixe o .dmg diretamente em ://github.com (veja os detalhes completos da release e instruções de assinatura no repositório).
Feedback sobre a responsividade da UI, interoperabilidade Swift/C++ e estabilidade é muito bem-vindo!
r/swift • u/romit5587 • 4d ago
After nine years of iOS work, the concurrency migration is the one where order matters most. Turning on Swift 6 mode in one go usually produces hundreds of errors and no idea where to start. This is the sequence that keeps it manageable:
What has been the hardest part of the migration for you?
r/swift • u/Oxnull-shubh • 4d ago
Hey everyone,
Like many of you, I've tried using AI coding assistants on iOS projects, but was constantly frustrated by:
Group { ... } wrappers or .foregroundStyle(.primary)).I built PR Forge (pr-forge-ai), an open-source agent that runs in GitHub Actions or your local terminal.
When you comment /forge on an issue: • It detects the project type (SwiftPM or Xcode .xcodeproj). • Applies progressive skills: u/State macro rules, .glassEffect(), WebView/WebPage in SwiftUI, InlineArray, and functional Swift idioms. • Runs swift test or xcodebuild. • Self-audits every checkbox in your issue PRD. • Pushes a commit under PR Forge Bot and opens a PR.
We tested it end-to-end on a live macOS Swift project (Spreading Aroma), where it autonomously built a node statistics counter, code optimizer, and unit test suites that passed CI and merged cleanly.
Repo: https://github.com/shubhransh-gupta/pr-forge
What are the most annoying Swift/Xcode boilerplate patterns you'd want an autonomous agent to automate?
r/swift • u/DirectConversation59 • 4d ago
Hey everyone!
I’m considering applying to the Apple Developer Academy in Bali for the next batch, and I’d love to hear some honest opinions from current learners or alumni.
I’m an international applicant and would mostly be financially supporting myself, so I’m trying to figure out whether it’s actually worth spending 10 months there.
I have a few questions:
Is the Academy actually worth it, or is it somewhat overhyped?
How much is the monthly stipend, and is it enough to live comfortably in Bali?
How much do you realistically spend per month on rent, food, transportation, electricity, and other necessities?
How much should I have saved before moving to Bali?
Is it possible to work part-time while attending the Academy, such as freelancing, remote work, or working at a café? Especially as a foreigner on a student visa.
How intense is the daily schedule? Do you have enough free time for personal projects or other commitments?
How good are the mentors and the actual learning experience?
Do you receive any Apple devices to use throughout the program?
Does the Academy actually help with career opportunities, internships, networking, or finding a job after graduation?
How is the experience for international learners? Is the language barrier an issue?
Are there any hidden expenses or things you wish you had known before joining?
Most importantly, if you could go back in time, would you still choose to join the Academy?
I’d really appreciate honest experiences, both positive and negative. I’m not expecting everything to be perfect, but since I’d be moving to another country and supporting myself financially, I want to know what I’m getting into.
Thanks in advance!
r/swift • u/IllBreadfruit3087 • 5d ago
r/swift • u/jacobs-tech-tavern • 5d ago
r/swift • u/thelectroom • 5d ago
All the videos I've seen on Youtube involve someone just randomly typing a million properties without any explanation of how they even know that an element supports these properties (e.g., how does Text() have .foregroundStyle and why does this have .white to define colour?)
Option + Click does not reveal this and I'm struggling to find anything that tells me what the properties are.
r/swift • u/Electrical_Cup3869 • 6d ago
I decided to build a swift package for using Private cloud compute and Apple's local models, I found it difficult to find the correct places to use them, and there was nothing out there to do it for me automatically, so I built my own!
Its still pretty early, it works on calibration of latency, and adjusts the model used based on request latency, it continuously re-calibrates the more its used based on the users device
r/swift • u/mohalibou • 6d ago
Hello all,
I recently put out a new package I've been working on to help myself learn about designing libraries. It's called JobsKit. I've been exploring the web service behind jobs.apple.com and decided to turn it into a type-safe Swift API, and figured it'd be nice if other people got a chance to try it out.
The idea behind it was to make it possible to search Apple's job listings using a Swift-based API, instead of manually dealing with the website's requests.
Here's a simple code example so you can see how it works:
import JobsKit
let client = JobsClient()
for try await job in client.allJobs(
matching: JobQuery(text: "swift")
) {
print(job.title)
}You can also filter by teams, products and locations, retrieving detailed job information, and parsing compensation info where available.
It's available for all Apple platforms as well as Linux.
GitHub: https://github.com/mohalibou/JobsKit
This is my first package I've put out there, so if you have any feedback on the implementation, do feel free to let me know about it.
r/swift • u/SpectralDragon_ • 7d ago
I've been building Ada Engine for the last 4 years, and my main problem has been finding a cross-platform SDK for graphics. I saw that Bevy and other Rust projects use WGPU, and I dreamed of rewriting it in Swift.
With AI, that day has come. In just 3 days, AI agents rewrote the entire Naga compiler and WGPU, which lets us compile WGSL (WebGPU Shading Language) to MSL (Metal Shading Language), GLSL, SPIR-V and HLSL. It all runs on-device, without vendor-specific libraries like SPIRV-Cross.
SAGA, the name of the new graphics SDK, builds and runs on Android, Windows, Web, Linux and Apple platforms. All in Swift! Ada Engine already supports it!
I'm really glad that you can now use a cross-platform graphics API in Swift instead of Vulkan or Dawn.
Check it out: https://github.com/AdaEngine/SAGA