xcode @import 导致解析问题:“无法构建模块”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29620786/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
@import causes parse issue: "could not build module"
提问by jeeeyul
After updating with Xcode 6.3, I found something strange things with my projects.
使用 Xcode 6.3 更新后,我发现我的项目有些奇怪。
Below codes causes parse issue that says "Could not build module 'AgendaFramework'", the AgendaFramework is my custom embedded framework for ios8:
下面的代码会导致解析问题,显示“无法构建模块‘AgendaFramework’”,AgendaFramework 是我为 ios8 定制的嵌入式框架:
@import MyEmbededFramework;
The error marker looks like this:
错误标记如下所示:
The issues is raised during indexing not building. Whole building can be performed successfully without any error or warning. I can build, archive, run on device, deploy, submit to App Store.
问题是在索引而不是构建期间提出的。整个建筑可以成功执行,没有任何错误或警告。我可以构建、存档、在设备上运行、部署、提交到 App Store。
However the error marker shows up when I edit the classes that belongs to the extension. The the extension(widget) explicitly linked to the embedded framework. (I know that I don't have to do it when I use @import statement.)
但是,当我编辑属于扩展的类时会出现错误标记。显式链接到嵌入式框架的扩展(小部件)。(我知道当我使用@import 语句时我不必这样做。)
In this state, I could not receive any valid content assistant, very annoying.
在这种状态下,我无法收到任何有效的内容助手,非常烦人。
After I replace the import statement with old style, the problem was disappeared:
在我用旧样式替换 import 语句后,问题就消失了:
#import <AgendaFramework/AgendaFramework.h>
I have several other projects that have very similar topology with the project which causes this issue, But they are okay. Only one project causes this issue. I compared every detail build settings, I could not find any clue.
我还有其他几个项目与导致此问题的项目具有非常相似的拓扑结构,但它们都很好。只有一个项目会导致此问题。我比较了每个细节构建设置,我找不到任何线索。
I tried:
我试过:
- Delete derived data
- Full Clean
- Reboot
- 删除派生数据
- 完全清洁
- 重启
Any clues are welcomed. Thanks!
欢迎任何线索。谢谢!
采纳答案by kwz
It looks like turning on: Allow Non-modular Includes In Framework Modulessolved this issue for me.
它看起来像打开: 允许非模块化包含在框架模块中为我解决了这个问题。
回答by vivek
回答by inigo333
Sometimes this issue can be solved by adding the framework to the same folder as the .xcodeproj file, no subfolders or anything.
有时这个问题可以通过将框架添加到与 .xcodeproj 文件相同的文件夹中来解决,没有子文件夹或任何东西。
Credits to Jonny who points it out as a comment in the question.
归功于 Jonny,他指出这是问题中的评论。
回答by William Cerniuk
Solution that worked for me: diligence in framework header file orientation to system style imports... like #import <CoreXLib/CoreThreads.h>
the story:
对我有用的解决方案:在框架头文件定向到系统样式导入方面的努力......就像#import <CoreXLib/CoreThreads.h>
这个故事:
In my case my framework that I built came from the combination of several code bases as it became apparent that I could reuse some of the general design patterns across that code easer via Framework vs the fragile Xcode project pathnames.
就我而言,我构建的框架来自多个代码库的组合,因为很明显我可以通过 Framework 与脆弱的 Xcode 项目路径名在该代码简易程序中重用一些通用设计模式。
As I built my framework "CoreXLib", I reorganized it into the Cocoa Framework typical of Xcode. I changed my imports from:
当我构建我的框架“CoreXLib”时,我将它重组为典型的 Xcode 的 Cocoa 框架。我改变了我的进口:
#import "CoreTypeAliases.h" // project local style
to
到
#import <CoreXLib/CoreTypeAliases.h> // system or framework style
appropriately. Several projects that used the CoreXLib.framework which includes the public headers in the lego-folder worked... so I thought I was good to go...
适当地。几个使用 CoreXLib.framework 的项目,其中包括乐高文件夹中的公共标题工作......所以我认为我很高兴......
Unfortunately some of the headers that were public did not get fully updated. The classes in the framework built just fine in the local style. All projects using it worked up to this point and then I ran into one that didn't... and the error noted by @jeeeyul
不幸的是,一些公开的标题没有得到完全更新。框架中的类以本地风格构建得很好。到目前为止,所有使用它的项目都有效,然后我遇到了一个没有......以及@jeeeyul 指出的错误
So after finding this thread and finding @kwz 's solution, and not having it do anything in my case, I decided to polish the code up while I was trying to figure this problem out. In the polishing, I found that some of the #imports
did not get changed like they should have in the Xcode search and replaces. Time for some hand-jamming...
因此,在找到此线程并找到 @kwz 的解决方案后,并且在我的情况下没有做任何事情后,我决定在尝试解决此问题的同时完善代码。在润色中,我发现其中一些#imports
没有像它们在 Xcode 搜索和替换中应有的那样进行更改。是时候进行一些手动干扰了...
After fixing allof those references in allof my CoreXLib project headers (not just the public ones, self defense), I dove back into the problem... I took the newly complied CoreXLib.framework over to the errant project that embedded it... and the problem had vanished! I checked the Allow Non-modular Includes...
in both the framework project and the project that linked the framework in and both were "No". Flipping both to "Yes" and to "No" made no difference in several tests. The onlyother change was the #import "..."
to #import <CoreXLib/...>
modifications.
在我的所有CoreXLib 项目标头(不仅仅是公共标头,自卫)中修复了所有这些引用之后,我又回到了这个问题......我将新编译的 CoreXLib.framework 转移到嵌入它的错误项目中。 ..问题就消失了!我检查了框架项目和链接框架的项目,两者都是“否”。在几个测试中,同时切换到“是”和“否”没有任何区别。的唯一其他变化是对修改。Allow Non-modular Includes...
#import "..."
#import <CoreXLib/...>
So sometimes polishing the apple knocks the bugsoff...
所以有时抛光苹果会敲掉虫子......
回答by Luo Lun
Today I solved this problem by those steps,:
今天我通过这些步骤解决了这个问题,:
- Chose the schema "MyEmbededFramework"
- Press [Command + B] to build
- From the build phase panel, add "MyEmbededFramework.framework" to Link Binary With Libraries
- 选择架构“MyEmbededFramework”
- 按 [Command + B] 构建
- 在构建阶段面板中,将“MyEmbededFramework.framework”添加到 Link Binary With Libraries
Try to build your project, the problem may disappear now.
尝试构建您的项目,问题现在可能会消失。
回答by lingyfh
you can try this, it's work for me. delete DerivedData dir that about your project.step by step
你可以试试这个,它对我有用。删除关于您的项目的 DerivedData 目录。一步步
回答by Ruturaj Chavda
回答by user2918201
Turn off module's in build settings. That may work
在构建设置中关闭模块。这可能有效