使用未声明的标识符“ NSBundle”

Sam*_*tha 0 macos xcode objective-c nsbundle

这是我的file.mm的样子:

const char *readFromFileMac(const char *fileName) {
    fileName =[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @(fileName)].UTF8String;
    return fileName;
}
Run Code Online (Sandbox Code Playgroud)

Xcode给我错误Use of undeclared identifier 'NSBundle'。我是否需要包含一些框架或头文件才能使用该NSBundle名称?

我唯一要做的就是将项目复制到另一个目录。复制后,我得到了这个错误,它以前可以正常工作。我正在使用Xcode 8.2

hid*_*yat 5

尝试 #import <Foundation/Foundation.h>

请记住将添加Foundation.framework到链接的库/框架。