Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit e6f0122

Browse files
authored
Merge pull request #316 from manicmaniac/update-readme
Update README
2 parents aa01060 + e1a9714 commit e6f0122

File tree

1 file changed

+34
-42
lines changed

1 file changed

+34
-42
lines changed

README.md

+34-42
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ Prerequisites
2727

2828
- Xcode `>= 12.0`
2929
- [Apollo iOS](https://github.com/apollographql/apollo-ios) `>= 0.34.0`, `< 0.38.0`
30-
- [Apollo Client Devtools](https://www.apollographql.com/docs/react/development-testing/developer-tooling/#apollo-client-devtools)
30+
- [Apollo Client Devtools](https://www.apollographql.com/docs/react/development-testing/developer-tooling/#apollo-client-devtools) `~> 2.0`
31+
32+
Compatibility
33+
-------------
34+
35+
If your are using `Apollo < 0.34.0`, use `ApolloDeveloperKit <= 0.15.0`.
3136

3237
Installation
3338
------------
@@ -52,7 +57,9 @@ github "apollographql/apollo-ios"
5257
github "manicmaniac/ApolloDeveloperKit"
5358
```
5459

55-
Then run `carthage update --platform iOS` or `carthage update --platform Mac`.
60+
Then run `carthage update --platform iOS --use-xcframeworks` or `carthage update --platform Mac --use-xcframeworks`.
61+
62+
You just need to drag and drop `ApolloDeveloperKit.xcframework` to your project.
5663

5764
### Swift Package Manager
5865

@@ -63,67 +70,52 @@ Since Xcode 12 has only limited support for resources installed via Swift Packag
6370
Setup
6471
-----
6572

66-
First, in order to hook Apollo's cache and network layer, you need to use `DebuggableNetworkTransport` and `DebuggableInMemoryNormalizedCache` instead of usual ones.
73+
First, you need to declare a long-lived variable where `ApolloDebugServer` belongs to, because as soon as you release the server, it stops running.
6774

68-
```swift
69-
let networkTransport = DebuggableNetworkTransport(networkTransport: HTTPNetworkTransport(url: url))
70-
let cache = DebuggableInMemoryNormalizedCache()
75+
The following code assumes you already have a procedure that instantiates `ApolloClient` in `AppDelegate`.
76+
77+
```
78+
class AppDelegate: UIResponder, UIApplicationDelegate {
79+
private var server: ApolloDebugServer!
80+
private var client: ApolloClient!
81+
}
7182
```
7283

73-
Second, instantiate `ApolloStore` and `ApolloClient` with debuggable ingredients.
84+
In order to hook Apollo's cache and network layer, you need to use `DebuggableRequestChainNetworkTransport` and `DebuggableNormalizedCache` instead of usual `RequestChainNetworkTransport` and `NormalizedCache`.
85+
86+
So the second step is to declare `ApolloStore` using `DebuggableNormalizedCache`.
87+
88+
Normally it should be put in the beginning of application, like `UIApplication.application(_:didFinishLaunchingWithOptions:)`.
7489

7590
```swift
91+
let cache = DebuggableNormalizedCache(cache: InMemoryNormalizedCache())
7692
let store = ApolloStore(cache: cache)
77-
let client = ApolloClient(networkTransport: networkTransport: store: store)
7893
```
7994

80-
Finally, create `ApolloDebugServer` and run.
95+
Third, configure network layer and instantiate `ApolloClient` with debuggable ingredients.
8196

8297
```swift
83-
let debugServer = ApolloDebugServer(cache: cache, networkTransport: networkTransport)
84-
self.debugServer = debugServer // Note: you need to retain debugServer's reference
85-
debugServer.start(port: 8081)
98+
let interceptorProvider = LegacyInterceptorProvider(store: store)
99+
let networkTransport = DebuggableRequestChainNetworkTransport(interceptorProvider: interceptorProvider, endpointURL: url)
100+
self.client = ApolloClient(networkTransport: networkTransport: store: store)
86101
```
87102

88-
Full example:
103+
Finally, create `ApolloDebugServer` and run.
89104

90105
```swift
91-
import Apollo
92-
import ApolloDeveloperKit
93-
import UIKit
94-
95-
@UIApplicationMain
96-
class AppDelegate: UIResponder, UIApplicationDelegate {
97-
var window: UIWindow?
98-
private var client: ApolloClient!
99-
private var debugServer: ApolloDebugServer?
100-
101-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
102-
let url = URL(string: "https://example.com/graphql")!
103-
#if DEBUG
104-
let networkTransport = DebuggableNetworkTransport(networkTransport: HTTPNetworkTransport(url: url))
105-
let cache = DebuggableNormalizedCache(cache: InMemoryNormalizedCache())
106-
let store = ApolloStore(cache: cache)
107-
client = ApolloClient(networkTransport: networkTransport, store: store)
108-
debugServer = ApolloDebugServer(networkTransport: networkTransport, cache: cache)
109-
do {
110-
try debugServer.start(port: 8081)
111-
} catch let error {
112-
print(error)
113-
}
114-
#else
115-
client = ApolloClient(url: url)
116-
#endif
117-
return true
118-
}
119-
}
106+
self.server = ApolloDebugServer(networkTransport: networkTransport, cache: cache)
107+
self.server.start(port: 8081)
120108
```
121109

110+
See `Example/{iOS,macOS}/AppDelegate.swift` for full examples.
111+
122112
Usage
123113
-----
124114

125115
**If you don't have [Apollo Client Developer Tools](https://www.apollographql.com/docs/react/development-testing/developer-tooling/#apollo-client-devtools), install it before proceeding the following steps.**
126116

117+
**Currently `ApolloDeveloperKit` supports only version 2.x of Apollo Client Developer Tools.**
118+
127119
1. Launch your app on your device or simulator.
128120
2. Open your browser and jump to the server's URL (in case your app runs the above example on a simulator, the URL would be `http://localhost:8081`).
129121
- You will see `ApolloDebugServer is running!` on your browser's tab.

0 commit comments

Comments
 (0)