From e2b04a2ac32805a97311687937a347a6ab6f997a Mon Sep 17 00:00:00 2001 From: Danny Ricciotti Date: Sun, 10 Aug 2025 18:58:16 -0400 Subject: [PATCH 1/2] Fix to build on Mac OS15 --- .gitignore | 1 + .../NativeAppleTranscriptionService.swift | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 9e32f1a..53d4d3e 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ playground.xcworkspace # .swiftpm .build/ +build/ # CocoaPods # diff --git a/VoiceInk/Services/NativeAppleTranscriptionService.swift b/VoiceInk/Services/NativeAppleTranscriptionService.swift index ddbcf45..e7009da 100644 --- a/VoiceInk/Services/NativeAppleTranscriptionService.swift +++ b/VoiceInk/Services/NativeAppleTranscriptionService.swift @@ -62,6 +62,9 @@ class NativeAppleTranscriptionService: TranscriptionService { throw ServiceError.unsupportedOS } + // Feature gated: SpeechAnalyzer/SpeechTranscriber are future APIs. + // Enable by defining ENABLE_NATIVE_SPEECH_ANALYZER in build settings once building against macOS 26+ SDKs. + #if canImport(Speech) && ENABLE_NATIVE_SPEECH_ANALYZER logger.notice("Starting Apple native transcription with SpeechAnalyzer.") let audioFile = try AVAudioFile(forReading: audioURL) @@ -140,11 +143,15 @@ class NativeAppleTranscriptionService: TranscriptionService { logger.notice("Native transcription successful. Length: \(finalTranscription.count) characters.") return finalTranscription + #else + logger.notice("Native Apple transcription is disabled in this build (future Speech APIs not enabled).") + throw ServiceError.unsupportedOS + #endif } @available(macOS 26, *) private func deallocateExistingAssets() async throws { - #if canImport(Speech) + #if canImport(Speech) && ENABLE_NATIVE_SPEECH_ANALYZER // Deallocate any existing allocated locales to avoid conflicts for locale in await AssetInventory.allocatedLocales { await AssetInventory.deallocate(locale: locale) @@ -155,7 +162,7 @@ class NativeAppleTranscriptionService: TranscriptionService { @available(macOS 26, *) private func allocateAssetsForLocale(_ locale: Locale) async throws { - #if canImport(Speech) + #if canImport(Speech) && ENABLE_NATIVE_SPEECH_ANALYZER do { try await AssetInventory.allocate(locale: locale) logger.notice("Successfully allocated assets for locale: '\(locale.identifier(.bcp47))'") @@ -166,9 +173,11 @@ class NativeAppleTranscriptionService: TranscriptionService { #endif } + // Forward-compatibility: Use Any here because SpeechTranscriber is only available in future macOS SDKs. + // This avoids referencing an unavailable SDK symbol while keeping the method shape for later adoption. @available(macOS 26, *) - private func ensureModelIsAvailable(for transcriber: SpeechTranscriber, locale: Locale) async throws { - #if canImport(Speech) + private func ensureModelIsAvailable(for transcriber: Any, locale: Locale) async throws { + #if canImport(Speech) && ENABLE_NATIVE_SPEECH_ANALYZER let installedLocales = await SpeechTranscriber.installedLocales let isInstalled = installedLocales.map({ $0.identifier(.bcp47) }).contains(locale.identifier(.bcp47)) From 2c12003b84115664efb91bcfc0d7fec838035da1 Mon Sep 17 00:00:00 2001 From: Danny Ricciotti Date: Sun, 10 Aug 2025 18:59:53 -0400 Subject: [PATCH 2/2] Update project.pbxproj --- VoiceInk.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VoiceInk.xcodeproj/project.pbxproj b/VoiceInk.xcodeproj/project.pbxproj index 43c1a71..7c85b52 100644 --- a/VoiceInk.xcodeproj/project.pbxproj +++ b/VoiceInk.xcodeproj/project.pbxproj @@ -54,7 +54,7 @@ E11473B02CBE0F0A00318EE4 /* VoiceInk.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VoiceInk.app; sourceTree = BUILT_PRODUCTS_DIR; }; E11473C32CBE0F0B00318EE4 /* VoiceInkTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; E11473CD2CBE0F0B00318EE4 /* VoiceInkUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - E1B2DCAA2E3DE70A008DFD68 /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../Downloads/build-apple/whisper.xcframework"; sourceTree = ""; }; + E1B2DCAA2E3DE70A008DFD68 /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../whisper.cpp/build-apple/whisper.xcframework"; sourceTree = ""; }; E1CE28772E4336150082B758 /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../build-apple/whisper.xcframework"; sourceTree = ""; }; /* End PBXFileReference section */