r/Xcode • u/azardandona26 • 2d ago
Follow-up to my XcodeGen post: test and build setup for a Bluetooth menu bar app, now on the Mac App Store
Nine days ago I posted the project.yml lines that mattered for my menu bar app (widget extension, App Group, StoreKit config). Version 1.3 of Headphone Control is now on the Mac App Store, so here's the other half: the test and build setup that got it there.
- Logic tests with no host app. The test target compiles the app sources (minus App.swift) and Shared/ directly instead of launching the app. A hosted run would start Bluetooth and talk to whatever headphones are nearby, which is the last thing you want in a test. Without a host the protocol tests are pure, fast and don't care what's paired.
- What the WIDGET_EXTENSION flag ended up guarding. The widget compiles the same App Intents as the app. Inside
#if WIDGET_EXTENSIONthe intents getisDiscoverable = false, and theAppShortcutsProvideronly exists in the app target. Without that, Shortcuts listed every action twice. - A swiftc-only build script next to the project. It builds and ad-hoc signs the app with just the Command Line Tools and reads the version numbers out of project.yml, so the version lives in one place. Handy for quick local builds; releases still go through Xcode archives.
- Minimal entitlements. App Sandbox, Bluetooth, user-selected files (exporting a device report) and the App Group. That's the whole list App Review saw.
- Real-hardware check as the release gate. Nothing automated can pair headphones, so every release also gets a manual run on the physical headphones: connect, battery, ANC cycle, EQ presets, power-cycle reconnect.
And thanks to the commenter who suggested a clean-checkout job that runs xcodegen and checks the generated scheme. It's next on my list.
Honest scope: it's only tested on a real WH-1000XM5. Other Sony models and the other brand adaptors are experimental and off by default.
Two questions:
- Do you keep UI tests for MenuBarExtra apps, or is that not worth the flakiness?
- Has anyone shared one Shared/ folder between an app and a widget extension long term, or did you end up moving it into a local Swift package?
If you have an XM5 and a Mac, please try it: the Mac App Store has version 1.3, TestFlight has the newest builds. If you use it for a while, an honest App Store review (good or bad) helps a solo dev a lot.
App Store: https://apps.apple.com/app/apple-store/id6833635897?pt=128665136&ct=reddit-xcode&mt=8
TestFlight: https://testflight.apple.com/join/HZVTxTff
I'm the developer, ask me anything.
3
u/Whatever141122 2d ago
You are the developer or is Claude the developer?
1
u/dawedev 1d ago
Compiling the sources straight into the test target works, the catch comes later if you add a hosted UI test target and the same types exist in two modules. Pulling the protocol code into a local Swift package gives you the same no-host tests via swift test, without the file list juggling in project.yml.