diff --git a/.circleci/config.yml b/.circleci/config.yml index 4c57436b7a..96e6511179 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,28 +3,28 @@ version: 2.1 parameters: xcode_version: type: string - default: "11.6.0" + default: "12.0.0" ios_current_version: type: string - default: "13.6" + default: "14.0" ios_previous_version: type: string - default: "12.4" + default: "13.5" ios_sdk: type: string - default: "iphonesimulator13.6" + default: "iphonesimulator14.0" macos_version: # The user-facing version string for macOS builds type: string - default: "10.15" + default: "11.0" macos_sdk: # The full SDK string to use for macOS builds type: string - default: "macosx10.15" + default: "macosx11.0" tvos_version: # The user-facing version string of tvOS builds type: string - default: "13.4" + default: "14.0" tvos_sdk: type: string - default: "appletvsimulator13.4" + default: "appletvsimulator14.0" commands: common_test_steps: @@ -89,7 +89,7 @@ jobs: macos: xcode: << pipeline.parameters.xcode_version >> environment: - DESTINATION: platform=iOS Simulator,OS=<< pipeline.parameters.ios_previous_version >>,name=iPhone Xs + DESTINATION: platform=iOS Simulator,OS=<< pipeline.parameters.ios_previous_version >>,name=iPhone 11 CIRCLE_XCODE_SCHEME: Apollo CIRCLE_XCODE_SDK: << pipeline.parameters.ios_sdk >> steps: @@ -129,7 +129,7 @@ jobs: macos: xcode: << pipeline.parameters.xcode_version >> environment: - DESTINATION: platform=iOS Simulator,OS=<< pipeline.parameters.ios_previous_version >>,name=iPhone Xs + DESTINATION: platform=iOS Simulator,OS=<< pipeline.parameters.ios_previous_version >>,name=iPhone 11 CIRCLE_XCODE_SCHEME: ApolloSQLite CIRCLE_XCODE_SDK: << pipeline.parameters.ios_sdk >> steps: @@ -159,7 +159,7 @@ jobs: macos: xcode: << pipeline.parameters.xcode_version >> environment: - DESTINATION: platform=iOS Simulator,OS=<< pipeline.parameters.ios_previous_version >>,name=iPhone Xs + DESTINATION: platform=iOS Simulator,OS=<< pipeline.parameters.ios_previous_version >>,name=iPhone 11 CIRCLE_XCODE_SCHEME: ApolloWebSocket CIRCLE_XCODE_SDK: << pipeline.parameters.ios_sdk >> steps: diff --git a/Apollo.xcodeproj/project.pbxproj b/Apollo.xcodeproj/project.pbxproj index 3ee16d3282..8d816ef884 100644 --- a/Apollo.xcodeproj/project.pbxproj +++ b/Apollo.xcodeproj/project.pbxproj @@ -582,6 +582,7 @@ 9BAEEC14234C132600808306 /* CLIExtractorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLIExtractorTests.swift; sourceTree = ""; }; 9BAEEC16234C275600808306 /* ApolloSchemaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApolloSchemaTests.swift; sourceTree = ""; }; 9BAEEC18234C297800808306 /* ApolloCodegenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApolloCodegenTests.swift; sourceTree = ""; }; + 9BB1DAC624A66B2500396235 /* ApolloMacPlayground.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; name = ApolloMacPlayground.playground; path = Playgrounds/ApolloMacPlayground.playground; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 9BC2D9CE233C3531007BD083 /* Apollo-Target-ApolloCodegen.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Apollo-Target-ApolloCodegen.xcconfig"; sourceTree = ""; }; 9BC2D9D1233C6DC0007BD083 /* Basher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Basher.swift; sourceTree = ""; }; 9BCF0CD923FC9CA50031D2A2 /* TestCacheProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestCacheProvider.swift; sourceTree = ""; }; @@ -1377,6 +1378,7 @@ 9FC750461D2A532C00458D91 /* Apollo */ = { isa = PBXGroup; children = ( + 9BB1DAC624A66B2500396235 /* ApolloMacPlayground.playground */, 9FC750621D2A59F600458D91 /* ApolloClient.swift */, 9B708AAC2305884500604A11 /* ApolloClientProtocol.swift */, 9FC9A9D21E2FD48B0023C4D5 /* GraphQLError.swift */, @@ -1898,7 +1900,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1130; - LastUpgradeCheck = 1130; + LastUpgradeCheck = 1200; ORGANIZATIONNAME = "Apollo GraphQL"; TargetAttributes = { 9B2DFBB524E1FA0D00ED3AE6 = { diff --git a/Apollo.xcodeproj/xcshareddata/xcschemes/Apollo Playground.xcscheme b/Apollo.xcodeproj/xcshareddata/xcschemes/Apollo Playground.xcscheme new file mode 100644 index 0000000000..ccbe345913 --- /dev/null +++ b/Apollo.xcodeproj/xcshareddata/xcschemes/Apollo Playground.xcscheme @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Apollo.xcodeproj/xcshareddata/xcschemes/Apollo.xcscheme b/Apollo.xcodeproj/xcshareddata/xcschemes/Apollo.xcscheme index f2059a1d3b..372e48177b 100644 --- a/Apollo.xcodeproj/xcshareddata/xcschemes/Apollo.xcscheme +++ b/Apollo.xcodeproj/xcshareddata/xcschemes/Apollo.xcscheme @@ -1,6 +1,6 @@ npm start` + +to start the server locally. Once it starts, you should see: + + `> 🚀 Server ready at http://localhost:8080/graphql` + + `> 🚀 Subscriptions ready at ws://localhost:8080/websocket` + +Once that's up and running, you can start running queries against it from this playground! + +*/ + +//: [Queries](@next) diff --git a/Playgrounds/ApolloMacPlayground.playground/Pages/Mutations.xcplaygroundpage/Contents.swift b/Playgrounds/ApolloMacPlayground.playground/Pages/Mutations.xcplaygroundpage/Contents.swift new file mode 100644 index 0000000000..9862f4c004 --- /dev/null +++ b/Playgrounds/ApolloMacPlayground.playground/Pages/Mutations.xcplaygroundpage/Contents.swift @@ -0,0 +1,50 @@ +//: [Previous](@previous) + +import Foundation +import Apollo +import StarWarsAPI +import PlaygroundSupport + +//: ## Mutations +//: Mutations are used to change a piece of information on the server, and then return specified data after the change was made. +//: +//: Again, set up a basic client, similar to how you set one up in the Queries page. +let url = URL(string: "http://localhost:8080/graphql")! +let client = ApolloClient(url: url) + +//: Again, code generation will generate Swift initializers for your mutations. Pick one to use and create an instance variable for it: + +let mutation = CreateAwesomeReviewMutation() + +//: Next, pass it into the `client.perform` closure to actually have the server run the mutation: + +client.perform(mutation: mutation) { result in + // This is the outer Result, which has either a `GraphQLResult` or an `Error` + switch result { + case .success(let graphQLResult): + if let errors = graphQLResult.errors { + // Errors here were returned by the graphQL system. + // Note that the presence of errors does NOT necessarily indicate a request failed: GraphQL requests can return partial results in the event of an error. + print("GraphQL Errors: \(errors)") + } + + if let review = graphQLResult.data?.createReview { + // Here, we've used type-safe accessors to the nested type to access the specific type with the specific fields requested by this query. + print("Stars: \(review.stars)") + print("Review Commentary: \(review.commentary ?? "(none)")") + + // If you try to add a field which is defined in the schema, but which you haven't specifically requested as part of the query, it won't build. Uncomment the following line for an example: + //print("Episode: \(review.episode)") + } + case .failure(let error): + // If this happens, something's gone wrong at the network level before the GraphQL server could respond. + print("Network Error: \(error)") + } + + PlaygroundPage.current.finishExecution() +} + +PlaygroundPage.current.needsIndefiniteExecution = true + + +//: [Subscriptions](@next) diff --git a/Playgrounds/ApolloMacPlayground.playground/Pages/Queries.xcplaygroundpage/Contents.swift b/Playgrounds/ApolloMacPlayground.playground/Pages/Queries.xcplaygroundpage/Contents.swift new file mode 100644 index 0000000000..3488d3234a --- /dev/null +++ b/Playgrounds/ApolloMacPlayground.playground/Pages/Queries.xcplaygroundpage/Contents.swift @@ -0,0 +1,50 @@ +//: [Introduction](@previous) + +import Foundation +import Apollo +import StarWarsAPI +import PlaygroundSupport + +//: ## Queries +//: Queries are the most basic GraphQL operation: You ask the graph for information, and it returns the specific things you asked for. +//: +//: ## Creating a basic client +//: To create a basic client with a default configuration, you need the URL for your GraphQL endpoint, which you can then pass into your client: + +let url = URL(string: "http://localhost:8080/graphql")! +let client = ApolloClient(url: url) + +//: ## Making a query +//: First, you need to set up code generation to create the Swift code based on your queries. In this playground, we're using the sample `StarWarsAPI` code. +//: +//: When code is generated, you can use it to create a type-safe query object which has any available parameters: + +let query = HeroDetailsQuery(episode: .newhope) + +//: After setting up your query, you can pass it to your server using `client.fetch` and receive the results asynchronously: + +client.fetch(query: query) { result in + // This is the outer Result, which has either a `GraphQLResult` or an `Error` + switch result { + case .success(let graphQLResult): + if let errors = graphQLResult.errors { + // Errors here were returned by the GraphQL system. + // Note that the presence of errors does NOT necessarily indicate a request failed: GraphQL requests can return partial results in the event of an error. + print("GraphQL errors: \(errors)") + } + + if let hero = graphQLResult.data?.hero { + // Here, we've used a type-safe accessor to the nested type to access the specific type with the specific fields requested by this query. + print("Hero name: \(hero.name)") + } + case .failure(let error): + // If this happens, something's gone wrong at the network level before the GraphQL server could respond. + print("Network error: \(error)") + } + + PlaygroundPage.current.finishExecution() +} + +PlaygroundPage.current.needsIndefiniteExecution = true + +//: [Mutations](@next) diff --git a/Playgrounds/ApolloMacPlayground.playground/Pages/SQLiteCache.xcplaygroundpage/Contents.swift b/Playgrounds/ApolloMacPlayground.playground/Pages/SQLiteCache.xcplaygroundpage/Contents.swift new file mode 100644 index 0000000000..e7f7600311 --- /dev/null +++ b/Playgrounds/ApolloMacPlayground.playground/Pages/SQLiteCache.xcplaygroundpage/Contents.swift @@ -0,0 +1,67 @@ +//: [Subscriptons](@previous) + +import Apollo +import Foundation +import PlaygroundSupport + +//: # Setting up a client with a SQLite cache + +//: First, you'll need to set up a network transport, since you will also need that to set up the client: +let serverURL = URL(string: "http://localhost:8080/graphql")! +let networkTransport = HTTPNetworkTransport(url: serverURL) + +//: You'll need to make sure you import the ApolloSQLite library IF you are not using CocoaPods (CocoaPods will automatically flatten everything down to a single Apollo import): +import ApolloSQLite + +//: Next, you'll have to figure out where to store your SQLite file. A reasonable place is the user's Documents directory in your sandbox. +let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! +let documentsURL = URL(fileURLWithPath: documentsPath) +let sqliteFileURL = documentsURL.appendingPathComponent("test_apollo_db.sqlite") + +print("File path: \(sqliteFileURL.path)") + +//: Use that file URL to instantiate the SQLite cache: +let sqliteCache = try SQLiteNormalizedCache(fileURL: sqliteFileURL) + +//: And then instantiate an instance of `ApolloStore` with the cache you've just created: +let store = ApolloStore(cache: sqliteCache) + +//: Finally, pass that into your `ApolloClient` initializer, and you're now set up to use the SQLite cache for persistent storage: +let apolloClient = ApolloClient(networkTransport: networkTransport, store: store) + + +//: Now, let's test +import StarWarsAPI +let query = HeroDetailsQuery(episode: .newhope) +apolloClient.fetch(query: query) { result in + // This is the outer Result, which has either a `GraphQLResult` or an `Error` + switch result { + case .success(let graphQLResult): + if let errors = graphQLResult.errors { + // Errors here were returned by the GraphQL system. + // Note that the presence of errors does NOT necessarily indicate a request failed: GraphQL requests can return partial results in the event of an error. + print("GraphQL errors: \(errors)") + } + + if let hero = graphQLResult.data?.hero { + // Here, we've used a type-safe accessor to the nested type to access the specific type with the specific fields requested by this query. + print("Hero name: \(hero.name)") + } + case .failure(let error): + // If this happens, something's gone wrong at the network level before the GraphQL server could respond. + print("Network error: \(error)") + } +} + +//: Give the database write a chance to finish before the playground finishes executing +DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + print("FINISHED") + PlaygroundPage.current.finishExecution() +} + +PlaygroundPage.current.needsIndefiniteExecution = true + +//: Once "FINISHED" prints, you can open the database file at the path printed out with "File path" and examine it to see the persisted data. +//: If you don't already have a SQLite file browser, you can try the free one at https://sqlitebrowser.org/ + +//: [Next](@next) diff --git a/Playgrounds/ApolloMacPlayground.playground/Pages/Subscriptions.xcplaygroundpage/Contents.swift b/Playgrounds/ApolloMacPlayground.playground/Pages/Subscriptions.xcplaygroundpage/Contents.swift new file mode 100644 index 0000000000..a188659b7b --- /dev/null +++ b/Playgrounds/ApolloMacPlayground.playground/Pages/Subscriptions.xcplaygroundpage/Contents.swift @@ -0,0 +1,130 @@ +//: [Mutations](@previous) +import Foundation +import Apollo +import ApolloWebSocket +import StarWarsAPI +import PlaygroundSupport +/*: +## Subscriptions + +Subscriptions allow you to use a web socket connection to subscribe to updates to a particular query. + +Your web backend must declare support for subscriptions in the Schema just like it declares support for mutations, these cannot be used to subscribe to listen to changes to arbitrary queries. +*/ + +/*: +## Network Transport and Client Setup + +To use subscriptions, you need to have a `NetworkTransport` implementation which supports them. Fortunately, with the `ApolloWebSocket` package, there are two! + +The first is the `WebSocketTransport`, which works with the web socket, and the second is the `SplitNetworkTransport`, which uses a web socket for subscriptions but a normal `HTTPNetworkTransport` for everything else. + +In this instance, we'll use a `SplitNetworkTransport` since we want to demonstrate subscribing to changes, but we need to also be able to send changes for that subscription to come through. +*/ + +//:First, setup the `HTTPNetworkTransport`: + +let url = URL(string: "http://localhost:8080/graphql")! +let normalTransport = HTTPNetworkTransport(url: url) + +//: Next, set up the `WebSocketTransport` to talk to the websocket endpoint. Note that this may take a different URL, sometimes with a `ws` prefix, than your normal http endpoint: + +let webSocketURL = URL(string: "ws://localhost:8080/websocket")! +let webSocketTransport = WebSocketTransport(request: URLRequest(url: webSocketURL)) + +//: Then, set up the split transport with the two transports you've just created: + +let splitTransport = SplitNetworkTransport(httpNetworkTransport: normalTransport, webSocketNetworkTransport: webSocketTransport) + +//: Finally, instantiate your client with the split transport: + +let client = ApolloClient(networkTransport: splitTransport) + +/*: + ### Creating a subscription + + Any `.graphql` files with a `subscription` in them will cause a subscription object to be generated. Instantiate that object to create the subscription: + */ + +let subscription = ReviewAddedSubscription() + +//: We'll create a couple vars here to help keep track of how many times we want to do this: + +var resultsReceived = 0 +var loops = 5 + +//: Then, start your subscription, and add a closure that you want to have called every time the web socket receives a message for that subscription: +client.subscribe(subscription: subscription) { result in + print() + switch result { + case .success(let graphQLResult): + if let errors = graphQLResult.errors { + print("Subscription graphQL errors: \(errors)") + } + + if let review = graphQLResult.data?.reviewAdded { + print("--- Got review from subscription! ---") + print("Episode: \(review.episode?.rawValue ?? "(n/a)")") + print("Stars: \(review.stars)") + print("Commentary: \(review.commentary ?? "none:")") + } + case .failure(let error): + // If this happens, something's gone wrong either at the network level before the GraphQL server could respond, or parsing has failed completely at the WebSocket level. + print("Subscription network error: \(error)") + } + + resultsReceived += 1 + + if let episode = subscription.episode { + // If your subscription has specified an episode, only reviews for that episode should come in. + if resultsReceived == loops { + print("\nGot \(loops) \(episode.rawValue) reviews, finishing execution") + PlaygroundPage.current.finishExecution() + } + } else { + // If you did not specify an episode, you'll get all reviews for all episodes. + let expectedTotalReviews = loops * Episode.allCases.count + if resultsReceived == expectedTotalReviews { + print("\nGot \(expectedTotalReviews) reviews of all episodes, finishing execution") + PlaygroundPage.current.finishExecution() + } + } +} + +/*: +### Sending data to the subscription + +Now that the subscription is listening for new reviews, let's add a bunch! We'll make a bunch of loops over every episode, to post reviews for a bunch of different episodes: +*/ + +for _ in 0.. + + + + + + + + \ No newline at end of file diff --git a/Sources/ApolloCodegenLib/FileFinder.swift b/Sources/ApolloCodegenLib/FileFinder.swift index ecf11a615e..85076fdc37 100644 --- a/Sources/ApolloCodegenLib/FileFinder.swift +++ b/Sources/ApolloCodegenLib/FileFinder.swift @@ -2,7 +2,7 @@ import Foundation public struct FileFinder { - public static func findParentFolder(from filePath: StaticString = #file) -> URL { + public static func findParentFolder(from filePath: StaticString = #filePath) -> URL { self.findParentFolder(from: filePath.apollo.toString) } diff --git a/Sources/ApolloTestSupport/XCTAssertHelpers.swift b/Sources/ApolloTestSupport/XCTAssertHelpers.swift index 9c1040df6a..48bc0d6e60 100644 --- a/Sources/ApolloTestSupport/XCTAssertHelpers.swift +++ b/Sources/ApolloTestSupport/XCTAssertHelpers.swift @@ -1,7 +1,7 @@ import XCTest @testable import Apollo -public func XCTAssertEqual(_ expression1: @autoclosure () throws -> [T : U]?, _ expression2: @autoclosure () throws -> [T : U]?, file: StaticString = #file, line: UInt = #line) rethrows { +public func XCTAssertEqual(_ expression1: @autoclosure () throws -> [T : U]?, _ expression2: @autoclosure () throws -> [T : U]?, file: StaticString = #filePath, line: UInt = #line) rethrows { let optionalValue1 = try expression1() let optionalValue2 = try expression2() @@ -19,7 +19,7 @@ public func XCTAssertEqual(_ expression1: @autoclosure () throws -> [T : U } } -public func XCTAssertMatch(_ valueExpression: @autoclosure () throws -> Pattern.Base, _ patternExpression: @autoclosure () throws -> Pattern, file: StaticString = #file, line: UInt = #line) rethrows { +public func XCTAssertMatch(_ valueExpression: @autoclosure () throws -> Pattern.Base, _ patternExpression: @autoclosure () throws -> Pattern, file: StaticString = #filePath, line: UInt = #line) rethrows { let value = try valueExpression() let pattern = try patternExpression() diff --git a/Tests/ApolloCacheDependentTests/FetchQueryTests.swift b/Tests/ApolloCacheDependentTests/FetchQueryTests.swift index fe2444a56a..641f01b972 100644 --- a/Tests/ApolloCacheDependentTests/FetchQueryTests.swift +++ b/Tests/ApolloCacheDependentTests/FetchQueryTests.swift @@ -465,7 +465,7 @@ class FetchQueryTests: XCTestCase, CacheTesting { group.enter() DispatchQueue.global().async { - _ = client1.clearCache() { _ in + client1.clearCache() { _ in group.leave() } } diff --git a/Tests/ApolloCodegenTests/CLIExtractorTests.swift b/Tests/ApolloCodegenTests/CLIExtractorTests.swift index 6a2540993f..5f41a6394f 100644 --- a/Tests/ApolloCodegenTests/CLIExtractorTests.swift +++ b/Tests/ApolloCodegenTests/CLIExtractorTests.swift @@ -19,7 +19,7 @@ class CLIExtractorTests: XCTestCase { private func checkSHASUMFileContentsDirectly(at url: URL, match expected: String, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) { guard let contents = try? String(contentsOf: url, encoding: .utf8) else { XCTFail("Could not load file at \(url.path)", @@ -38,7 +38,7 @@ class CLIExtractorTests: XCTestCase { private func validateSHASUMFile(shouldBeValid: Bool, apolloFolderURL: URL, match expected: String, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) { do { let isValid = try CLIExtractor.validateSHASUMInExtractedFile(apolloFolderURL: apolloFolderURL, expected: expected) @@ -53,7 +53,7 @@ class CLIExtractorTests: XCTestCase { } } - func validateCLIIsExtractedWithRealSHASUM(file: StaticString = #file, + func validateCLIIsExtractedWithRealSHASUM(file: StaticString = #filePath, line: UInt = #line) { let binaryFolderURL = CodegenTestHelper.binaryFolderURL() XCTAssertTrue(FileManager.default.apollo.folderExists(at: binaryFolderURL), diff --git a/Tests/ApolloCodegenTests/CodegenTestHelper.swift b/Tests/ApolloCodegenTests/CodegenTestHelper.swift index 296a9f2f65..04ba8295c1 100644 --- a/Tests/ApolloCodegenTests/CodegenTestHelper.swift +++ b/Tests/ApolloCodegenTests/CodegenTestHelper.swift @@ -25,7 +25,7 @@ struct CodegenTestHelper { } static func handleFileLoadError(_ error: Error, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) { let nsError = error as NSError if let underlying = nsError.userInfo["NSUnderlyingError"] as? NSError, @@ -95,7 +95,7 @@ struct CodegenTestHelper { .appendingPathComponent("Output") } - static func deleteExistingOutputFolder(file: StaticString = #file, + static func deleteExistingOutputFolder(file: StaticString = #filePath, line: UInt = #line) { do { let outputFolderURL = self.outputFolderURL() @@ -107,7 +107,7 @@ struct CodegenTestHelper { } } - static func downloadCLIIfNeeded(file: StaticString = #file, + static func downloadCLIIfNeeded(file: StaticString = #filePath, line: UInt = #line) { do { let cliFolderURL = self.cliFolderURL() @@ -119,7 +119,7 @@ struct CodegenTestHelper { } } - static func deleteExistingApolloFolder(file: StaticString = #file, + static func deleteExistingApolloFolder(file: StaticString = #filePath, line: UInt = #line) { do { let apolloFolderURL = self.apolloFolderURL() diff --git a/Tests/ApolloCodegenTests/LineByLineComparison.swift b/Tests/ApolloCodegenTests/LineByLineComparison.swift index 8800e54d1e..0cbe5a8f31 100644 --- a/Tests/ApolloCodegenTests/LineByLineComparison.swift +++ b/Tests/ApolloCodegenTests/LineByLineComparison.swift @@ -23,7 +23,7 @@ struct LineByLineComparison { static func between(received: String, expectedFileURL: URL, trimImports: Bool = false, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) { guard FileManager.default.apollo.fileExists(at: expectedFileURL) else { XCTFail("File not found at \(expectedFileURL)", @@ -65,7 +65,7 @@ struct LineByLineComparison { /// - line: The line where this function is being called. Defaults to the direct caller static func between(received: String, expected: String, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) { let receivedLines = received.components(separatedBy: "\n") diff --git a/Tests/ApolloTests/AutomaticPersistedQueriesTests.swift b/Tests/ApolloTests/AutomaticPersistedQueriesTests.swift index 3c6f08b9be..2dfaa8f57a 100644 --- a/Tests/ApolloTests/AutomaticPersistedQueriesTests.swift +++ b/Tests/ApolloTests/AutomaticPersistedQueriesTests.swift @@ -13,7 +13,7 @@ class AutomaticPersistedQueriesTests: XCTestCase { query: HeroNameQuery, queryDocument: Bool = false, persistedQuery: Bool = false, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) throws { guard @@ -85,7 +85,7 @@ class AutomaticPersistedQueriesTests: XCTestCase { mutation: CreateAwesomeReviewMutation, queryDocument: Bool = false, persistedQuery: Bool = false, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) throws { guard @@ -146,7 +146,7 @@ class AutomaticPersistedQueriesTests: XCTestCase { query: HeroNameQuery, queryDocument: Bool = false, persistedQuery: Bool = false, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) throws { let url = try XCTUnwrap(request.url, "URL not valid", diff --git a/Tests/ApolloTests/HTTPTransportTests.swift b/Tests/ApolloTests/HTTPTransportTests.swift index 3ccc3f0a9b..2fbe545ae0 100644 --- a/Tests/ApolloTests/HTTPTransportTests.swift +++ b/Tests/ApolloTests/HTTPTransportTests.swift @@ -37,7 +37,7 @@ class HTTPTransportTests: XCTestCase { private func validateHeroNameQueryResponse(result: Result, Error>, expectation: XCTestExpectation, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) { defer { expectation.fulfill() diff --git a/Tests/ApolloTests/RequestCreatorTests.swift b/Tests/ApolloTests/RequestCreatorTests.swift index 7aafca3015..18ea9c2ce5 100644 --- a/Tests/ApolloTests/RequestCreatorTests.swift +++ b/Tests/ApolloTests/RequestCreatorTests.swift @@ -17,7 +17,7 @@ class RequestCreatorTests: XCTestCase { private func checkString(_ string: String, includes expectedString: String, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) { XCTAssertTrue(string.contains(expectedString), "Expected string:\n\n\(expectedString)\n\ndid not appear in string\n\n\(string)", diff --git a/Tests/ApolloTests/UploadTests.swift b/Tests/ApolloTests/UploadTests.swift index 3f1010c236..276f0118cb 100644 --- a/Tests/ApolloTests/UploadTests.swift +++ b/Tests/ApolloTests/UploadTests.swift @@ -23,7 +23,7 @@ class UploadTests: XCTestCase { private func compareInitialFile(at initialFileURL: URL, toUploadedFileAt path: String?, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line) { guard let path = path else { XCTFail("Path was nil!",