-->

“could not build module 'Foundation'”

2020-05-30 03:40发布

问题:

Did a search for this question and could not find much help.

"could not build module 'Foundation'"

#import < Foundation/Foundation.h>

Not certain what is the problem. Thank you for any advice.

回答1:

I was able to solve this using the solution provided in this Apple Support Communities thread:

The real problem here is at Build Settings in the session: Apple LLVM 5.0 - Language - Modules, we should set Enable Modules (C and Objective C) to NO



回答2:

I found that if you use some external c / c++ code in your project, you have to remove all the #import in prefix. that's quite headache but it's a true problem



回答3:

Cmd+Option+Shift+k then Cmd+Option+k solved above error for me.



回答4:

you can try this

in your .pch file

write like this

#ifndef PureStandard_PrefixHeader_pch
#define PureStandard_PrefixHeader_pch
#ifdef __OBJC__
#import "A.h"
#import "B.h"
#endif
#endif


回答5:

The suggested fix to set Enable Modules (C and Objective-C) did not solve this issue for me.

What did is renaming my someFile.c files to someFile.m. Even though those files contain just C functions (that do use Foundation types), naming them .c produces this error.



回答6:

I have resolved by change Build System to Legacy Build System

Open the ios/PROJECT_NAME.workspace file

Then in the top menu select File > Workspace Settings

Then change Build System to Legacy Build System


回答7:

If using flutter run flutter clean in terminal or in android studio, restart emulator and run app.



回答8:

Just rename your Objective-C++ file from *.c to *.mm.

The errors are gone that way, it handles all the imports just fine this way.



标签: foundation