From 89074ccb507dbd46a6442e3ff06c1108d3eab840 Mon Sep 17 00:00:00 2001 From: Ellen Shapiro Date: Tue, 25 Feb 2020 15:14:19 -0600 Subject: [PATCH] Add defensive @available guards to prevent accidental compilation on unsupported platforms. --- Sources/ApolloCodegenLib/ApolloCLI.swift | 1 + Sources/ApolloCodegenLib/ApolloCodegen.swift | 1 + Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift | 1 + Sources/ApolloCodegenLib/Basher.swift | 1 + Sources/ApolloCodegenLib/CLIDownloader.swift | 1 + Sources/ApolloCodegenLib/CLIExtractor.swift | 1 + 6 files changed, 6 insertions(+) diff --git a/Sources/ApolloCodegenLib/ApolloCLI.swift b/Sources/ApolloCodegenLib/ApolloCLI.swift index 816f8513f5..7611c66012 100644 --- a/Sources/ApolloCodegenLib/ApolloCLI.swift +++ b/Sources/ApolloCodegenLib/ApolloCLI.swift @@ -1,6 +1,7 @@ import Foundation /// Wrapper for calling the bundled node-based Apollo CLI. +@available(OSX, message: "Only available on macOS") public struct ApolloCLI { /// Creates an instance of `ApolloCLI`, downloading and extracting if needed diff --git a/Sources/ApolloCodegenLib/ApolloCodegen.swift b/Sources/ApolloCodegenLib/ApolloCodegen.swift index 327d73ae95..1dd948256c 100644 --- a/Sources/ApolloCodegenLib/ApolloCodegen.swift +++ b/Sources/ApolloCodegenLib/ApolloCodegen.swift @@ -1,6 +1,7 @@ import Foundation /// A class to facilitate running code generation +@available(OSX, message: "Only available on macOS") public class ApolloCodegen { /// Errors which can happen with code generation diff --git a/Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift b/Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift index e9433e4954..b39ad8d5cf 100644 --- a/Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift +++ b/Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift @@ -1,6 +1,7 @@ import Foundation /// A wrapper to facilitate downloading a schema with the Apollo node CLI +@available(OSX, message: "Only available on macOS") public struct ApolloSchemaDownloader { /// Runs code generation from the given folder with the passed-in options diff --git a/Sources/ApolloCodegenLib/Basher.swift b/Sources/ApolloCodegenLib/Basher.swift index b91dd3b5d5..e6b4d110a1 100644 --- a/Sources/ApolloCodegenLib/Basher.swift +++ b/Sources/ApolloCodegenLib/Basher.swift @@ -1,6 +1,7 @@ import Foundation /// Bash command runner +@available(OSX, message: "Only available on macOS") public struct Basher { public enum BashError: Error, LocalizedError { diff --git a/Sources/ApolloCodegenLib/CLIDownloader.swift b/Sources/ApolloCodegenLib/CLIDownloader.swift index 4fbad1d0ff..020d44c522 100644 --- a/Sources/ApolloCodegenLib/CLIDownloader.swift +++ b/Sources/ApolloCodegenLib/CLIDownloader.swift @@ -1,6 +1,7 @@ import Foundation /// Helper for downloading the CLI Zip file so we don't have to include it in the repo. +@available(OSX, message: "Only available on macOS") struct CLIDownloader { enum CLIDownloaderError: Error, LocalizedError { diff --git a/Sources/ApolloCodegenLib/CLIExtractor.swift b/Sources/ApolloCodegenLib/CLIExtractor.swift index 49c7377ce1..0bd26615b3 100644 --- a/Sources/ApolloCodegenLib/CLIExtractor.swift +++ b/Sources/ApolloCodegenLib/CLIExtractor.swift @@ -1,6 +1,7 @@ import Foundation /// Helper for extracting and validating the node-based Apollo CLI from a zip. +@available(OSX, message: "Only available on macOS") struct CLIExtractor { // MARK: - Extracting the binary