4

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

  • Create new Cocoa Touch Framework using Swift Language
  • Add an iOS swift file
  • Build - OK
  • Clean - OK
  • Build - ERROR
  • From here on the project will not build unless I delete the swift file.

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 enter image description here

Product Name: MyTextFramework

Language: Swift enter image description here

I now have a bare bones Cocoa Touch Framework. enter image description here

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. enter image description here

Cmd-K to clean the project

Cmd-B to build again... BAM enter image description here

2 Answers 2

3

If you are not going to use this Swift framework from Objective-C, the easiest solution is to get rid of MyTextFramework.h

Sign up to request clarification or add additional context in comments.

2 Comments

This is correct and does solve the question I asked. I'd like to know why it has to be removed, and what happens if I did want to use my framework in Obj-C and not just Swift?
Did you figure this out ever? This is absolutely ridiculous.
1

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?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.