Skip to content

Commit a2e2e4a

Browse files
committed
chore: update apollo.podspec to use xcframework
1 parent bb49ff5 commit a2e2e4a

File tree

39 files changed

+226
-111
lines changed

39 files changed

+226
-111
lines changed

Apollo.podspec

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,30 @@
1-
Pod::Spec.new do |s|
2-
s.name = 'Apollo'
3-
s.version = `scripts/get-version.sh`
4-
s.author = 'Apollo GraphQL'
5-
s.homepage = 'https://github.com/apollographql/apollo-ios'
6-
s.license = { :type => 'MIT', :file => 'LICENSE' }
7-
s.summary = "A GraphQL client for iOS, written in Swift."
8-
s.source = { :git => 'https://github.com/apollographql/apollo-ios.git', :tag => s.version }
9-
s.requires_arc = true
10-
s.swift_version = '5.6'
11-
s.default_subspecs = 'Core'
12-
s.ios.deployment_target = '12.0'
13-
s.osx.deployment_target = '10.14'
14-
s.tvos.deployment_target = '12.0'
15-
s.watchos.deployment_target = '5.0'
16-
s.visionos.deployment_target = '1.0'
17-
18-
cli_binary_name = 'apollo-ios-cli'
19-
s.preserve_paths = [cli_binary_name]
20-
s.prepare_command = <<-CMD
21-
make unpack-cli
22-
CMD
23-
24-
s.subspec 'Core' do |ss|
25-
ss.source_files = 'Sources/Apollo/**/*.swift','Sources/ApolloAPI/**/*.swift'
26-
ss.resource_bundles = {'Apollo' => ['Sources/Apollo/Resources/PrivacyInfo.xcprivacy']}
27-
end
28-
29-
# Apollo provides exactly one persistent cache out-of-the-box, as a reasonable default choice for
30-
# those who require cache persistence. Third-party caches may use different storage mechanisms.
31-
s.subspec 'SQLite' do |ss|
32-
ss.source_files = 'Sources/ApolloSQLite/*.swift'
33-
ss.dependency 'Apollo/Core'
34-
ss.resource_bundles = {
35-
'ApolloSQLite' => ['Sources/ApolloSQLite/Resources/PrivacyInfo.xcprivacy']
36-
}
37-
end
38-
39-
# Websocket and subscription support based on Starscream
40-
s.subspec 'WebSocket' do |ss|
41-
ss.source_files = 'Sources/ApolloWebSocket/**/*.swift'
42-
ss.dependency 'Apollo/Core'
43-
ss.resource_bundles = {
44-
'ApolloWebSocket' => ['Sources/ApolloWebSocket/Resources/PrivacyInfo.xcprivacy']
45-
}
46-
end
47-
1+
Pod::Spec.new do |spec|
2+
spec.name = "Apollo"
3+
spec.version = "0.0.1"
4+
spec.summary = "Apollo iOS XCFrameworks"
5+
spec.description = "Precompiled Apollo iOS frameworks for GraphQL client"
6+
7+
spec.homepage = "https://github.com/runna-app/apollo-ios"
8+
spec.license = { :type => "MIT" }
9+
spec.author = { "Runna" => "dev@runna.com" }
10+
11+
spec.platform = :ios, "15.0"
12+
13+
spec.source = { :path => "." }
14+
15+
spec.vendored_frameworks = [
16+
'Apollo.xcframework',
17+
'ApolloSQLite.xcframework',
18+
'ApolloAPI.xcframework',
19+
]
20+
21+
# Ensure the frameworks are preserved during installation
22+
spec.preserve_paths = [
23+
'Apollo.xcframework',
24+
'ApolloSQLite.xcframework',
25+
'ApolloAPI.xcframework',
26+
]
27+
28+
# Add any required system frameworks
29+
spec.frameworks = 'Foundation'
4830
end

ApolloTestSupport.podspec

Whitespace-only changes.

