Last active
January 4, 2019 12:45
-
-
Save drkibitz/8ba180b5be697f872faefb0ef15b0634 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## Source in Xcode Run Script Phase | |
## | |
set -e | |
CARTHAGE=$(command -v carthage) | |
## | |
## Validate | |
## Does not assume Homebrew, but suggest it. | |
## | |
if [ -z "${CARTHAGE}" ]; then | |
echo >&2 "error: The 'carthage' command was not found, please install it and try again (ex. 'brew install carthage'). Aborting." | |
exit 1 | |
fi | |
## | |
## Bootstrap | |
## Warns of outdated dependencies after bootstrap. | |
## | |
if [ -d "${SRCROOT}/Carthage/Checkouts" ]; then | |
"${CARTHAGE}" outdated --project-directory "${SRCROOT}" --xcode-warnings --verbose | |
else | |
"${CARTHAGE}" bootstrap --project-directory "${SRCROOT}" --no-build --verbose | |
fi | |
## | |
## Build | |
## env -i is a work around for https://github.com/Carthage/Carthage/issues/2613 | |
## Should be able to simply execute carthage, but that is a bug introduced with Xcode 10. | |
## | |
#CARTHAGE_BUILD_STATIC="1" | |
if [ "${CARTHAGE_BUILD_STATIC}" = "1" ]; then | |
echo "Carthage building static..." | |
## | |
## Temp xcconfig to override build dependencies to build static | |
## No embedding needed, just linking in the project | |
## | |
xcconfig="$(mktemp /tmp/static.xcconfig.XXXXXX)" | |
trap 'rm -f "${xcconfig}"' INT TERM HUP EXIT | |
## Xcode officially supports it now, no need for libtool! | |
echo "MACH_O_TYPE = staticlib" >> "${xcconfig}" | |
## No need for a dSYM file for static builds | |
echo "DEBUG_INFORMATION_FORMAT = dwarf" >> "${xcconfig}" | |
## Needed for depenencies to find their depenencies | |
echo "FRAMEWORK_SEARCH_PATHS = \$(inherited) ${SRCROOT}/Carthage/Build/iOS/Static" >> "${xcconfig}" | |
env -i XCODE_XCCONFIG_FILE="${xcconfig}" "${CARTHAGE}" build --project-directory "${SRCROOT}" --platform "${PLATFORM_NAME}" --no-use-binaries --cache-builds --verbose | |
else | |
echo "Carthage building dynamic..." | |
rm -fR "${SRCROOT}/Carthage/Build/iOS/Static" | |
env -i "${CARTHAGE}" build --project-directory "${SRCROOT}" --platform "${PLATFORM_NAME}" --cache-builds --verbose | |
## | |
## Embed | |
## Requires runscript input and output files. | |
## | |
"${CARTHAGE}" copy-frameworks | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment