Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift Package Manager 5.3 compatibility #1584

Merged
merged 7 commits into from Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
270 changes: 152 additions & 118 deletions Apollo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

60 changes: 56 additions & 4 deletions Package.swift
@@ -1,4 +1,4 @@
// swift-tools-version:5.2
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down Expand Up @@ -41,91 +41,143 @@ let package = Package(
.upToNextMinor(from: "0.0.2")),
],
targets: [
.target(
name: "ApolloCore",
dependencies: []),
.target(
name: "ApolloCore",
dependencies: [],
exclude: [
"Info.plist"
]),
.target(
name: "Apollo",
dependencies: [
"ApolloCore",
],
exclude: [
"Info.plist"
]),
.target(
name: "ApolloCodegenLib",
dependencies: [
"ApolloCore",
"InflectorKit",
.product(name: "Stencil", package: "Stencil"),
],
exclude: [
"Info.plist"
]),
.target(
name: "ApolloSQLite",
dependencies: [
"Apollo",
.product(name: "SQLite", package: "SQLite.swift"),
],
exclude: [
"Info.plist"
]),
.target(
name: "ApolloSQLiteTestSupport",
dependencies: [
"ApolloSQLite",
"ApolloTestSupport"
],
exclude: [
"Info.plist"
]),
.target(
name: "ApolloWebSocket",
dependencies: [
"Apollo",
"ApolloCore",
.product(name: "Starscream", package: "Starscream"),
],
exclude: [
"Info.plist"
]),
.target(
name: "ApolloTestSupport",
dependencies: [
"Apollo",
],
exclude: [
"Info.plist"
]),
.target(
name: "GitHubAPI",
dependencies: [
"Apollo",
],
exclude: [
"Info.plist",
"graphql"
]),
.target(
name: "StarWarsAPI",
dependencies: [
"Apollo",
],
exclude: [
"Info.plist",
"graphql"
]),
.target(
name: "UploadAPI",
dependencies: [
"Apollo",
],
exclude: [
"Info.plist",
"graphql"
]),
.testTarget(
name: "ApolloTests",
dependencies: [
"ApolloTestSupport",
"StarWarsAPI",
"UploadAPI"
],
exclude: [
"Info.plist"
],
resources: [
.copy("Resources")
]),
.testTarget(
name: "ApolloCacheDependentTests",
dependencies: [
"ApolloSQLiteTestSupport",
"StarWarsAPI",
],
exclude: [
"Info.plist"
]),
.testTarget(
name: "ApolloCodegenTests",
dependencies: [
"ApolloTestSupport",
"ApolloCodegenLib"
],
exclude: [
"Info.plist",
"scripts directory"
]),
.testTarget(
name: "ApolloSQLiteTests",
dependencies: [
"ApolloSQLiteTestSupport",
"StarWarsAPI"
],
exclude: [
"Info.plist"
]),
.testTarget(
name: "ApolloWebsocketTests",
dependencies: [
"ApolloWebSocket",
"ApolloTestSupport",
"StarWarsAPI",
],
exclude: [
"Info.plist"
]),
]
)
131 changes: 131 additions & 0 deletions Package@swift-5.2.swift
@@ -0,0 +1,131 @@
// swift-tools-version:5.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Apollo",
products: [
.library(
name: "ApolloCore",
targets: ["ApolloCore"]),
.library(
name: "Apollo",
targets: ["Apollo"]),
.library(
name: "Apollo-Dynamic",
type: .dynamic,
targets: ["Apollo"]),
.library(
name: "ApolloCodegenLib",
targets: ["ApolloCodegenLib"]),
.library(
name: "ApolloSQLite",
targets: ["ApolloSQLite"]),
.library(
name: "ApolloWebSocket",
targets: ["ApolloWebSocket"]),
],
dependencies: [
.package(
url: "https://github.com/stephencelis/SQLite.swift.git",
.upToNextMinor(from: "0.12.2")),
.package(
url: "https://github.com/daltoniam/Starscream",
.upToNextMinor(from: "3.1.1")),
.package(
url: "https://github.com/stencilproject/Stencil.git",
.upToNextMinor(from: "0.14.0")),
.package(
url: "https://github.com/apollographql/InflectorKit",
.upToNextMinor(from: "0.0.2")),
],
targets: [
.target(
name: "ApolloCore",
dependencies: []),
.target(
name: "Apollo",
dependencies: [
"ApolloCore",
]),
.target(
name: "ApolloCodegenLib",
dependencies: [
"ApolloCore",
"InflectorKit",
.product(name: "Stencil", package: "Stencil"),
]),
.target(
name: "ApolloSQLite",
dependencies: [
"Apollo",
.product(name: "SQLite", package: "SQLite.swift"),
]),
.target(
name: "ApolloSQLiteTestSupport",
dependencies: [
"ApolloSQLite",
"ApolloTestSupport"
]),
.target(
name: "ApolloWebSocket",
dependencies: [
"Apollo",
"ApolloCore",
.product(name: "Starscream", package: "Starscream"),
]),
.target(
name: "ApolloTestSupport",
dependencies: [
"Apollo",
]),
.target(
name: "GitHubAPI",
dependencies: [
"Apollo",
]),
.target(
name: "StarWarsAPI",
dependencies: [
"Apollo",
]),
.target(
name: "UploadAPI",
dependencies: [
"Apollo",
]),
.testTarget(
name: "ApolloTests",
dependencies: [
"ApolloTestSupport",
"StarWarsAPI",
"UploadAPI"
]),
.testTarget(
name: "ApolloCacheDependentTests",
dependencies: [
"ApolloSQLiteTestSupport",
"StarWarsAPI",
]),
.testTarget(
name: "ApolloCodegenTests",
dependencies: [
"ApolloTestSupport",
"ApolloCodegenLib"
]),
.testTarget(
name: "ApolloSQLiteTests",
dependencies: [
"ApolloSQLiteTestSupport",
"StarWarsAPI"
]),
.testTarget(
name: "ApolloWebsocketTests",
dependencies: [
"ApolloWebSocket",
"ApolloTestSupport",
"StarWarsAPI",
]),
]
)
8 changes: 5 additions & 3 deletions Sources/ApolloCodegenLib/ApolloCodegen.swift
Expand Up @@ -48,9 +48,11 @@ public class ApolloCodegen {
throw CodegenError.multipleFilesButNotDirectoryURL(folderURL)
}
case .singleFile(let fileURL):
guard fileURL.apollo.isSwiftFileURL else {
throw CodegenError.singleFileButNotSwiftFileURL(fileURL)
}
if options.codegenEngine == .typescript {
guard fileURL.apollo.isSwiftFileURL else {
throw CodegenError.singleFileButNotSwiftFileURL(fileURL)
}
} // else we're fine with JSON at this point for intermediate purposes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once default codegen becomes swift codegen, this will fail the tests that check that a folder URL can't be passed in here.


try FileManager.default.apollo.createContainingFolderIfNeeded(for: fileURL)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ApolloCodegenLib/ApolloCodegenOptions.swift
Expand Up @@ -14,7 +14,7 @@ public struct ApolloCodegenOptions {
}

/// Enum to select which code generation you wish to use
public enum CodeGenerationEngine {
public enum CodeGenerationEngine: Equatable {
/// The default, tried and true code generation engine
case typescript

Expand Down
10 changes: 0 additions & 10 deletions Sources/GitHubAPI/operationIdsPath.json

This file was deleted.