could not build module foundation

本文介绍了解决Xcode中出现的couldnotbuildmodulefoundation错误的方法。通过在#import指令周围添加预处理器指令#ifdef __OBJC__ #endif,可以避免C文件错误地包含Objective-C头文件,从而解决构建失败的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天新建工程,突然发现爆出could not build module foundation的bug,就是运行不了,clean也没用。


在网站

http://stackoverflow.com/questions/19723392/adding-c-file-causes-pch-error

找到解决方案,说是

Surround #import's with preprocessor directive #ifdef __OBJC__ #endif

Thanks! That was it. I think I figured out why this works: the pch is included as a prefix into both C and ObjC files. So my C files were getting Foundation.h which of course would never work

我的问题也是在内部同时导入了c和oc头文件,我尝试注释掉c文件的引用,ok,能够build运行了,

貌似是既有c文件又有oc文件会出这个问题,但我取消注释后,又没事了,纳闷。


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值