Skip to content

Commit

Permalink
Added #if availability check to some ApolloCodegen source files that …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Tiziano Coroneo committed Mar 5, 2020
1 parent 165f078 commit f7711c7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Sources/ApolloCodegenLib/ApolloCLI.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Foundation

// Only available on macOS
#if os(macOS)

/// 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
Expand Down Expand Up @@ -47,3 +49,5 @@ public struct ApolloCLI {
return try Basher.run(command: command, from: folder)
}
}

#endif
6 changes: 5 additions & 1 deletion Sources/ApolloCodegenLib/ApolloCodegen.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Foundation

// Only available on macOS
#if os(macOS)

/// A class to facilitate running code generation
@available(OSX, message: "Only available on macOS")
public class ApolloCodegen {

/// Errors which can happen with code generation
Expand Down Expand Up @@ -42,3 +44,5 @@ public class ApolloCodegen {
return try cli.runApollo(with: options.arguments, from: folder)
}
}

#endif
6 changes: 5 additions & 1 deletion Sources/ApolloCodegenLib/ApolloSchemaDownloader.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Foundation

// Only available on macOS
#if os(macOS)

/// 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
Expand All @@ -19,3 +21,5 @@ public struct ApolloSchemaDownloader {
return try cli.runApollo(with: options.arguments)
}
}

#endif
6 changes: 5 additions & 1 deletion Sources/ApolloCodegenLib/Basher.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Foundation

// Only available on macOS
#if os(macOS)

/// Bash command runner
@available(OSX, message: "Only available on macOS")
public struct Basher {

public enum BashError: Error, LocalizedError {
Expand Down Expand Up @@ -65,3 +67,5 @@ public struct Basher {
return output
}
}

#endif
6 changes: 5 additions & 1 deletion Sources/ApolloCodegenLib/CLIDownloader.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Foundation

// Only available on macOS
#if os(macOS)

/// 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 {
Expand Down Expand Up @@ -118,3 +120,5 @@ struct CLIDownloader {
}
}
}

#endif
6 changes: 5 additions & 1 deletion Sources/ApolloCodegenLib/CLIExtractor.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Foundation

// Only available on macOS
#if os(macOS)

/// 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
Expand Down Expand Up @@ -122,3 +124,5 @@ struct CLIExtractor {
}
}
}

#endif

0 comments on commit f7711c7

Please sign in to comment.