Package.XCFramework.swift

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// swift-tools-version:5.9
2+
//
3+
// The swift-tools-version declares the minimum version of Swift required to build this package.
4+
// Swift 5.9 is available from Xcode 15.0.
5+
//
6+
// This is an alternative Package.swift that uses precompiled XCFrameworks from the artifacts folder.
7+
// To use this instead of the source-based Package.swift:
8+
// 1. Build the XCFrameworks using: make xcframeworks
9+
// 2. Rename this file to Package.swift (and backup the original)
10+
// 3. Update your package dependencies
11+
12+
import PackageDescription
13+
14+
let package = Package(
15+
name: "Apollo",
16+
platforms: [
17+
.iOS(.v17),
18+
.watchOS(.v11),
19+
],
20+
products: [
21+
.library(name: "Apollo", targets: ["Apollo"]),
22+
.library(name: "ApolloAPI", targets: ["ApolloAPI"]),
23+
.library(name: "ApolloSQLite", targets: ["ApolloSQLite"]),
24+
],
25+
dependencies: [
26+
],
27+
targets: [
28+
.binaryTarget(
29+
name: "Apollo",
30+
path: "artifacts/Apollo.xcframework"
31+
),
32+
.binaryTarget(
33+
name: "ApolloAPI",
34+
path: "artifacts/ApolloAPI.xcframework"
35+
),
36+
.binaryTarget(
37+
name: "ApolloSQLite",
38+
path: "artifacts/ApolloSQLite.xcframework"
39+
),
40+
]
41+
)

XCFRAMEWORK_USAGE.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Using Apollo iOS with XCFrameworks
2+
3+
This project supports two ways to integrate Apollo iOS into your project:
4+
5+
## Option 1: Source-Based Installation (Default)
6+
7+
Use the standard `Package.swift` file which builds Apollo from source. This is the default and recommended approach for most users.
8+
9+
**Pros:**
10+
- Full source code available for debugging
11+
- Works with all platforms (iOS, macOS, tvOS, watchOS, visionOS)
12+
- Automatic updates through Swift Package Manager
13+
14+
**Supported Platforms:**
15+
- iOS 12.0+
16+
- macOS 10.14+
17+
- tvOS 12.0+
18+
- watchOS 5.0+
19+
- visionOS 1.0+
20+
21+
## Option 2: Precompiled XCFramework Installation
22+
23+
Use the `Package.XCFramework.swift` file which uses precompiled binary XCFrameworks for faster build times.
24+
25+
**Pros:**
26+
- Significantly faster build times
27+
- Smaller project compilation overhead
28+
- Pre-optimized binaries
29+
30+
**Cons:**
31+
- Limited to iOS 17.0+ and watchOS 11.0+
32+
- Requires building XCFrameworks first
33+
- No source code debugging
34+
35+
**Supported Platforms:**
36+
- iOS 17.0+
37+
- watchOS 11.0+
38+
39+
### How to Use XCFrameworks
40+
41+
1. **Build the XCFrameworks:**
42+
```bash
43+
make xcframeworks
44+
```
45+
This will create XCFrameworks for Apollo, ApolloAPI, and ApolloSQLite in the `artifacts/` folder.
46+
47+
2. **Switch to XCFramework Package:**
48+
```bash
49+
# Backup the original Package.swift
50+
mv Package.swift Package.Source.swift
51+
52+
# Use the XCFramework version
53+
mv Package.XCFramework.swift Package.swift
54+
```
55+
56+
3. **Use in your project:**
57+
Add the dependency to your project's `Package.swift` as usual:
58+
```swift
59+
dependencies: [
60+
.package(path: "../path/to/apollo-ios")
61+
]
62+
```
63+
64+
4. **Switch back to source-based (if needed):**
65+
```bash
66+
mv Package.swift Package.XCFramework.swift
67+
mv Package.Source.swift Package.swift
68+
```
69+
70+
## Available Libraries
71+
72+
Both installation methods provide the following libraries:
73+
74+
- **Apollo**: The core Apollo iOS client
75+
- **ApolloAPI**: Apollo's GraphQL type system
76+
- **ApolloSQLite**: SQLite normalized cache implementation
77+
- **ApolloWebSocket**: WebSocket transport (source-based only)
78+
- **ApolloTestSupport**: Testing utilities (source-based only)
79+
80+
## Choosing the Right Option
81+
82+
- **Use source-based** if you need:
83+
- Support for macOS, tvOS, or visionOS
84+
- Access to ApolloWebSocket or ApolloTestSupport
85+
- Support for older OS versions
86+
- Source-level debugging
87+
88+
- **Use XCFramework** if you:
89+
- Only target iOS 17+ and/or watchOS 11+
90+
- Want faster build times
91+
- Prefer smaller project compilation overhead
92+
- Only need Apollo, ApolloAPI, and ApolloSQLite

