Apollo iOS 1.6 migration guide

From 1.5 to 1.6


This guide describes the process of migrating your code from version 1.5 to version 1.6 of Apollo iOS. Please follow the relevant migration guides if you're on a version other than 1.5.

Apollo Codegen SPM Package

The 1.6 update restructured the Apollo iOS ecosystem by splitting the code up into multiple different repositories/packages. One of these changes was the creation of the new apollo-ios-codegen repo and SPM package for users who want to do their code generation through Swift vs using the CLI tool.

Note: If you use the CLI tool for code generation, this change does not affect you. For more information on the project restructuring in the 1.6 release see this GitHub issue.

If you are doing your code generation through Swift you have something like the following in your Package.swift file:

Swift
Package.swift
1let package = Package(
2  name: "MyCodegen",
3  platforms: [.macOS(.v10_15)],
4  dependencies: [
5    .package(url: "https://github.com/apollographql/apollo-ios", exact: "1.5.0")
6  ],
7  targets: [
8    .executableTarget(
9      name: "MyCodegen",
10      dependencies: [
11        .product(name: "ApolloCodegenLib", package: "apollo-ios"),
12      ],
13      path: "Sources"),
14  ]
15)

In order to keep your code building successfully in the 1.6 release you will need to use the new apollo-ios-codegen package instead of the apollo-ios package:

Swift
Package.swift
1let package = Package(
2  name: "MyCodegen",
3  platforms: [.macOS(.v10_15)],
4  dependencies: [
5    .package(url: "https://github.com/apollographql/apollo-ios-codegen", exact: "1.6.0")
6  ],
7  targets: [
8    .executableTarget(
9      name: "MyCodegen",
10      dependencies: [
11        .product(name: "ApolloCodegenLib", package: "apollo-ios-codegen"),
12      ],
13      path: "Sources"),
14  ]
15)