Reputation: 530
macOS: 10.14.5
XCode: 10.2.1
Clang: 8.0.0
I am able to successfully compile Obj-C with XCode but am getting a fatal error that Foundation.h
is missing when attempting to compile from the command line. Any ideas on how to fix this?
$ cat first_program.m
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[]) {
@autoreleasepool {
NSLog(@"Hello, World!");
}
return 0;
}
$ clang -Wall -framework Foundation first_program.m
first_program.m:1:9: fatal error: 'Foundation/Foundation.h' file not found
#import <Foundation/Foundation.h>
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
$ clang -v
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
Upvotes: 0
Views: 1493
Reputation: 47159
I suspect since it appears the version clang
used is non-Apple headers cannot be located. You can likely tell it where to look for the Foundation
framework by adding isysroot
to your compile command with the xcrun --show-sdk-path
option:
clang -Wall -framework Foundation -isysroot `xcrun --show-sdk-path` first_program.m
Upvotes: 4