简体   繁体   English

Xcode中的此错误是什么意思?

[英]What does this error in Xcode mean?

When I build my app it randomly gives me this error: 当我构建我的应用程序时,它随机给我这个错误:

ld: entry point (_main) undefined. ld:入口点(_main)未定义。 for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 对于体系结构arm64 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

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 这是我的github链接: https : //github.com/nneeranjun/Map-Exercise.git

You're missing a main.m file, which is normally created automatically when you start a new project in Xcode. 您缺少main.m文件,该文件通常是在Xcode中启动新项目时自动创建的。

For a typical generic Cocoa Touch application, it looks like this: 对于典型的通用Cocoa Touch应用程序,它看起来像这样:

#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. 检查“目标成员资格”设置,并确保文件包含在应用程序的目标中。

Create a main.m file. 创建一个main.m文件。
Add the following code to this. 将以下代码添加到此。

#import <UIKit/UIKit.h>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM