Xcode 无法为我自己的框架生成 Swift 表示 [英] Xcode Couldn't Generate Swift Representation for my own framework

查看:31
本文介绍了Xcode 无法为我自己的框架生成 Swift 表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个框架,我想在我的 OS X 应用程序中使用它.由于在 El Capitan 上更新到 Xcode 7,当我尝试命令单击 import 语句时,Xcode 转到以下视图.

I have created a framework which I want to use in my OS X app. Since updating to Xcode 7 on El Capitan, when I try to command-click on the import statement, Xcode goes to the following view.

如何让 Xcode 正确显示 Swift 表示?我以前遇到过这种情况,我的解决方案是重新创建我不想再做的每个项目文件.

How can I get Xcode to display the Swift representation properly? I've had it happen before, and my solution was to recreate every project file which I don't want to do again.

推荐答案

根据我的经验,此问题有两个可能的原因.第一个是您的框架无法定位.要解决此问题,您需要转到目标的构建设置并添加到框架搜索路径的绝对路径:

From my experience there are two possible causes for this issue. The first one is that your framework can't be located. To fix this you need to go to target's Build Settings and add a path to Framework Search Paths either an absolute:

/Users/{user}/path-to-framework-parent-directory

或相对于项目目录:

$(PROJECT_DIR)/path-to-framework-parent-directory

另一个可能的原因是您的框架的路径中包含一个空格.我发现无论您是尝试用反斜杠 ../Project\ Name/frameworks 转义它还是采用双引号 "../Project Name/中的整个路径都没有关系框架".结果是 SourceKit 无法加载模块.

Another possible cause is that the path to your framework contains a space in it. I found that it doesn't matter whether you try to escape it with backslash ../Project\ Name/frameworks or take the whole path in double-quotes "../Project Name/frameworks". The result would be that SourceKit could not load the module.

请注意,$(PROJECT_DIR) 可能会扩展为包含空格的路径,并且也会导致相同的错误.所以它看起来像是 Xcode/SourceKit 中的一个错误(我尝试了最新的 Xcode 7.2-beta3,但该错误仍然存​​在).

Note that $(PROJECT_DIR) could expand to a path with a space in it and it would too result in the same error. So it looks like a bug in Xcode/SourceKit (I tried the latest Xcode 7.2-beta3 and the bug is still there).

我的存储库位于第二个硬盘驱动器 /Voluems/Macintosh HD/Repos.我刚刚将硬盘重命名为HD,所以路径看起来像/Volumes/HD/Repos,问题就消失了.

My repository was on the second hard drive /Voluems/Macintosh HD/Repos. I just renamed the hard drive to HD, so the path looks like /Volumes/HD/Repos and the problem was gone.

这篇关于Xcode 无法为我自己的框架生成 Swift 表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