Skip to content

Instantly share code, notes, and snippets.

@modocache
Last active February 3, 2018 23:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save modocache/853f5e9b3c00b1b4448c to your computer and use it in GitHub Desktop.
Save modocache/853f5e9b3c00b1b4448c to your computer and use it in GitHub Desktop.
# 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