iOS spike build 2: app icon, scene manifest, crash-proof self-test on demand

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-14 20:28:29 +01:00
co-authored by Claude Opus 5.5
parent 77d6e459b2
commit c9ad186de1
11 changed files with 130 additions and 25 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ PROJECT := $(SPIKE)/SizzleSpike.xcodeproj
SCHEME := SizzleSpike SCHEME := SizzleSpike
APP_ID := cc.tiredsysadmin.ios.sizzlespike APP_ID := cc.tiredsysadmin.ios.sizzlespike
BUILD_NO := $(shell sed -n 's/^ *CURRENT_PROJECT_VERSION: *"\(.*\)"/\1/p' $(SPIKE)/project.yml) BUILD_NO := $(shell sed -n 's/^ *CURRENT_PROJECT_VERSION: *"\(.*\)"/\1/p' $(SPIKE)/project.yml)
SOURCES := $(SPIKE)/project.yml $(wildcard $(SPIKE)/*/*.swift $(SPIKE)/*/*.plist $(SPIKE)/*/*.entitlements) SOURCES := $(shell find $(SPIKE) -type f -not -path '*.xcodeproj/*')
SIM_APP := build/sim/Build/Products/Debug-iphonesimulator/$(SCHEME).app SIM_APP := build/sim/Build/Products/Debug-iphonesimulator/$(SCHEME).app
DEV_APP := build/dev/Build/Products/Release-iphoneos/$(SCHEME).app DEV_APP := build/dev/Build/Products/Release-iphoneos/$(SCHEME).app
+21 -5
View File
@@ -12,7 +12,7 @@ App Groups work there?
| Piece | What it is | | Piece | What it is |
|---|---| |---|---|
| `spike/project.yml` | XcodeGen spec; `make project` generates the Xcode project (git-ignored) | | `spike/project.yml` | XcodeGen spec; `make project` generates the Xcode project (git-ignored) |
| `spike/App/` | SwiftUI host app `cc.tiredsysadmin.ios.sizzlespike`; runs a self-test at launch | | `spike/App/` | SwiftUI host app `cc.tiredsysadmin.ios.sizzlespike` with a self-test (Run self-test button) |
| `spike/AU/` | App extension `…sizzlespike.au`: one AUv3 instrument (`aumu` / `sSpk` / `Tsys`), "Tired Sysadmin: Sizzle Spike Sine", a sine voice with a Gain parameter | | `spike/AU/` | App extension `…sizzlespike.au`: one AUv3 instrument (`aumu` / `sSpk` / `Tsys`), "Tired Sysadmin: Sizzle Spike Sine", a sine voice with a Gain parameter |
| `spike/Shared/Spike.swift` | The App Group id, the component description, and the App Group probe both sides run | | `spike/Shared/Spike.swift` | The App Group id, the component description, and the App Group probe both sides run |
@@ -32,7 +32,7 @@ The self-test shows three checks:
### Build ### Build
```sh ```sh
make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzlespike_1.ipa make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzlespike_<build>.ipa
``` ```
Needs Xcode and XcodeGen. The device build is unsigned, then ad-hoc signed inside-out Needs Xcode and XcodeGen. The device build is unsigned, then ad-hoc signed inside-out
@@ -47,9 +47,9 @@ runtime was installed when the spike was written, so it hasn't been run there.
### Test on the iPad ### Test on the iPad
1. AirDrop or copy `cc.tiredsysadmin.ios.sizzlespike_1.ipa` to the iPad, open it with 1. AirDrop or copy the newest `cc.tiredsysadmin.ios.sizzlespike_<build>.ipa` to the
TrollStore, install. iPad, open it with TrollStore, install.
2. Open **Sizzle Spike** and note [1]–[3] (screenshot the screen). 2. Open **Sizzle Spike**, tap **Run self-test**, and note [1]–[3] (screenshot).
3. In AUM (or GarageBand → Audio Units, Loopy, Drambo…), add an instrument and look 3. In AUM (or GarageBand → Audio Units, Loopy, Drambo…), add an instrument and look
for **Tired Sysadmin: Sizzle Spike Sine**. Load it, play notes, open its view (it for **Tired Sysadmin: Sizzle Spike Sine**. Load it, play notes, open its view (it
lists the App Group files). lists the App Group files).
@@ -66,6 +66,22 @@ What the outcomes mean:
passing sample data through the plugin's saved state, or having the plugin passing sample data through the plugin's saved state, or having the plugin
pick files with a document picker. pick files with a document picker.
### Results so far
- **Build 1 (0.1.0):** AUM lists the plugin, loads it, and it plays from a MIDI
keyboard, so hosts do see AUv3 plugins from a TrollStore install. AUM showed a
red X as its icon (the app had no icon), and the app itself closed right after
opening (it ran the self-test at launch).
- **Build 2 (0.1.1):** adds an app icon, the SwiftUI scene manifest, and makes the
self-test crash-proof for diagnosis. It runs only on the button. Each step is
saved before it runs, so the next launch says where a crash happened
("The previous run stopped during: …"). AVAudioEngine's Objective-C exceptions
are caught by `App/ObjC/SPKTry.m` and printed instead of killing the app.
If the app still closes before showing anything, the crash is at launch. Its log
is in Settings → Privacy & Security → Analytics & Improvements → Analytics Data,
in a file named `SizzleSpike-<date>.ips`.
## Decisions ## Decisions
- **XcodeGen, not a checked-in .xcodeproj:** the project is text you can diff and - **XcodeGen, not a checked-in .xcodeproj:** the project is text you can diff and
@@ -0,0 +1,6 @@
{
"images" : [
{ "filename" : "icon-1024.png", "idiom" : "universal", "platform" : "ios", "size" : "1024x1024" }
],
"info" : { "author" : "xcode", "version" : 1 }
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

@@ -0,0 +1 @@
{ "info" : { "author" : "xcode", "version" : 1 } }
+1
View File
@@ -0,0 +1 @@
#import "ObjC/SPKTry.h"
-1
View File
@@ -25,6 +25,5 @@ struct ContentView: View {
} }
.padding() .padding()
.preferredColorScheme(.dark) .preferredColorScheme(.dark)
.task { await test.run() }
} }
} }
+13
View File
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Runs `block`, turning an Objective-C exception (AVAudioEngine raises them for
/// misuse, and Swift can't catch them, so they crash the app) into a returned
/// description. Returns nil when the block finished normally.
NSString *_Nullable SPKTry(NS_NOESCAPE void (^block)(void));
NS_ASSUME_NONNULL_END
+13
View File
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#import "SPKTry.h"
NSString *_Nullable SPKTry(NS_NOESCAPE void (^block)(void)) {
@try {
block();
return nil;
} @catch (NSException *e) {
return [NSString stringWithFormat:@"%@: %@", e.name, e.reason ?: @"(no reason)"];
}
}
+69 -15
View File
@@ -8,68 +8,116 @@ import os
/// 1. did iOS register the extension's Audio Unit (what hosts will list)? /// 1. did iOS register the extension's Audio Unit (what hosts will list)?
/// 2. does it load out of process and render sound? /// 2. does it load out of process and render sound?
/// 3. can the app and the extension share files through the App Group? /// 3. can the app and the extension share files through the App Group?
///
/// Runs only when asked (not at launch), records each step in UserDefaults before
/// doing it, and routes AVAudioEngine calls through SPKTry, so a crash or an
/// Objective-C exception leaves a readable trail instead of a vanishing app.
@MainActor @MainActor
final class SelfTest: ObservableObject { final class SelfTest: ObservableObject {
@Published var lines: [String] = [] @Published var lines: [String] = []
private let log = Logger(subsystem: "cc.tiredsysadmin.ios.sizzlespike", category: "selftest") private let log = Logger(subsystem: "cc.tiredsysadmin.ios.sizzlespike", category: "selftest")
private let defaults = UserDefaults.standard
private static let stepKey = "selftest.step"
private var liveEngine: AVAudioEngine? private var liveEngine: AVAudioEngine?
init() {
lines = ["iOS \(ProcessInfo.processInfo.operatingSystemVersionString)",
"App started OK."]
if let step = defaults.string(forKey: Self.stepKey) {
lines.append("!! The previous run stopped during: \(step)")
}
lines.append("Tap Run self-test.")
}
private func say(_ s: String) { private func say(_ s: String) {
lines.append(s) lines.append(s)
log.notice("\(s, privacy: .public)") log.notice("\(s, privacy: .public)")
} }
/// Remember what we're about to do; cleared when the run finishes.
private func step(_ s: String) {
defaults.set(s, forKey: Self.stepKey)
defaults.synchronize()
}
/// Runs an AVAudioEngine call, reporting an Objective-C exception as a failure.
private func objc(_ what: String, _ body: () -> Void) -> Bool {
step(what)
if let ex = SPKTry(body) { say(" \(what): EXCEPTION \(ex)"); return false }
return true
}
func run() async { func run() async {
lines = [] lines = ["iOS \(ProcessInfo.processInfo.operatingSystemVersionString)"]
let os = ProcessInfo.processInfo.operatingSystemVersionString
say("iOS \(os)")
// 1. Registration // 1. Registration
step("[1] component lookup")
let all = AVAudioUnitComponentManager.shared().components(matching: Spike.desc) let all = AVAudioUnitComponentManager.shared().components(matching: Spike.desc)
say("[1] Registered components matching Tsys/sSpk: \(all.count) \(all.isEmpty ? "FAIL" : "PASS")") say("[1] Registered components matching Tsys/sSpk: \(all.count) \(all.isEmpty ? "FAIL" : "PASS")")
for c in all { say(" \(c.name) v\(c.versionString), type \(c.typeName)") } for c in all { say(" \(c.name) v\(c.versionString), type \(c.typeName)") }
// 3a. App Group from the app side (before the AU writes) // 3a. App Group from the app side (before the AU writes)
step("[3] App Group probe")
say("[3] " + Spike.probeGroup(as: "app")) say("[3] " + Spike.probeGroup(as: "app"))
// 2. Load out of process, render 1 s offline (silent), measure the peak // 2. Load out of process, render 1 s offline (silent), measure the peak
do { do {
step("[2] instantiate out of process")
let unit = try await AVAudioUnit.instantiate(with: Spike.desc, options: .loadOutOfProcess) let unit = try await AVAudioUnit.instantiate(with: Spike.desc, options: .loadOutOfProcess)
say("[2] Instantiated \"\(unit.auAudioUnit.audioUnitName ?? "?")\" out of process: PASS") say("[2] Instantiated \"\(unit.auAudioUnit.audioUnitName ?? "?")\" out of process: PASS")
let engine = AVAudioEngine() let engine = AVAudioEngine()
let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 2)! let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 2)!
try engine.enableManualRenderingMode(.offline, format: format, maximumFrameCount: 4096) var thrown: Error?
engine.attach(unit) guard objc("[2] enable offline rendering", {
engine.connect(unit, to: engine.mainMixerNode, format: format) do { try engine.enableManualRenderingMode(.offline, format: format, maximumFrameCount: 4096) }
try engine.start() catch { thrown = error }
(unit as? AVAudioUnitMIDIInstrument)?.startNote(69, withVelocity: 100, onChannel: 0) }), thrown == nil else { throw thrown ?? SpikeError.exception }
guard objc("[2] connect", {
engine.attach(unit)
engine.connect(unit, to: engine.mainMixerNode, format: format)
}) else { throw SpikeError.exception }
guard objc("[2] start engine", { do { try engine.start() } catch { thrown = error } }), thrown == nil
else { throw thrown ?? SpikeError.exception }
guard objc("[2] note on", { (unit as? AVAudioUnitMIDIInstrument)?.startNote(69, withVelocity: 100, onChannel: 0) })
else { throw SpikeError.exception }
let buf = AVAudioPCMBuffer(pcmFormat: engine.manualRenderingFormat, frameCapacity: 4096)! let buf = AVAudioPCMBuffer(pcmFormat: engine.manualRenderingFormat, frameCapacity: 4096)!
var peak: Float = 0 var peak: Float = 0
for _ in 0..<11 { for _ in 0..<11 {
_ = try engine.renderOffline(4096, to: buf) guard objc("[2] render", {
let ch = buf.floatChannelData![0] do { _ = try engine.renderOffline(4096, to: buf) } catch { thrown = error }
for i in 0..<Int(buf.frameLength) { peak = max(peak, abs(ch[i])) } }), thrown == nil else { throw thrown ?? SpikeError.exception }
if let ch = buf.floatChannelData?[0] {
for i in 0..<Int(buf.frameLength) { peak = max(peak, abs(ch[i])) }
}
} }
engine.stop() _ = objc("[2] stop engine") { engine.stop() }
say(String(format: "[2] Rendered 1 s offline, peak %.3f: %@", peak, peak > 0.05 ? "PASS" : "FAIL")) say(String(format: "[2] Rendered 1 s offline, peak %.3f: %@", peak, peak > 0.05 ? "PASS" : "FAIL"))
} catch { } catch {
say("[2] FAIL: \(error.localizedDescription) (\((error as NSError).code))") say("[2] FAIL: \(error.localizedDescription) (\((error as NSError).code))")
} }
// 3b. The AU wrote au.txt when it was created; read it back from the app side // 3b. The AU wrote au.txt when it was created; read it back from the app side
step("[3] App Group probe after AU load")
say("[3] after AU load: " + Spike.probeGroup(as: "app")) say("[3] after AU load: " + Spike.probeGroup(as: "app"))
defaults.removeObject(forKey: Self.stepKey)
say("Done.")
} }
/// Audible check through the speaker, using the same out-of-process AU. /// Audible check through the speaker, using the same out-of-process AU.
func playTone() async { func playTone() async {
do { do {
step("play: audio session")
try AVAudioSession.sharedInstance().setCategory(.playback) try AVAudioSession.sharedInstance().setCategory(.playback)
try AVAudioSession.sharedInstance().setActive(true) try AVAudioSession.sharedInstance().setActive(true)
step("play: instantiate")
let unit = try await AVAudioUnit.instantiate(with: Spike.desc, options: .loadOutOfProcess) let unit = try await AVAudioUnit.instantiate(with: Spike.desc, options: .loadOutOfProcess)
let engine = AVAudioEngine() let engine = AVAudioEngine()
engine.attach(unit) var thrown: Error?
engine.connect(unit, to: engine.mainMixerNode, format: nil) guard objc("play: connect + start", {
try engine.start() engine.attach(unit)
engine.connect(unit, to: engine.mainMixerNode, format: nil)
do { try engine.start() } catch { thrown = error }
}), thrown == nil else { throw thrown ?? SpikeError.exception }
liveEngine = engine liveEngine = engine
let inst = unit as? AVAudioUnitMIDIInstrument let inst = unit as? AVAudioUnitMIDIInstrument
inst?.startNote(69, withVelocity: 100, onChannel: 0) inst?.startNote(69, withVelocity: 100, onChannel: 0)
@@ -78,9 +126,15 @@ final class SelfTest: ObservableObject {
try await Task.sleep(nanoseconds: 300_000_000) try await Task.sleep(nanoseconds: 300_000_000)
engine.stop() engine.stop()
liveEngine = nil liveEngine = nil
defaults.removeObject(forKey: Self.stepKey)
say("Played A4 for 1 s") say("Played A4 for 1 s")
} catch { } catch {
say("Play FAIL: \(error.localizedDescription)") say("Play FAIL: \(error.localizedDescription)")
} }
} }
} }
enum SpikeError: LocalizedError {
case exception
var errorDescription: String? { "Objective-C exception (see the line above)" }
}
+5 -3
View File
@@ -8,8 +8,8 @@ options:
iOS: "15.0" iOS: "15.0"
settings: settings:
base: base:
MARKETING_VERSION: "0.1.0" MARKETING_VERSION: "0.1.1"
CURRENT_PROJECT_VERSION: "1" CURRENT_PROJECT_VERSION: "2"
SWIFT_VERSION: "5.0" SWIFT_VERSION: "5.0"
TARGETED_DEVICE_FAMILY: "1,2" TARGETED_DEVICE_FAMILY: "1,2"
ARCHS: arm64 ARCHS: arm64
@@ -30,9 +30,11 @@ targets:
GENERATE_INFOPLIST_FILE: YES GENERATE_INFOPLIST_FILE: YES
INFOPLIST_KEY_CFBundleDisplayName: Sizzle Spike INFOPLIST_KEY_CFBundleDisplayName: Sizzle Spike
INFOPLIST_KEY_UILaunchScreen_Generation: YES INFOPLIST_KEY_UILaunchScreen_Generation: YES
INFOPLIST_KEY_UIApplicationSceneManifest_Generation: YES
ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon
SWIFT_OBJC_BRIDGING_HEADER: App/Bridging.h
INFOPLIST_KEY_UISupportedInterfaceOrientations: "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight" INFOPLIST_KEY_UISupportedInterfaceOrientations: "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad: "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight" INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad: "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"
INFOPLIST_KEY_UIBackgroundModes: audio
SizzleSpikeAU: SizzleSpikeAU:
type: app-extension type: app-extension
platform: iOS platform: iOS