nilay neeranjun
nilay neeranjun

Reputation: 145

What does this error in Xcode mean?

When I build my app it randomly gives me this error:

ld: entry point (_main) undefined. for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I really don't know how to explain it because I have no idea what it means and I have no idea where it can be coming from.

Here is my github link: https://github.com/nneeranjun/Map-Exercise.git

Upvotes: 1

Views: 382

Answers (2)

Mark Bessey
Mark Bessey

Reputation: 19782

You're missing a main.m file, which is normally created automatically when you start a new project in Xcode.

For a typical generic Cocoa Touch application, it looks like this:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
  @autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
  }
}

After you've created the file, add it to the project (File menu, "Add Files to "project name").

Once you have added the file to the project, you need to make sure it's included in the target. Select the file in the project navigator, and go to the View menu and select Utilities->Show File Inspector to show the file inspector. Check the "Target Membership" setting, and make sure the file is included in the target for your application.

Upvotes: 3

barryjones
barryjones

Reputation: 2309

Create a main.m file.
Add the following code to this.

#import <UIKit/UIKit.h>

int main(int argc, char *argv[])
{    
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, @"AppDelegate");
    }
}

Upvotes: 0

Related Questions