开发者

I am trying to learn Objective C but maybe my enviroment is wrong?

开发者 https://www.devze.com 2022-12-10 21:28 出处:网络
#import <stdio.h> #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) {
#import <stdio.h>
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
  printf("Hello World!!\n");
  return 0;
}

I have a MacAir running OS X 10.6.1 with XCode version 3.2.1. When I attempt to compile the lines above I get开发者_StackOverflow中文版 3951 errors. Most of them seem to be NSObjCRunntime.h file where NSString is defined. When I comment out #import <Foundation/Foundation.h> I get no errors. Is there something wrong in my setup?

Thanks


It sounds like you're compiling this as C, so the Objective-C in Foundation is freaking it out. How are you compiling this? What sort of project is it? Is the file called main.c (which is a C file) or main.m (which is an Objective-C file)?


You're not linking in the Foundation framework. Check out the "Like binary with libraries" phase of your target, and make sure that Foundation.framework is in there.


Make sure you link against the specified SDK and framework:

gcc -isysroot /Developer/SDKs/MacOSX10.5.sdk  -framework CoreServices -framework CoreFoundation ...

Replace as needed for your version of the SDK and your frameworks.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号