@import causes parse issue: “could not build module”

喜夏-厌秋 提交于 2019-11-28 21:05:50

It looks like turning on: Allow Non-modular Includes In Framework Modules solved this issue for me.

Sometimes this issue can be solved by adding the framework to the same folder as the .xcodeproj file, no subfolders or anything.

Credits to Jonny who points it out as a comment in the question.

Hi this is due to the fact that file which you are making it public in framework header must be public also.

Solution that worked for me: diligence in framework header file orientation to system style imports... like #import <CoreXLib/CoreThreads.h> the story:

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.

As I built my framework "CoreXLib", I reorganized it into the Cocoa Framework typical of Xcode. I changed my imports from:

    #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...

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

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...

After fixing all of those references in all of 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 only other change was the #import "..." to #import <CoreXLib/...> modifications.

So sometimes polishing the apple 🍎 knocks the bugs🐞🐞off...

Today I solved this problem by those steps,:

  1. Chose the schema "MyEmbededFramework"
  2. Press [Command + B] to build
  3. From the build phase panel, add "MyEmbededFramework.framework" to Link Binary With Libraries

Try to build your project, the problem may disappear now.

lingyfh

you can try this, it's work for me. delete DerivedData dir that about your project.step by step

Turn off module's in build settings. That may work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!