erreur main xcode

hello, I am new to xcode and I have an error with main, and after doing some research I said it seems that xcode does not recognize the main, but I can not understand why, knowing that I write in c ++ is not that the problem? thank you for helping me.



Undefined symbols for architecture x86_64:

"_main", referenced from:

implicit entry/start for main executable

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

TL;DR: When you create an Xcode project for a Cocoa Application, Game, or Command Line tool, a default main (depending on language) is created for you. That should provide you a starting point for your code. Somehow, that main file is deleted or removed from the project compile sources list in your project.


Are you building a Command Line tool, or a Cocoa application? What language are you trying to use (Swift, Objective-C, Objective-C++, C, C++)?


If you are building a command line application, you have to provide a main() subroutine/function if you are starting out in C/C++/Objective-C/Objective-C++. If you are using Swift, no need for a main. Based on your error, it would seem you are trying to use C/C++/Objective-C/Objective-C++. In the template that Xcode uses to create a command line application, depending on the language you choose when you create the project, a main.c/main.cpp/main.m/main.mm/main.swift file should have been created. If you've deleted that, then you have to provide a source file with a main() function defined.


If you are writing a Cocoa application, depending on the language, a main.m file should have been created, which contains the invocation of the NSApplication class that creates the Cocoa application objects, initializes the application, and enters into the main runloop. If you are trying to create a Swift-based application, an AppDelegate.swift file should have been created that provides a skeleton application delegate. Now, there are ways by which you can build the main program for Cocoa applications, but, that requires more detailed knowledge of how the Cocoa frameworks work, both Objective-C and Swift.


If you created an Empty Project, you have to provide the source code for the main program.

But I only have one main file in my project, and it's main.m, but still the Xcode reports this error. I'm writing Objective-C program and Using Xcode 11 Beta 2.


So is that possible that this error report just a bug in the beta software?

What is in your main.m? It should have at least the following in it:


#import <Cocoa/Cocoa.h>

int main(int argc, const char * argv[]) {
  return NSApplicationMain(argc, argv);
}
erreur main xcode
 
 
Q