Created
November 22, 2016 06:26
-
-
Save banjun/166045c994d07b9e67df9357ff6418f3 to your computer and use it in GitHub Desktop.
Generate Swift CLI executable from Xcode target, with CocoaPods Frameworks and Swift stdlibs, without statically linked with the stdlibs
This file contains 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
FRAMEWORK_ARG=$(for f in $(echo "${FRAMEWORK_SEARCH_PATHS}"); do echo -n "-F$f "; done) | |
RUNPATH_ARG=$(for p in $(echo $LD_RUNPATH_SEARCH_PATHS); do echo -n "-Xlinker -rpath -Xlinker $p "; done) | |
LD="${DT_TOOLCHAIN_DIR}/usr/bin/clang -arch ${arch} -isysroot ${SDKROOT} -L${CONFIGURATION_BUILD_DIR} ${FRAMEWORK_ARG} -filelist ${LINK_FILE_LIST_normal_x86_64} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} ${RUNPATH_ARG} -fobjc-link-runtime -L${DT_TOOLCHAIN_DIR}/usr/lib/swift/macosx -lc++ -framework Foundation -Xlinker -add_ast_path -Xlinker ${OBJECT_FILE_DIR_normal}/${arch}/${EXECUTABLE_NAME}.swiftmodule -Xlinker -dependency_info -Xlinker ${LD_DEPENDENCY_INFO_FILE} -o ${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME}" | |
echo "$LD" | |
zsh -c "$LD" | |
mkdir -p "${CONFIGURATION_BUILD_DIR}/Frameworks" | |
for f in ${CONFIGURATION_BUILD_DIR}/*/*.framework; do | |
cp -r "$f" "${CONFIGURATION_BUILD_DIR}/Frameworks/" | |
done | |
xcrun swift-stdlib-tool --copy --platform macosx --scan-folder ${CONFIGURATION_BUILD_DIR} --destination ${CONFIGURATION_BUILD_DIR}/Frameworks/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
alternative for LD:
SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES