From 77d6e459b219c096b5374686ecdddc17a9b9c2f8 Mon Sep 17 00:00:00 2001 From: Reactorcoremeltdown Date: Sat, 14 Nov 2026 13:46:45 +0100 Subject: [PATCH] iOS: TrollStore AUv3 spike (host app + sine AUv3 + App Group self-test) Separate tree under ios/ with its own Makefile: XcodeGen project, unsigned device build ad-hoc signed with entitlements and packed as an .ipa. Co-Authored-By: Claude Opus 5.5 --- docs/DEVELOPER_HANDOVER.md | 7 ++ ios/.gitignore | 4 + ios/Makefile | 69 ++++++++++++++++ ios/README.md | 81 ++++++++++++++++++ ios/spike/AU/AU.entitlements | 10 +++ ios/spike/AU/AudioUnitViewController.swift | 34 ++++++++ ios/spike/AU/Info.plist | 59 +++++++++++++ ios/spike/AU/SpikeAudioUnit.swift | 96 ++++++++++++++++++++++ ios/spike/App/App.entitlements | 10 +++ ios/spike/App/ContentView.swift | 30 +++++++ ios/spike/App/SelfTest.swift | 86 +++++++++++++++++++ ios/spike/App/SpikeApp.swift | 9 ++ ios/spike/Shared/Spike.swift | 39 +++++++++ ios/spike/project.yml | 44 ++++++++++ versions.properties | 3 + 15 files changed, 581 insertions(+) create mode 100644 ios/.gitignore create mode 100644 ios/Makefile create mode 100644 ios/README.md create mode 100644 ios/spike/AU/AU.entitlements create mode 100644 ios/spike/AU/AudioUnitViewController.swift create mode 100644 ios/spike/AU/Info.plist create mode 100644 ios/spike/AU/SpikeAudioUnit.swift create mode 100644 ios/spike/App/App.entitlements create mode 100644 ios/spike/App/ContentView.swift create mode 100644 ios/spike/App/SelfTest.swift create mode 100644 ios/spike/App/SpikeApp.swift create mode 100644 ios/spike/Shared/Spike.swift create mode 100644 ios/spike/project.yml diff --git a/docs/DEVELOPER_HANDOVER.md b/docs/DEVELOPER_HANDOVER.md index 4e49a3c..91dcad4 100644 --- a/docs/DEVELOPER_HANDOVER.md +++ b/docs/DEVELOPER_HANDOVER.md @@ -377,6 +377,13 @@ in a `LaunchedEffect`, opens the editor, and on CLOSE / Back returns to `returnT The mixer's INSTRUMENT and FX dropdowns use it on long-press (`RetroDropdown`'s optional `onLongClick`, with a haptic tick; a tap still opens the menu). +### 5.4.2 iOS/iPadOS AUv3 port (staging) + +`ios/` is a separate tree with its own Makefile for the planned iPadOS 15+ app +that would ship every device as an AUv3 plugin, installed with TrollStore. For +now it holds only a spike that checks whether hosts see AUv3 plugins from a +TrollStore install and whether App Groups work there. See `ios/README.md`. + ### 5.5 Sizzle as a background MIDI sound module Goal: another app (Mikro Seq, a DAW, a controller app) plays Sizzle's mixer over diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..924054e --- /dev/null +++ b/ios/.gitignore @@ -0,0 +1,4 @@ +build/ +dist/ +# generated from spike/project.yml by `make project` +*.xcodeproj/ diff --git a/ios/Makefile b/ios/Makefile new file mode 100644 index 0000000..9f0bdd6 --- /dev/null +++ b/ios/Makefile @@ -0,0 +1,69 @@ +# Sizzle for iOS/iPadOS — build entrypoint (separate from the Android Makefile). +# +# For now this tree holds only the TrollStore AUv3 spike (spike/): a host app plus +# one sine-wave AUv3 instrument and an App Group, built to answer "do hosts see +# AUv3 plugins from a TrollStore-installed app?" before any real porting. +# +# make help what each target does +# make project generate spike/SizzleSpike.xcodeproj from spike/project.yml +# make sim build the spike for the iOS Simulator +# make sim-run install + launch it on a booted simulator (self-test runs at launch) +# make ipa unsigned device build, ad-hoc signed with entitlements, packed as +# dist/cc.tiredsysadmin.ios.sizzlespike_.ipa for TrollStore +# make clean remove build/ and dist/ +# +# Needs Xcode and XcodeGen (brew install xcodegen). Builds stay local (CLAUDE.md). + +SHELL := /bin/sh +SPIKE := spike +PROJECT := $(SPIKE)/SizzleSpike.xcodeproj +SCHEME := SizzleSpike +APP_ID := cc.tiredsysadmin.ios.sizzlespike +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) + +SIM_APP := build/sim/Build/Products/Debug-iphonesimulator/$(SCHEME).app +DEV_APP := build/dev/Build/Products/Release-iphoneos/$(SCHEME).app +IPA := dist/$(APP_ID)_$(BUILD_NO).ipa + +.DEFAULT_GOAL := help + +help: + @sed -n 's/^# //p' Makefile + +project: $(PROJECT)/project.pbxproj +$(PROJECT)/project.pbxproj: $(SPIKE)/project.yml + cd $(SPIKE) && xcodegen generate --spec project.yml --quiet + +# Simulator: Xcode's "sign to run locally" (-) embeds the entitlements, so the +# App Group works there too. +sim: $(SIM_APP) +$(SIM_APP): $(PROJECT)/project.pbxproj $(SOURCES) + xcodebuild -quiet -project $(PROJECT) -scheme $(SCHEME) -configuration Debug \ + -sdk iphonesimulator -derivedDataPath build/sim \ + CODE_SIGN_IDENTITY=- CODE_SIGN_STYLE=Manual build + +sim-run: $(SIM_APP) + xcrun simctl install booted $(SIM_APP) + xcrun simctl launch booted $(APP_ID) + +# Device: build without signing, then ad-hoc sign inside-out (extension first) +# with each target's entitlements. TrollStore re-signs at install time but keeps +# the entitlements it finds, which is how the App Group survives. +ipa: $(IPA) +$(IPA): $(PROJECT)/project.pbxproj $(SOURCES) + xcodebuild -quiet -project $(PROJECT) -scheme $(SCHEME) -configuration Release \ + -sdk iphoneos -derivedDataPath build/dev CODE_SIGNING_ALLOWED=NO build + rm -rf build/Payload && mkdir -p build/Payload dist + cp -R $(DEV_APP) build/Payload/ + codesign -f -s - --entitlements $(SPIKE)/AU/AU.entitlements \ + build/Payload/$(SCHEME).app/PlugIns/SizzleSpikeAU.appex + codesign -f -s - --entitlements $(SPIKE)/App/App.entitlements \ + build/Payload/$(SCHEME).app + rm -f $@ && cd build && zip -qr ../$@ Payload + @echo "wrote $@" + +clean: + rm -rf build dist + +.PHONY: help project sim sim-run ipa clean diff --git a/ios/README.md b/ios/README.md new file mode 100644 index 0000000..11fc6aa --- /dev/null +++ b/ios/README.md @@ -0,0 +1,81 @@ +# Sizzle for iOS/iPadOS — staging tree + +This tree is separate from the Android app (its own Makefile, nothing shared yet). +The plan is to ship every Sizzle instrument and effect as AUv3 plugins inside one +app (iOS/iPadOS 15+), installed with TrollStore. Before porting anything, the +**spike** in `spike/` answers the one question that could sink the plan: do hosts +(AUM, GarageBand, Loopy…) list AUv3 plugins from a TrollStore-installed app, and do +App Groups work there? + +## The spike + +| Piece | What it is | +|---|---| +| `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/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 | + +The self-test shows three checks: + +1. **[1] Registered components:** what `AVAudioUnitComponentManager` lists for + `Tsys/sSpk`. That is the same registry hosts read, so a FAIL here means no host + will see the plugin. +2. **[2] Instantiated out of process / Rendered 1 s offline:** iOS launches the + extension and its render block produces sound (silent, offline render; peak > 0.05). + "Play tone (1 s)" does the same through the speaker. +3. **[3] App Group:** the app writes `app.txt`, the extension writes `au.txt` when it is + created (and `au-view.txt` when a host opens its view), and each side lists what's + there. After [2], seeing `au.txt` in the app's list proves both sides share files, + which is how the real port will hand samples and SF2 files to the plugins. + +### Build + +```sh +make -C ios ipa # → ios/dist/cc.tiredsysadmin.ios.sizzlespike_1.ipa +``` + +Needs Xcode and XcodeGen. The device build is unsigned, then ad-hoc signed inside-out +(extension first) with each target's entitlements, and zipped as `Payload/`. +TrollStore re-signs at install time and keeps the entitlements it finds; ldid +isn't needed. Checked on the Mac: arm64, minimum OS 15.0 for the app and the +extension, App Group entitlement on both, extension entry point `NSExtensionMain`, +extension point `com.apple.AudioUnit-UI`. + +`make sim` / `make sim-run` build and run it in the Simulator, but no Simulator +runtime was installed when the spike was written, so it hasn't been run there. + +### Test on the iPad + +1. AirDrop or copy `cc.tiredsysadmin.ios.sizzlespike_1.ipa` to the iPad, open it with + TrollStore, install. +2. Open **Sizzle Spike** and note [1]–[3] (screenshot the screen). +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 + lists the App Group files). +4. Back in Sizzle Spike, **Run self-test** again: `au-view.txt` should now be listed. + +What the outcomes mean: + +- [1] PASS and the host lists it: the plan works as designed. +- [1] PASS but no host lists it: hosts filter TrollStore apps somehow; investigate + before porting. +- [1] FAIL: iOS didn't register the extension (pluginkit); try re-launching the app, + then a respring, then reinstall. +- [3] NOT AVAILABLE: App Groups don't survive TrollStore signing. The fallback is + passing sample data through the plugin's saved state, or having the plugin + pick files with a document picker. + +## Decisions + +- **XcodeGen, not a checked-in .xcodeproj:** the project is text you can diff and + review; the generated project is git-ignored. +- **Swift render block in the spike:** good enough for one sine voice (no allocation + or locks in the render block). The real port puts the DSP in a C++ core (see the + conversation that planned it: Kotlin DSP → C++ verified against reference audio + rendered by the Kotlin code). +- **One extension, factory dispatch:** the real port will list many + `AudioComponents` in one or a few extensions and pick the unit in + `createAudioUnit(with:)` by subtype, instead of one extension per device. +- **Versions:** the spike's version lives in `spike/project.yml` + (`MARKETING_VERSION` 0.1.0, `CURRENT_PROJECT_VERSION` 1, which names the .ipa). diff --git a/ios/spike/AU/AU.entitlements b/ios/spike/AU/AU.entitlements new file mode 100644 index 0000000..87b5fec --- /dev/null +++ b/ios/spike/AU/AU.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.application-groups + + group.cc.tiredsysadmin.ios.sizzlespike + + + diff --git a/ios/spike/AU/AudioUnitViewController.swift b/ios/spike/AU/AudioUnitViewController.swift new file mode 100644 index 0000000..77c3976 --- /dev/null +++ b/ios/spike/AU/AudioUnitViewController.swift @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import CoreAudioKit +import UIKit + +/// The extension's principal class: the AU factory and its (minimal) view. +public final class AudioUnitViewController: AUViewController, AUAudioUnitFactory { + private var audioUnit: AUAudioUnit? + + public func createAudioUnit(with componentDescription: AudioComponentDescription) throws -> AUAudioUnit { + let au = try SpikeAudioUnit(componentDescription: componentDescription, options: []) + audioUnit = au + return au + } + + public override func viewDidLoad() { + super.viewDidLoad() + preferredContentSize = CGSize(width: 400, height: 220) + view.backgroundColor = UIColor(red: 0.08, green: 0.09, blue: 0.10, alpha: 1) + let label = UILabel() + label.numberOfLines = 0 + label.font = .monospacedSystemFont(ofSize: 12, weight: .regular) + label.textColor = UIColor(red: 0.96, green: 0.76, blue: 0.29, alpha: 1) + label.text = "Sizzle Spike Sine (AUv3)\nPlay notes from the host.\n\n" + Spike.probeGroup(as: "au-view") + label.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(label) + NSLayoutConstraint.activate([ + label.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 12), + label.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -12), + label.topAnchor.constraint(equalTo: view.topAnchor, constant: 12), + ]) + } +} diff --git a/ios/spike/AU/Info.plist b/ios/spike/AU/Info.plist new file mode 100644 index 0000000..6acb701 --- /dev/null +++ b/ios/spike/AU/Info.plist @@ -0,0 +1,59 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + Sizzle Spike AU + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSExtension + + NSExtensionAttributes + + AudioComponents + + + description + Sizzle Spike Sine + factoryFunction + $(PRODUCT_MODULE_NAME).AudioUnitViewController + manufacturer + Tsys + name + Tired Sysadmin: Sizzle Spike Sine + sandboxSafe + + subtype + sSpk + tags + + Synthesizer + + type + aumu + version + 65536 + + + + NSExtensionPointIdentifier + com.apple.AudioUnit-UI + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).AudioUnitViewController + + + diff --git a/ios/spike/AU/SpikeAudioUnit.swift b/ios/spike/AU/SpikeAudioUnit.swift new file mode 100644 index 0000000..8bdf1f0 --- /dev/null +++ b/ios/spike/AU/SpikeAudioUnit.swift @@ -0,0 +1,96 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import AudioToolbox +import AVFoundation +import Foundation + +/// State the render block touches. Allocated before rendering starts; the render +/// block only reads and writes these fields (no allocation, no locks). +final class SineKernel { + var sampleRate: Double = 44_100 + var phase: Double = 0 + var freq: Double = 440 + var env: Float = 0 + var gate = false + var gain: Float = 0.3 + /// Our own output memory for hosts that pass buffers with nil mData. + var scratch = UnsafeMutablePointer.allocate(capacity: 2 * 4096) + deinit { scratch.deallocate() } +} + +/// The spike's instrument: one sine voice, MIDI note on/off, one Gain parameter. +public final class SpikeAudioUnit: AUAudioUnit { + private let kernel = SineKernel() + private var outBus: AUAudioUnitBus! + private var busses: AUAudioUnitBusArray! + private var tree: AUParameterTree! + + public override init(componentDescription: AudioComponentDescription, + options: AudioComponentInstantiationOptions = []) throws { + try super.init(componentDescription: componentDescription, options: options) + let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 2)! + outBus = try AUAudioUnitBus(format: format) + outBus.maximumChannelCount = 2 + busses = AUAudioUnitBusArray(audioUnit: self, busType: .output, busses: [outBus]) + + let gain = AUParameterTree.createParameter( + withIdentifier: "gain", name: "Gain", address: 0, min: 0, max: 1, + unit: .linearGain, unitName: nil, flags: [.flag_IsReadable, .flag_IsWritable], + valueStrings: nil, dependentParameters: nil) + tree = AUParameterTree.createTree(withChildren: [gain]) + let k = kernel + tree.implementorValueObserver = { p, v in if p.address == 0 { k.gain = v } } + tree.implementorValueProvider = { p in p.address == 0 ? k.gain : 0 } + maximumFramesToRender = 4096 + + // Prove the extension side can write the App Group too. + _ = Spike.probeGroup(as: "au") + } + + public override var outputBusses: AUAudioUnitBusArray { busses } + public override var parameterTree: AUParameterTree? { get { tree } set { } } + + public override func allocateRenderResources() throws { + try super.allocateRenderResources() + kernel.sampleRate = outBus.format.sampleRate + if maximumFramesToRender > 4096 { + kernel.scratch.deallocate() + kernel.scratch = .allocate(capacity: 2 * Int(maximumFramesToRender)) + } + } + + public override var internalRenderBlock: AUInternalRenderBlock { + let k = kernel + return { _, _, frameCount, _, outputData, eventList, _ in + // MIDI (applied at the start of the block; good enough for a spike) + var ev = eventList + while let e = ev { + if e.pointee.head.eventType == .MIDI { + let m = e.pointee.MIDI + let status = m.data.0 & 0xF0, note = m.data.1, vel = m.data.2 + if status == 0x90 && vel > 0 { + k.freq = 440 * pow(2, (Double(note) - 69) / 12); k.gate = true + } else if status == 0x80 || status == 0x90 { + k.gate = false + } + } + ev = UnsafePointer(e.pointee.head.next) + } + let abl = UnsafeMutableAudioBufferListPointer(outputData) + for j in 0.. 2 * Double.pi { k.phase -= 2 * Double.pi } + for j in 0.. + + + + com.apple.security.application-groups + + group.cc.tiredsysadmin.ios.sizzlespike + + + diff --git a/ios/spike/App/ContentView.swift b/ios/spike/App/ContentView.swift new file mode 100644 index 0000000..5bb586d --- /dev/null +++ b/ios/spike/App/ContentView.swift @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import SwiftUI + +struct ContentView: View { + @StateObject private var test = SelfTest() + + var body: some View { + VStack(alignment: .leading, spacing: 12) { + Text("Sizzle AUv3 spike").font(.system(.title2, design: .monospaced)).foregroundColor(.orange) + Text("In AUM / GarageBand / Loopy look for\n\"Tired Sysadmin: Sizzle Spike Sine\" (instrument).") + .font(.system(.footnote, design: .monospaced)).foregroundColor(.gray) + HStack { + Button("Run self-test") { Task { await test.run() } } + Button("Play tone (1 s)") { Task { await test.playTone() } } + } + .buttonStyle(.bordered) + ScrollView { + Text(test.lines.joined(separator: "\n")) + .font(.system(.footnote, design: .monospaced)) + .frame(maxWidth: .infinity, alignment: .leading) + .textSelection(.enabled) + } + } + .padding() + .preferredColorScheme(.dark) + .task { await test.run() } + } +} diff --git a/ios/spike/App/SelfTest.swift b/ios/spike/App/SelfTest.swift new file mode 100644 index 0000000..5f7e80d --- /dev/null +++ b/ios/spike/App/SelfTest.swift @@ -0,0 +1,86 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import AVFoundation +import os + +/// Answers the spike's questions on the device itself: +/// 1. did iOS register the extension's Audio Unit (what hosts will list)? +/// 2. does it load out of process and render sound? +/// 3. can the app and the extension share files through the App Group? +@MainActor +final class SelfTest: ObservableObject { + @Published var lines: [String] = [] + private let log = Logger(subsystem: "cc.tiredsysadmin.ios.sizzlespike", category: "selftest") + private var liveEngine: AVAudioEngine? + + private func say(_ s: String) { + lines.append(s) + log.notice("\(s, privacy: .public)") + } + + func run() async { + lines = [] + let os = ProcessInfo.processInfo.operatingSystemVersionString + say("iOS \(os)") + + // 1. Registration + let all = AVAudioUnitComponentManager.shared().components(matching: Spike.desc) + 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)") } + + // 3a. App Group from the app side (before the AU writes) + say("[3] " + Spike.probeGroup(as: "app")) + + // 2. Load out of process, render 1 s offline (silent), measure the peak + do { + let unit = try await AVAudioUnit.instantiate(with: Spike.desc, options: .loadOutOfProcess) + say("[2] Instantiated \"\(unit.auAudioUnit.audioUnitName ?? "?")\" out of process: PASS") + let engine = AVAudioEngine() + let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 2)! + try engine.enableManualRenderingMode(.offline, format: format, maximumFrameCount: 4096) + engine.attach(unit) + engine.connect(unit, to: engine.mainMixerNode, format: format) + try engine.start() + (unit as? AVAudioUnitMIDIInstrument)?.startNote(69, withVelocity: 100, onChannel: 0) + let buf = AVAudioPCMBuffer(pcmFormat: engine.manualRenderingFormat, frameCapacity: 4096)! + var peak: Float = 0 + for _ in 0..<11 { + _ = try engine.renderOffline(4096, to: buf) + let ch = buf.floatChannelData![0] + for i in 0.. 0.05 ? "PASS" : "FAIL")) + } catch { + 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 + say("[3] after AU load: " + Spike.probeGroup(as: "app")) + } + + /// Audible check through the speaker, using the same out-of-process AU. + func playTone() async { + do { + try AVAudioSession.sharedInstance().setCategory(.playback) + try AVAudioSession.sharedInstance().setActive(true) + let unit = try await AVAudioUnit.instantiate(with: Spike.desc, options: .loadOutOfProcess) + let engine = AVAudioEngine() + engine.attach(unit) + engine.connect(unit, to: engine.mainMixerNode, format: nil) + try engine.start() + liveEngine = engine + let inst = unit as? AVAudioUnitMIDIInstrument + inst?.startNote(69, withVelocity: 100, onChannel: 0) + try await Task.sleep(nanoseconds: 1_000_000_000) + inst?.stopNote(69, onChannel: 0) + try await Task.sleep(nanoseconds: 300_000_000) + engine.stop() + liveEngine = nil + say("Played A4 for 1 s") + } catch { + say("Play FAIL: \(error.localizedDescription)") + } + } +} diff --git a/ios/spike/App/SpikeApp.swift b/ios/spike/App/SpikeApp.swift new file mode 100644 index 0000000..c4876a4 --- /dev/null +++ b/ios/spike/App/SpikeApp.swift @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import SwiftUI + +@main +struct SpikeApp: App { + var body: some Scene { WindowGroup { ContentView() } } +} diff --git a/ios/spike/Shared/Spike.swift b/ios/spike/Shared/Spike.swift new file mode 100644 index 0000000..51b652e --- /dev/null +++ b/ios/spike/Shared/Spike.swift @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown +// SPDX-License-Identifier: GPL-3.0-or-later + +import AudioToolbox +import Foundation + +/// What the app and the extension agree on: the App Group and the AU's identity. +enum Spike { + static let group = "group.cc.tiredsysadmin.ios.sizzlespike" + + /// 'aumu' / 'sSpk' / 'Tsys' — must match AU/Info.plist. + static let desc = AudioComponentDescription( + componentType: kAudioUnitType_MusicDevice, + componentSubType: fourCC("sSpk"), + componentManufacturer: fourCC("Tsys"), + componentFlags: 0, componentFlagsMask: 0) + + static func fourCC(_ s: String) -> FourCharCode { + s.utf8.reduce(0) { ($0 << 8) | FourCharCode($1) } + } + + /// Writes `.txt` into the App Group container and reports every file in it, + /// so each side shows what the other one wrote. + static func probeGroup(as who: String) -> String { + guard let dir = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group) else { + return "App Group \(group): NOT AVAILABLE (entitlement missing or not honoured)" + } + let stamp = ISO8601DateFormatter().string(from: Date()) + let wrote = (try? "\(who) was here at \(stamp)\n".write(to: dir.appendingPathComponent("\(who).txt"), + atomically: true, encoding: .utf8)) != nil + var out = "App Group OK, \(who) write \(wrote ? "OK" : "FAILED")" + let files = (try? FileManager.default.contentsOfDirectory(atPath: dir.path).sorted()) ?? [] + for f in files where f.hasSuffix(".txt") { + let text = (try? String(contentsOf: dir.appendingPathComponent(f), encoding: .utf8)) ?? "?" + out += "\n \(f): \(text.trimmingCharacters(in: .whitespacesAndNewlines))" + } + return out + } +} diff --git a/ios/spike/project.yml b/ios/spike/project.yml new file mode 100644 index 0000000..14ed733 --- /dev/null +++ b/ios/spike/project.yml @@ -0,0 +1,44 @@ +# XcodeGen spec for the TrollStore AUv3 spike (see ios/README.md). +# `make -C ios project` turns this into SizzleSpike.xcodeproj; never edit the +# generated project by hand. +name: SizzleSpike +options: + bundleIdPrefix: cc.tiredsysadmin.ios + deploymentTarget: + iOS: "15.0" +settings: + base: + MARKETING_VERSION: "0.1.0" + CURRENT_PROJECT_VERSION: "1" + SWIFT_VERSION: "5.0" + TARGETED_DEVICE_FAMILY: "1,2" + ARCHS: arm64 + DEVELOPMENT_TEAM: "" +targets: + SizzleSpike: + type: application + platform: iOS + sources: [App, Shared] + dependencies: + - target: SizzleSpikeAU + embed: true + codeSign: false + settings: + base: + PRODUCT_BUNDLE_IDENTIFIER: cc.tiredsysadmin.ios.sizzlespike + CODE_SIGN_ENTITLEMENTS: App/App.entitlements + GENERATE_INFOPLIST_FILE: YES + INFOPLIST_KEY_CFBundleDisplayName: Sizzle Spike + INFOPLIST_KEY_UILaunchScreen_Generation: YES + INFOPLIST_KEY_UISupportedInterfaceOrientations: "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight" + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad: "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight" + INFOPLIST_KEY_UIBackgroundModes: audio + SizzleSpikeAU: + type: app-extension + platform: iOS + sources: [AU, Shared] + settings: + base: + PRODUCT_BUNDLE_IDENTIFIER: cc.tiredsysadmin.ios.sizzlespike.au + CODE_SIGN_ENTITLEMENTS: AU/AU.entitlements + INFOPLIST_FILE: AU/Info.plist diff --git a/versions.properties b/versions.properties index 1d31cd6..b9c485e 100644 --- a/versions.properties +++ b/versions.properties @@ -14,6 +14,9 @@ android.versionCode = 70 # No desktop builds exist yet. These lines are the agreed slots so a port starts # with a version instead of inventing one; `-` means "not built on this # platform". Namespace for every platform: cc.tiredsysadmin..sizzle. +# iOS/iPadOS (cc.tiredsysadmin.ios.sizzle): only the AUv3 spike exists so far; +# its version is in ios/spike/project.yml (0.1.0, build 1). See ios/README.md. +ios.versionName = - macos.versionName = - linux.versionName = - bsd.versionName = -