artifacts/Apollo.xcframework.sha256

Lines changed: 0 additions & 1 deletion
This file was deleted.

artifacts/Apollo.xcframework.zip

-3 Bytes
Binary file not shown.

artifacts/Apollo.xcframework/Info.plist

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,64 @@
88
<key>BinaryPath</key>
99
<string>Apollo.framework/Apollo</string>
1010
<key>LibraryIdentifier</key>
11-
<string>ios-arm64_x86_64-simulator</string>
11+
<string>watchos-arm64_arm64_32</string>
1212
<key>LibraryPath</key>
1313
<string>Apollo.framework</string>
1414
<key>SupportedArchitectures</key>
1515
<array>
1616
<string>arm64</string>
17-
<string>x86_64</string>
17+
<string>arm64_32</string>
1818
</array>
1919
<key>SupportedPlatform</key>
20-
<string>ios</string>
21-
<key>SupportedPlatformVariant</key>
22-
<string>simulator</string>
20+
<string>watchos</string>
2321
</dict>
2422
<dict>
2523
<key>BinaryPath</key>
2624
<string>Apollo.framework/Apollo</string>
2725
<key>LibraryIdentifier</key>
28-
<string>watchos-arm64_x86_64-simulator</string>
26+
<string>ios-arm64</string>
2927
<key>LibraryPath</key>
3028
<string>Apollo.framework</string>
3129
<key>SupportedArchitectures</key>
3230
<array>
3331
<string>arm64</string>
34-
<string>x86_64</string>
3532
</array>
3633
<key>SupportedPlatform</key>
37-
<string>watchos</string>
38-
<key>SupportedPlatformVariant</key>
39-
<string>simulator</string>
34+
<string>ios</string>
4035
</dict>
4136
<dict>
4237
<key>BinaryPath</key>
4338
<string>Apollo.framework/Apollo</string>
4439
<key>LibraryIdentifier</key>
45-
<string>watchos-arm64_arm64_32</string>
40+
<string>watchos-arm64_x86_64-simulator</string>
4641
<key>LibraryPath</key>
4742
<string>Apollo.framework</string>
4843
<key>SupportedArchitectures</key>
4944
<array>
5045
<string>arm64</string>
51-
<string>arm64_32</string>
46+
<string>x86_64</string>
5247
</array>
5348
<key>SupportedPlatform</key>
5449
<string>watchos</string>
50+
<key>SupportedPlatformVariant</key>
51+
<string>simulator</string>
5552
</dict>
5653
<dict>
5754
<key>BinaryPath</key>
5855
<string>Apollo.framework/Apollo</string>
5956
<key>LibraryIdentifier</key>
60-
<string>ios-arm64</string>
57+
<string>ios-arm64_x86_64-simulator</string>
6158
<key>LibraryPath</key>
6259
<string>Apollo.framework</string>
6360
<key>SupportedArchitectures</key>
6461
<array>
6562
<string>arm64</string>
63+
<string>x86_64</string>
6664
</array>
6765
<key>SupportedPlatform</key>
6866
<string>ios</string>
67+
<key>SupportedPlatformVariant</key>
68+
<string>simulator</string>
6969
</dict>
7070
</array>
7171
<key>CFBundlePackageType</key>
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)