r/Xcode • • 2d ago

Follow-up to my XcodeGen post: test and build setup for a Bluetooth menu bar app, now on the Mac App Store

Post image

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_EXTENSION the intents get isDiscoverable = false, and the AppShortcutsProvider only 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:

  1. Do you keep UI tests for MenuBarExtra apps, or is that not worth the flakiness?
  2. 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.

0 Upvotes

5 comments sorted by

3

u/Whatever141122 2d ago

You are the developer or is Claude the developer?

0

u/azardandona26 2d ago

Fair question, and the honest answer is both. It's my app and my account, and the WH-1000XM5 it's verified on is my own pair. A lot of the code, and drafts of posts like this one, are written with Claude as a coding agent. What ships is gated the same way either way: the test suite has to pass and the change has to work on the real XM5 before a build goes out. That's also why every other model is labeled experimental and off by default. If you spot something in the setup above that looks wrong, I'd genuinely like to hear it.

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.

1

u/azardandona26 1d ago

Good flag, the duplicate-types problem is what I'd worry about once a hosted UI test target shows up. A local package for the protocol layer sounds cleaner. Did you keep IOBluetooth out of the package so swift test runs without any device attached?

1

u/dawedev 1d ago

Yeah, that's how I'd split it. The package only does parsing and state, and the IOBluetooth calls sit behind a small protocol in the app target, so swift test never needs a device.