Reputation: 10532
I have a problem creating a Swift Cocoa Touch Framework. As soon as I add my first .swift file, clean, then build I get a build error:
<unknown>:0: error: could not build Objective-C module 'MyTextFramework'
This is easily reproducible from scratch in just a few steps using Xcode 6.1.1
I've tried the typical Xcode magic such as deleting derived data, restarting Xcode, etc.
Steps detailed below with screenshots:
File > New > Project > iOS Framework & Library > Cocoa Touch Framework
Product Name: MyTextFramework
Language: Swift
I now have a bare bones Cocoa Touch Framework.
Add an iOS Swift file named FooBaz.swift
Add a class that extends NSObject and an init function.
The target still builds fine at this point.
Cmd-K to clean the project
Cmd-B to build again... BAM
Upvotes: 4
Views: 1057
Reputation: 10532
As Georg Tuparev answered, I just need to remove MyTextFramework.h and it builds fine. However, this prevents using my framework in Obj-C code.
Is it even possible to build a framework containing Swift code that can be used in both Swift AND Obj-C? If it is technically possible, then it seems this issue with Xcode would prevent anyone from actually doing it. Does anyone have any comments or solutions for this scenario?
Upvotes: 1
Reputation: 441
If you are not going to use this Swift framework from Objective-C, the easiest solution is to get rid of MyTextFramework.h
Upvotes: 3