Your first screen shot shows it:
You've already selected Command Line Tool, which is correct. So now click Next and you will be creating a command line tool that uses the Foundation framework. In your second screen shot, enter a name for the tool and click Next; you will then be asked for a place to Save this project. Do so. When you do, the code for main.m will say:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
}
return 0;
}
See that first line? That is "using the Foundation framework".
One thing to know is that Foundation is so important in Objective-C that it's practically part of the language. It provides classes like NSNumber
, NSString
, NSArray
, NSDictionary
, and many others that we assume are always available. So Foundation is special in that every Objective-C project will use it, and it'll be included in any project templates like the Command Line Tool template you're working from. Other project templates will include additional frameworks (eg the Cocoa App template will set up your project with AppKit for you), and if you want to use other frameworks you'll add them yourself after you create the project.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.