1

I have an open source C++ project. My aim is now to extend this project with additional code. This code is Objective-C code (because I don't know C++). I have already found a way to call an Objective-C function from a C++ class (Calling Objective-C method from C++ method?) But, when I try to compile my C++ code with XCode, XCode freezes (no error during the building phase). My question is if it is even possible to call an Objective-C class out of a project that is only written in C++.

Has anyone had some experiences with that?

Community
  • 1
  • 1
Gustav
  • 21
  • 2

2 Answers2

1

you can certainly integrate the two langs.

if your program (+depends) is large, then Xcode can get tied up for a number of reasons.

personally, i have had not been able to use Xc4 as effectively as Xc3 on large projects. i spend too much time waiting for it to become responsive. i have loaded large (meta) projects in Xc4 and let it parse and create several GB of 'derived data' for hours (literally) on an otherwise idle 8 core machine -- only to end the process several hours into it. again, it depends on the size of the projects, and their dependencies. it's unlikely that your projects are that complex.

the tradeoff is that Xc4 adds some significant features (e.g. superior parsing, compilation during editing). sometimes it's good to launch into Xc3 and minimize functionalities (e.g. code sense indexing) until it builds for you.

compilation should not cause a freeze (but give it some time to recover)... Xcode may be overwhelmed by errors if you have not specified the right languages, or you have mixed the languages - without proper compiler flags.

if it's really big, Xcode can spend a lot of time parsing the sources, creating derived data.

if it persists, it's probably a give idea to post more info.

justin
  • 104,054
  • 14
  • 179
  • 226
0

Xcode freezing is definitly a bug, it should compile or give an error. Try switching to another compiler in your project settings.

As long as the c++ code is compiled in objective-c++ mode it should work. AFAIK it will only compile in objective-c++ mode if the file extension is .mm or if you explicitly tell the compiler. Commandline switch for both gcc and clang is -ObjC++

Eelke
  • 20,897
  • 4
  • 50
  • 76