Skip to content

Instantly share code, notes, and snippets.

@J-Swift
Created September 6, 2018 18:27
Show Gist options
  • Save J-Swift/6ababe2dc12efa6a9b5d49ed4ae86584 to your computer and use it in GitHub Desktop.
Save J-Swift/6ababe2dc12efa6a9b5d49ed4ae86584 to your computer and use it in GitHub Desktop.
Get swift toolchain id from toolchain download name
#!/usr/bin/env bash
readonly target_swift_toolchain_name='swift-4.1.3-RELEASE.xctoolchain'
readonly toolchain_plist_file_path="/Library/Developer/Toolchains/${target_swift_toolchain_name}/Info.plist"
if [ ! -f "${toolchain_plist_file_path}" ]; then
echo
echo "ERROR: no toolchain found at [${toolchain_plist_file_path}]"
exit 1
fi
grep -A 1 'CFBundleIdentifier' "${toolchain_plist_file_path}" | tail -1 \
| sed 's/\<string\>//' | sed 's/\<\/string\>//' \
| grep -Eo '\S+'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment