Search code examples
xcodefoundation

Xcode 9.4.1 and Foundation Framework


Hello I'm new to programming in Objective-C. I'm reading the book "Programing in Objective-C Developers Library" and they're asking me to create a command line project using the foundation framework, but when I go to create one, I don't see an option to use Foundation.

Pic 1

Pic 2


Solution

  • Your first screen shot shows it:

    enter image description here

    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".