Xcode 无法为我自己的框架生成 Swift 表示

编程入门 行业动态 更新时间:2024-10-27 00:33:18
本文介绍了Xcode 无法为我自己的框架生成 Swift 表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我创建了一个框架,我想在我的 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-24 10:37:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1061427.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自己的   为我   框架   Xcode   Swift

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!