Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit b78c6af

Browse files
documentation: add more documentation around macOS builds (#1165)
* documentation: add more documentation around macOS builds Building on macOS is a bit more complicated as the toolchain selection is reliant on Xcode environment variables. This documents how to query the toolchain identifier and use that to build the Swift APIs package. * Update Documentation/Development.md Co-authored-by: Michelle Casbon <texasmichelle@users.noreply.github.com> Co-authored-by: Michelle Casbon <texasmichelle@users.noreply.github.com>
1 parent 9a1b625 commit b78c6af

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Documentation/Development.md

+17
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,23 @@ $ swift build -Xcc -I/Library/tensorflow-2.4.0/usr/include -Xlinker -L/Library/t
249249
$ swift test -Xcc -I/Library/tensorflow-2.4.0/usr/include -Xlinker -L/Library/tensorflow-2.4.0/usr/lib
250250
```
251251

252+
On macOS, in order to select the proper toolchain, the `TOOLCHAINS` environment
253+
variable can be used to modify the selected Xcode toolchain temporarily. The
254+
macOS (Xcode) toolchain distributed from [swift.org](https://swift.org) has a
255+
bundle identifier which can uniquely identify the toolchain to the system. The
256+
following attempts to determine the latest toolchain snapshot and extract the
257+
identifier for it.
258+
259+
```shell
260+
xpath 2>/dev/null $(find /Library/Developer/Toolchains ~/Library/Developer/Toolchains -type d -depth 1 -regex '.*/swift-DEVELOPMENT-SNAPSHOT-.*.xctoolchain | sort -u | tail -n 1)/Info.plist "/plist/dict/key[. = 'CFBundleIdentifier']/following-sibling::string[1]//text()"
261+
```
262+
263+
This allows one to build the package as:
264+
265+
```shell
266+
TOOLCHAINS=$(xpath 2>/dev/null $(find /Library/Developer/Toolchains ~/Library/Developer/Toolchains -type d -depth 1 -regex '.*/swift-DEVELOPMENT-SNAPSHOT-.*.xctoolchain | sort -u | tail -n 1)/Info.plist "/plist/dict/key[. = 'CFBundleIdentifier']/following-sibling::string[1]//text()") swift build -Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN -Xcc -I/Library/tensorflow-2.4.0/usr/include -Xlinker -L/Library/tensorflow-2.4.0/usr/lib
267+
```
268+
252269
#### CMake
253270

254271
*Note: In-tree builds are not supported.*

0 commit comments

Comments
 (0)