Skip to content

Instantly share code, notes, and snippets.

@modocache

modocache/xctest.sh

Last active Feb 3, 2018
Embed
What would you like to do?
# It's relatively easy to run Apple XCTest on OS X and swift-corelibs-xctest on Linux.
# Just look at apple/swift-corelibs-foundation for an example.
#
# But it's pretty difficult to run swift-corelibs-xctest on OS X.
#
# Let's say we have the following file:
#
# // main.swift
# import XCTest
# XCTMain([])
#
# To compile this on Linux:
swiftc main.swift -o MyTest
# And to run:
./MyTest
# To compile this on OS X:
export BUILT_PRODUCTS_DIR=/Users/bgesiak/Library/Developer/Xcode/DerivedData/XCTest-bzxmivvccdrmtvctkfgutfkgbsze/Build/Products/Debug
xcrun -sdk `xcrun --sdk macosx --show-sdk-path` \
swiftc \
-target x86_64-apple-macosx10.11 \
-L$BUILT_PRODUCTS_DIR \
-I$BUILT_PRODUCTS_DIR \
-F$BUILT_PRODUCTS_DIR \
-Xlinker -rpath \
-Xlinker $BUILT_PRODUCTS_DIR \
main.swift -o MyTest
# And to run:
./MyTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment