Skip to content

Commit d2e0ffe

Browse files
committed
fix(predictions): exclude CoreML predictions plugin from tvOS explicitly
The tvOS build failed with "'SFSpeechRecognitionResult' is unavailable in tvOS". SFSpeechRecognitionResult is marked API_UNAVAILABLE(tvos), and the CoreML predictions plugin was relying on `#if canImport(Speech)` to compile itself out on tvOS. As of the Xcode 26 SDKs, the tvOS Speech framework ships a module (module.modulemap and Speech.swiftmodule), so canImport(Speech) now succeeds on tvOS while the type itself remains unavailable. The guard silently stopped excluding the platform. Verified this is an SDK change and not a consequence of raising the tvOS deployment floor: the same file fails to compile against the Xcode 26 tvOS SDK at both tvos13.0 and tvos15.0. Adding `&& !os(tvOS)` restores the pre-Xcode-26 behavior. Applied to every file in the CoreML plugin rather than only the Speech types, because the plugin's configure/reset/client-behavior files reference those types and were previously compiled out as a unit. Verified by building CoreMLPredictionsPlugin and AWSPredictionsPlugin for arm64-apple-tvos15.0-simulator, and confirming macOS still compiles CoreMLPredictionService so the plugin stays active where Speech is genuinely available.
1 parent 73ee9b1 commit d2e0ffe

13 files changed

Lines changed: 18 additions & 13 deletions

AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Configure.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extension AWSPredictionsPlugin {
4141
let authService = AWSAuthService()
4242
let credentialIdentityResolver = authService.getCredentialIdentityResolver()
4343
let coremlService: CoreMLPredictionBehavior?
44-
#if canImport(Speech) && canImport(Vision)
44+
#if canImport(Speech) && canImport(Vision) && !os(tvOS)
4545
coremlService = try CoreMLPredictionService(configuration: configuration)
4646
#else
4747
coremlService = nil

AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/CoreML/CoreMLPredictionService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if canImport(Speech) && canImport(Vision)
8+
#if canImport(Speech) && canImport(Vision) && !os(tvOS)
99
import Amplify
1010
import CoreMLPredictionsPlugin
1111
import Foundation

AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+ClientBehavior.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if canImport(Speech) && canImport(Vision)
8+
#if canImport(Speech) && canImport(Vision) && !os(tvOS)
99
import Amplify
1010
import CoreGraphics
1111
import Foundation

AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Configure.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if canImport(Speech) && canImport(Vision)
8+
#if canImport(Speech) && canImport(Vision) && !os(tvOS)
99
import Foundation
1010
import Amplify
1111

AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Reset.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if canImport(Speech) && canImport(Vision)
8+
#if canImport(Speech) && canImport(Vision) && !os(tvOS)
99
import Amplify
1010
import Foundation
1111

AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if canImport(Speech) && canImport(Vision)
8+
#if canImport(Speech) && canImport(Vision) && !os(tvOS)
99
import Amplify
1010
import Foundation
1111

AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechAdapter.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if canImport(Speech)
8+
// See CoreMLSpeechBehavior for why tvOS is excluded here.
9+
#if canImport(Speech) && !os(tvOS)
910
import Amplify
1011
import Speech
1112

AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechBehavior.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if canImport(Speech)
8+
// SFSpeechRecognitionResult is marked API_UNAVAILABLE(tvos). As of the Xcode 26
9+
// SDKs the Speech module is importable on tvOS, so canImport(Speech) alone no
10+
// longer excludes the platform.
11+
#if canImport(Speech) && !os(tvOS)
912
import Amplify
1013
import Foundation
1114
import Speech

AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginAmplifyVersionableTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if canImport(Speech) && canImport(Vision)
8+
#if canImport(Speech) && canImport(Vision) && !os(tvOS)
99
import CoreMLPredictionsPlugin
1010
import XCTest
1111

AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginClientBehaviorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8-
#if canImport(Speech) && canImport(Vision)
8+
#if canImport(Speech) && canImport(Vision) && !os(tvOS)
99
import Amplify
1010
import XCTest
1111
@testable import CoreMLPredictionsPlugin

0 commit comments

Comments
 (0)