Skip to content

Instantly share code, notes, and snippets.

@dabrahams
Last active May 18, 2021 00:16
Show Gist options
  • Save dabrahams/c7de10507e98463e71bf8b4586f5e51a to your computer and use it in GitHub Desktop.
Save dabrahams/c7de10507e98463e71bf8b4586f5e51a to your computer and use it in GitHub Desktop.
Linking and importing a swift module for use in the REPL
$ echo 'public func f() { print("YES") }' > x.swift
$ swiftc -emit-library -emit-module -module-link-name x  x.swift
$ swift -L . -I .
Welcome to Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55).
Type :help for assistance.
  1> import x
import x
  2> f()
f()
YES
@dabrahams
Copy link
Author

Thanks, updated the Gist for use with stock Swift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment