Is there a way to declare a function in a .swift file (that is compiled into a .swiftmodule), like so:
hello.swift
func hello_world() {
println("hello world")
}
main.swift
import hello
hello.hello_world()
I've also made a git repo with these two files and a Makefile with the compile / link commands ready to go. Currently I can get main.swift to import hello, but it's currently failing to link ... is there another linker flag I can pass? Currently Makefile is:
PWD=$(shell pwd)
APP_NAME=main
MODULE_NAME=hello
SWIFT_MODULE_PATH=$(PWD)/$(MODULE_NAME).swiftmodule
SDK=/Applications/Xcode6-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
main : clean
xcrun swift $(MODULE_NAME).swift -emit-module -v
xcrun swift $(APP_NAME).swift \
-o $(APP_NAME) \
-sdk $(SDK) \
-I $(PWD) \
-Xlinker -sectalign \
-Xlinker __SWIFT \
-Xlinker __ast \
-Xlinker 4 \
-Xlinker -sectcreate \
-Xlinker __SWIFT \
-Xlinker __ast \
-Xlinker $(SWIFT_MODULE_PATH) \
-v