Skip to content

Commit aee7fcd

Browse files
How to cach SPM dependencies (#3465)
How to cach SPM dependencies
1 parent d804045 commit aee7fcd

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

content/knowledge-codemagic/caching.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,38 @@ Xcode build logs can be gathered as artifacts by setting the path to the logs in
111111
artifacts:
112112
- /tmp/xcodebuild_logs/*.log
113113
{{< /highlight >}}
114+
115+
## Swift Package Manager caching
116+
117+
Swift Package Manager (SPM) is Apple's official dependency manager for Swift projects. By caching SPM dependencies in your workflow, subsequent builds can reuse previously fetched packages rather than downloading them again, resulting in faster build times.
118+
119+
You can cache the **global SPM cache** which is shared across all projects on the machine
120+
121+
{{< highlight yaml "style=paraiso-dark">}}
122+
cache:
123+
cache_paths:
124+
- ~/Library/Caches/org.swift.swiftpm
125+
{{< /highlight >}}
126+
127+
Alternatively, when building and exporting your `.ipa` with Codemagic's CLI tools you can cache **project level SPM dependencies** by setting the path to the `SourcePackages` directory as follows:
128+
129+
{{< highlight yaml "style=paraiso-dark">}}
130+
- name: Build ipa for distribution
131+
script: |
132+
xcode-project build-ipa \
133+
--project "$XCODE_PROJECT" \
134+
--scheme "$XCODE_SCHEME" \
135+
--archive-flags "-clonedSourcePackagesDirPath $CM_BUILD_DIR/SourcePackages"
136+
{{< /highlight >}}
137+
138+
You can then set your cache paths as follows:
139+
140+
{{< highlight yaml "style=paraiso-dark">}}
141+
cache:
142+
cache_paths:
143+
- $CM_BUILD_DIR/SourcePackages
144+
{{< /highlight >}}
145+
146+
147+
148+

0 commit comments

Comments
 (0)