How to convert a complex C ++ Xcode project into a Cocoa application?

I have the source code for a relatively complex C ++ application that includes many libraries, dependencies, etc. I am trying to take it and add Cocoa GUI to it. I still haven't done the following:

  • Create a new Cocoa xcodeproj and try moving all the libraries, etc. into the Cocoa app. I just can't build it. Thousands of mistakes no matter what I do. My mastery here is simply not enough to understand what is happening.

So, I think a simpler method should be to make the appropriate changes to C ++ xcodeproj so that the main () function starts NSApplication instead of what it is doing right now.

Does anyone know what I need to do to make this happen? I'm new to Cocoa, so I'm not sure what I will have to add. For reference, the main.cpp C ++ application is actually very simple:

int main() {
    ofSetupOpenGL(320,300, OF_WINDOW);
    ofRunApp(new testApp());
}

I would like to make all the right changes so that it can be:

#import <Cocoa/Cocoa.h>

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

And try the old xcodeproj compiler with all the “files” in it, and then when it starts, open the Cocoa window.

It should be noted that C ++ xcodeproj has absolutely nothing to do with Cocoa or even Objective-C related to it, so we will need to add everything that matters and make all the appropriate changes.

Any ideas?

(Or, conversely, if you know how I can easily get all things from C ++ xcodeproj to build a squeaky clean Cocoa xcodeproj, let me know, but that seems to me more complicated at the moment.)

Thank!

+3
4

, ...

  • Cocoa? Mac ​​ QT, wxWidgets .
  • ++ Objective-C ++. Objective-C ++ ++. .cpp → .mm , , UI. , - Cocoa XCode . OpenGL, Cocoa, ++, .

: " ", .. , , . - . , .

, . , () . !

+1

, , ++ , cocoa.

, , . , objc.

-: ++ objc. . , . objc.

second: / objc ++. - , ui .

-: . cocoa, gcc cpp , ++. ++ objc, obj++ FILENAME.mm ( .M, ). , cpp , .

: , cocoa cpp, /, / cocoa. , Open GL, - NSOpenGLView, cocoa. , , .

NSApplicationMain, ++, , , NSWindow, NSView , , NSApplication.

objc, , , .

+1

, - ( Mac, Windows), ++. (Cocoa Mac MFC Windows). - , .

0

, .

int main() {
     ofSetupOpenGL(320,300, OF_WINDOW);
     ofRunApp(new testApp()); 
}

Open Frameworks. Open Frameworks Mac XCode . , OpenGL flockingExample?

0

Source: https://habr.com/ru/post/1785071/


All Articles