I am looking for a simple procedure for combining an Objective-C code from a shared library project with Swift code from an application project but have had no success so far with this sequence:
- start Xcode 6.1.1
- create workspace Test
- create iOS Cocoa Touch Static Library project TestLibrary and add it to workspace
- create iOS Single View Application project Test (language: Swift) and add it to workspace
- add
import TestLibrary
to ViewController.swift
If I now build Test, I receive this error in ViewController.swift: No such module: ‘TestLibrary’
.
Presumably two hurdles must be overcome:
- Tell TestLibrary that is should "export" TestLibrary.h. What is the right syntax and procedure for adding the (presumably) required bridging header file?
- Tell Test where TestLibrary is located. Since both the application and static library projects belong to the same workspace (and sit in the file system next to each other) I assume no explicit steps are required, or are there?
So in summary, my question is this: how can I overcome the build error even if I subsequently add let test = TestLibrary()
to ViewController.swift, i.e. how can Test (Swift code base) make use of TestLibrary (Objective-C code base)?