Skip to content

Commit 01045b5

Browse files
Merge pull request #610 from apollographql/fix/script
Update documentation + Scripts for building
2 parents 80628f2 + 8088f40 commit 01045b5

File tree

3 files changed

+65
-25
lines changed

3 files changed

+65
-25
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Change log
22

3+
### v0.11.0
4+
5+
- **BREAKING**: Updated Podspec to preserve paths rather than embedding scripts in the framework. Updated instructions for embedding with CocoaPods. ([#575](https://github.com/apollographql/apollo-ios/pull/575), [#610](https://github.com/apollographql/apollo-ios/pull/610))
6+
- **NEW**: At long last, the ability to update headers on preflight requests, the ability to peer into what came to the `URLSession` and the ability to determine if an operation should be retried. ([#602](https://github.com/apollographql/apollo-ios/pull/602))
7+
- **NEW**: Added `.fetchIgnoringCacheCompletely` caching option, which can result in significantly faster performance if you don't need the caching. ([#551](https://github.com/apollographql/apollo-ios/pull/551))
8+
- **NEW**: Added support for using `GET` for queries. ([#572](https://github.com/apollographql/apollo-ios/pull/572), [#599](https://github.com/apollographql/apollo-ios/pull/599), [#602](https://github.com/apollographql/apollo-ios/pull/602))
9+
- Updated lib and dependencies to use Swift 5, and say so in the Podfile. ([#522](https://github.com/apollographql/apollo-ios/pull/522), [#528](https://github.com/apollographql/apollo-ios/pull/528), [#561](https://github.com/apollographql/apollo-ios/pull/561), [#592](https://github.com/apollographql/apollo-ios/pull/592))
10+
- Exposed a method to ping a WebSocket server to keep it alive. ([#422](https://github.com/apollographql/apollo-ios/pull/422))
11+
- Handling is always done on a handler queue. ([#539](https://github.com/apollographql/apollo-ios/pull/539))
12+
- Added documentation on the `read` and `update` operations for watching queries. ([#452](https://github.com/apollographql/apollo-ios/pull/452))
13+
- Updated build scripts for non-CocoaPods installations to account for spaces in project names or folders. ([#610](https://github.com/apollographql/apollo-ios/pull/610))
14+
- Fixed a code generation fail if you're using MacPorts instead of Homebrew to install `npm`. ([#591](https://github.com/apollographql/apollo-ios/pull/591))
15+
316
### v0.10.1
417

518
- Disabled bitcode in Debug builds for physical devices ([#499](https://github.com/apollographql/apollo-ios/pull/499))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CURRENT_PROJECT_VERSION = 0.10.2
1+
CURRENT_PROJECT_VERSION = 0.11.0

docs/source/installation.md

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Apollo iOS requires the latest Xcode, which can be installed from the [Mac App S
77
Follow along with these steps (described in detail below) to use Apollo iOS in your app:
88

99
1. Install the Apollo framework into your project and link it to your application target
10-
1. Add a code generation build step to your target
1110
1. Add a schema file to your target directory
11+
1. Add a code generation build step to your target
1212
1. Build your target
1313
1. Add the generated API file to your target
1414
1. Install the Xcode add-ons to get syntax highlighting for your `.graphql` files (optional)
@@ -41,7 +41,7 @@ You can install `Apollo.framework` into your project using Carthage, CocoaPods,
4141

4242
### CocoaPods
4343

44-
1. Because Apollo iOS has been written using Swift 3, it requires CocoaPods 1.1.0. You can install it using:
44+
1. Because Apollo iOS has been written using Swift 5, you need to use version `1.5.0` or higher. You can install CocoaPods using:
4545

4646
```sh
4747
gem install cocoapods
@@ -57,46 +57,73 @@ You can install `Apollo.framework` into your project using Carthage, CocoaPods,
5757

5858
You can also manually clone the [`apollo-ios` repository](https://github.com/apollostack/apollo-ios), drag `Apollo.xcodeproj` into your project or workspace, add a dependency on `Apollo.framework` to your target.
5959

60+
## Adding a schema file to your target directory
61+
62+
You'll have to copy or [download a schema](/downloading-schema/) to your target directory before generating code.
63+
64+
Apollo iOS requires a GraphQL schema file as input to the code generation process. A schema file is a JSON file that contains the results of an an introspection query. Conventionally this file is called `schema.json`.
65+
66+
6067
## Adding a code generation build step
6168

62-
In order to invoke `apollo` as part of the Xcode build process, create a build step that runs before "Compile Sources".
69+
In order to invoke `apollo` as part of the Xcode build process, create a build step that runs before "Compile Sources" to invoke `apollo` through the `check-and-run-apollo-cli.sh` wrapper script.
6370

64-
1. On your application targets’ "Build Phases" settings tab, click the "+" icon and choose "New Run Script Phase". Create a Run Script, change its name to "Generate Apollo GraphQL API" and drag it just above "Compile Sources". Then add the following contents to the script area below the shell:
71+
The main reason for calling the wrapper is to check whether the version of `apollo` installed on your system is compatible with the framework version installed in your project, and to warn you if it isn't. Without this check, you could end up generating code that is incompatible with the runtime code contained in the framework.
6572

66-
for iOS Project
67-
```sh
68-
APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"
73+
The location of this wrapper script is slightly different based on how you've integrated Apollo into you project, but the first steps are the same everywhere:
6974

70-
if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
71-
echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
72-
exit 1
73-
fi
75+
1. On your application target's **Build Phases** settings tab, click the **+** icon and choose **New Run Script Phase**.
76+
2. In the created Run Script, change its name to **Generate Apollo GraphQL API**
77+
3. Drag this new run script just above **Compile Sources** in your list of **Build Phases** so that it executes before your code is compiled.
78+
4. Add the appropriate contents to the run script from the options below.
7479

80+
### If you ARE integrating Apollo using CocoaPods
81+
82+
Our CocoaPods install includes the code-generation script as a file which will not be added to the framework. Since this is always installed in a consistent place, you can use the same path to it. Add the following to the Run Script:
83+
84+
```sh
85+
SCRIPT_PATH="${PODS_ROOT}/Apollo/scripts"
7586
cd "${SRCROOT}/${TARGET_NAME}"
76-
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift
87+
"${SCRIPT_PATH}"/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift
7788
```
78-
for macOS Project
89+
90+
### If you're NOT integrating Apollo using CocoaPods
91+
92+
In this case, the `check-and-run-apollo-cli.sh` file is bundled into the framework. The procedures to call it are slightly different based on whether you're using an iOS or macOS target because of the way the frameworks are compiled.
93+
94+
📱 For an **iOS** target or a **Cocoa Touch Framework**, use the following:
95+
7996
```sh
80-
APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"
97+
# Do some magic so we can make sure `FRAMEWORK_SEARCH_PATHS` works correctly when there's a space in the scheme or the folder name.
98+
QUOTED_FRAMEWORK_SEARCH_PATHS=\"$(echo $FRAMEWORK_SEARCH_PATHS | tr -d '"' | sed -e 's/ \//" "\//g')\"
8199

82-
if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
83-
echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
84-
exit 1
100+
APOLLO_FRAMEWORK_PATH ="$(eval find ${QUOTED_FRAMEWORK_SEARCH_PATHS} -name "Apollo.framework" -maxdepth 1)"
101+
102+
if [ -z "${APOLLO_FRAMEWORK_PATH}" ]; then
103+
echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
104+
exit 1
85105
fi
86106

87107
cd "${SRCROOT}/${TARGET_NAME}"
88-
$APOLLO_FRAMEWORK_PATH/Versions/Current/Resources/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift
108+
"${APOLLO_FRAMEWORK_PATH}"/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift
89109
```
90110

111+
💻 For a **macOS** or a **Cocoa Framework** target, use the following:
91112

113+
```sh
114+
# Do some magic so we can make sure `FRAMEWORK_SEARCH_PATHS` works correctly when there's a space in the scheme or the folder name.
115+
QUOTED_FRAMEWORK_SEARCH_PATHS=\"$(echo $FRAMEWORK_SEARCH_PATHS | tr -d '"' | sed -e 's/ \//" "\//g')\"
92116

93-
The script above will invoke `apollo` through the `check-and-run-apollo-cli.sh` wrapper script, which is actually contained in the `Apollo.framework` bundle. The main reason for this is to check whether the version of `apollo` installed on your system is compatible with the framework version installed in your project, and to warn you if it isn't. Without this check, you could end up generating code that is incompatible with the runtime code contained in the framework.
117+
APOLLO_FRAMEWORK_PATH="$(eval find ${QUOTED_FRAMEWORK_SEARCH_PATHS} -name "Apollo.framework" -maxdepth 1)"
94118

95-
## Adding a schema file to your target directory
96-
97-
You'll have to copy or [download a schema](/downloading-schema/) to your target directory before generating code.
119+
if [ -z "${APOLLO_FRAMEWORK_PATH}" ]; then
120+
echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
121+
exit 1
122+
fi
98123

99-
Apollo iOS requires a GraphQL schema file as input to the code generation process. A schema file is a JSON file that contains the results of an an introspection query. Conventionally this file is called `schema.json`.
124+
cd "${SRCROOT}/${TARGET_NAME}"
125+
"${APOLLO_FRAMEWORK_PATH}"/Versions/Current/Resources/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift
126+
```
100127

101128
## Build your target
102129

@@ -125,7 +152,7 @@ At this point, you can try building your target in Xcode. This will verify that
125152

126153
`cp -R GraphQL.xclangspec ~/Library/Developer/Xcode/Specifications`
127154

128-
You may receive a warning when you first start up Xcode after installing these add-ons.
155+
You may receive a warning the first time you start up Xcode after installing these add-ons - once you agree to load the plugin, you will no longer see this warning.
129156

130157
## Create `.graphql` files with your queries or mutations
131158

0 commit comments

Comments
 (0)