Skip to content

Instantly share code, notes, and snippets.

@sharplet
Last active September 12, 2022 12:24
Show Gist options
  • Save sharplet/3bd13037b0972e451921 to your computer and use it in GitHub Desktop.
Save sharplet/3bd13037b0972e451921 to your computer and use it in GitHub Desktop.
Building a Swift framework, then building and running Quick specs, *without Xcode*
# View on GitHub: https://github.com/sharplet/Switch
# Try it yourself: git clone https://github.com/sharplet/Switch.git && cd Switch && rake
$ rake
mkdir -p Build
mkdir -p Build/Switch.framework
mkdir -p Build/Switch.framework/Versions/A/Modules/Switch.swiftmodule
ln -sf A Build/Switch.framework/Versions/Current
ln -sf Versions/Current/Modules Build/Switch.framework/Modules
ln -sf Versions/Current/Switch Build/Switch.framework/Switch
xcrun -sdk macosx swiftc -module-name Switch -emit-library -o Build/Switch.framework/Versions/Current/Switch -- Source/Array+Ext.swift Source/Option.swift Source/ParseResult.swift Source/Parser.swift Source/String+Ext.swift
xcrun -sdk macosx swiftc -module-name Switch -emit-module-path Build/Switch.framework/Versions/A/Modules/Switch.swiftmodule/x86_64.swiftmodule -- Source/Array+Ext.swift Source/Option.swift Source/ParseResult.swift Source/Parser.swift Source/String+Ext.swift
touch Build/Switch.framework
mkdir -p Build/Specs.xctest
xcrun -sdk macosx swiftc -o Build/Specs.xctest/Specs -lswiftCore -FBuild -FCarthage/Build/Mac -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xlinker -rpath -Xlinker Carthage/Build/Mac -Xlinker -rpath -Xlinker /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -- /var/folders/8v/5t6y1vqx1wz6vnt4yrcjgy4w0000gp/T/d20150417-4280-1r63ner/main.swift Specs/FeatureSpec.swift Specs/Helpers/Process+Ext.swift Specs/String+ExtSpec.swift
touch Build/Specs.xctest
xcrun -sdk macosx xctest Build/Specs.xctest/Specs 2>&1 | tee xctest.log | xcpretty -c; exit ${PIPESTATUS[0]}
Test Suite Specs.xctest started
FeatureSpec
✓ parses_a_single_short_option (0.008 seconds)
StringExtSpec
✓ toMutableCString____copies_the_full_string_when_multibyte_characters_are_involved (0.000 seconds)
Executed 2 tests, with 0 failures (0 unexpected) in 0.008 (0.009) seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment