Skip to content

Commit f7711c7

Browse files
author
Tiziano Coroneo
committed
Added #if availability check to some ApolloCodegen source files that prevent compilation on other platforms. This previously caused an issue that prevented SwiftUI previews on iOS targets from working properly, if that target included Apollo as a dependency.
1 parent 165f078 commit f7711c7

6 files changed

Lines changed: 30 additions & 6 deletions

File tree

Sources/ApolloCodegenLib/ApolloCLI.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Foundation
22

3+
// Only available on macOS
4+
#if os(macOS)
5+
36
/// Wrapper for calling the bundled node-based Apollo CLI.
4-
@available(OSX, message: "Only available on macOS")
57
public struct ApolloCLI {
68

79
/// Creates an instance of `ApolloCLI`, downloading and extracting if needed
@@ -47,3 +49,5 @@ public struct ApolloCLI {
4749
return try Basher.run(command: command, from: folder)
4850
}
4951
}
52+
53+
#endif

Sources/ApolloCodegenLib/ApolloCodegen.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Foundation
22

3+
// Only available on macOS
4+
#if os(macOS)
5+
36
/// A class to facilitate running code generation
4-
@available(OSX, message: "Only available on macOS")
57
public class ApolloCodegen {
68

79
/// Errors which can happen with code generation
@@ -42,3 +44,5 @@ public class ApolloCodegen {
4244
return try cli.runApollo(with: options.arguments, from: folder)
4345
}
4446
}
47+
48+
#endif

Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Foundation
22

3+
// Only available on macOS
4+
#if os(macOS)
5+
36
/// A wrapper to facilitate downloading a schema with the Apollo node CLI
4-
@available(OSX, message: "Only available on macOS")
57
public struct ApolloSchemaDownloader {
68

79
/// Runs code generation from the given folder with the passed-in options
@@ -19,3 +21,5 @@ public struct ApolloSchemaDownloader {
1921
return try cli.runApollo(with: options.arguments)
2022
}
2123
}
24+
25+
#endif

Sources/ApolloCodegenLib/Basher.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Foundation
22

3+
// Only available on macOS
4+
#if os(macOS)
5+
36
/// Bash command runner
4-
@available(OSX, message: "Only available on macOS")
57
public struct Basher {
68

79
public enum BashError: Error, LocalizedError {
@@ -65,3 +67,5 @@ public struct Basher {
6567
return output
6668
}
6769
}
70+
71+
#endif

Sources/ApolloCodegenLib/CLIDownloader.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Foundation
22

3+
// Only available on macOS
4+
#if os(macOS)
5+
36
/// Helper for downloading the CLI Zip file so we don't have to include it in the repo.
4-
@available(OSX, message: "Only available on macOS")
57
struct CLIDownloader {
68

79
enum CLIDownloaderError: Error, LocalizedError {
@@ -118,3 +120,5 @@ struct CLIDownloader {
118120
}
119121
}
120122
}
123+
124+
#endif

Sources/ApolloCodegenLib/CLIExtractor.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Foundation
22

3+
// Only available on macOS
4+
#if os(macOS)
5+
36
/// Helper for extracting and validating the node-based Apollo CLI from a zip.
4-
@available(OSX, message: "Only available on macOS")
57
struct CLIExtractor {
68

79
// MARK: - Extracting the binary
@@ -122,3 +124,5 @@ struct CLIExtractor {
122124
}
123125
}
124126
}
127+
128+
#endif

0 commit comments

Comments
 (0)