On 16 May 2015, at 4:29 am, Jens Alfke <
je...@mooseyard.com> wrote:
> The problem is that to test this I need a class in a module, and from looking at the docs, the only way to do that is to create a new Xcode framework target, with all the rigamarole that entails. (Actually I’d need two, one for iOS and one for Mac.) Is there any other way to do this? Like a “module Foo” statement, similar to every single other existing language that supports modules?
I don't think there's anything language-level like that. The way I've done it is to use swiftc to build a dynamic library, e.g.:
$ swiftc -emit-library -o build/libFoo.dylib -module-name Foo Foo/*.swift
$ swiftc -emit-module -o build/Foo.swiftmodule -module-name Foo Foo/*.swift
$ swiftc -Lbuild -Ibuild -lFoo main.swift
Managing the linker search paths, linked libraries and import search paths like this kinda sucks, and frameworks do abstract away some of that for you. But the tradeoff is that building the framework bundle itself is a bit more complicated. It's definitely doable though, and easier once you write a build script or something to automate it.
It would be nice if there was a simpler way, but I think tooling can definitely solve the problem.
–Adam