[swift-users] How to create custom module without the package manager?
Bee
bee.ography at gmail.com
Sat Dec 12 08:50:17 CST 2015
Hi all,
I'd like to create my own simple custom module, but I don't want to use the
complicated package manager. Package manager is overkill for a simple
single source file module. So, here's what I've tried.
file: greet.swift
public func askName() {
print("What's your name? ")
let name = readLine()!
print("Hello, \(name)... good to see you!")
}
file: main.swift
askName()
terminal:
$ swiftc -emit-library -emit-object greet.swift -module-name greet
emits greet.o
$ ar rcs libgreet.a greet.o
emits libgreet.a
$ swiftc -emit-module greet.swift -module-name greet
emits greet.swiftmodule and greet.swiftdoc
All went well, so I think now I already have had the "greet" module. Let's
try to use it…
file: test.swift
import greet
askName()
terminal:
$ swiftc test.swift
clang: warning: argument unused during compilation: '-F/home/username'
/tmp/test-b63aab.o: In function `main':
/tmp/test-b63aab.o:(.text+0x41): undefined reference to
`_TF5greet7askNameFT_T_'
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see
invocation)
What's happening? What's wrong? How can I fix it?
Thank you.
Regards,
--
-Bee-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151212/53820498/attachment.html>
More information about the swift-users
mailing list