[英]Error building Swift Cocoa Touch Framework after adding Swift file: <unknown>:0: error: could not build Objective-C module
I have a problem creating a Swift Cocoa Touch Framework. 我在创建Swift Cocoa Touch Framework时遇到问题。 As soon as I add my first .swift file, clean, then build I get a build error:
只要我添加我的第一个.swift文件,清理,然后构建我得到一个构建错误:
<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 使用Xcode 6.1.1,只需几步即可轻松重现
I've tried the typical Xcode magic such as deleting derived data, restarting Xcode, etc. 我尝试了典型的Xcode魔术,例如删除派生数据,重启Xcode等。
Steps detailed below with screenshots: 以下详细步骤截图:
File > New > Project > iOS Framework & Library > Cocoa Touch Framework 文件>新建>项目> iOS框架和库> Cocoa Touch Framework
Product Name: MyTextFramework 产品名称:MyTextFramework
Language: Swift 语言:斯威夫特
I now have a bare bones Cocoa Touch Framework. 我现在有一个简单的Cocoa Touch Framework。
Add an iOS Swift file named FooBaz.swift 添加一个名为FooBaz.swift的iOS Swift文件
Add a class that extends NSObject and an init function. 添加一个扩展NSObject和init函数的类。
The target still builds fine at this point. 此时目标仍然很好。
Cmd-K to clean the project Cmd-K清理项目
Cmd-B to build again... BAM Cmd-B再次建造...... BAM
如果您不打算使用Objective-C中的Swift框架,最简单的解决方案是摆脱MyTextFramework.h
As Georg Tuparev answered, I just need to remove MyTextFramework.h and it builds fine. 正如Georg Tuparev回答的那样,我只需要删除MyTextFramework.h就可以了。 However, this prevents using my framework in Obj-C code.
但是,这可以防止在Obj-C代码中使用我的框架。
Is it even possible to build a framework containing Swift code that can be used in both Swift AND Obj-C? 甚至可以构建一个包含可以在Swift和Obj-C中使用的Swift代码的框架吗? If it is technically possible, then it seems this issue with Xcode would prevent anyone from actually doing it.
如果技术上可行,那么Xcode的这个问题似乎会阻止任何人实际做到这一点。 Does anyone have any comments or solutions for this scenario?
有没有人对此方案有任何意见或解决方案?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.