“could not build module 'Foundation'”

2020-05-30 03:47发布

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.

标签: foundation
8条回答
时光不老,我们不散
2楼-- · 2020-05-30 03:51

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
查看更多
别忘想泡老子
3楼-- · 2020-05-30 03:51

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.

查看更多
啃猪蹄的小仙女
4楼-- · 2020-05-30 03:53

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
查看更多
甜甜的少女心
5楼-- · 2020-05-30 04:00

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

查看更多
趁早两清
6楼-- · 2020-05-30 04:01

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

查看更多
放我归山
7楼-- · 2020-05-30 04:02

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.

查看更多
登录 后发表回答