I have a C++ project generated from Cmake to Xcode. My project is just some static and dynamic libraries. I want to include some 3rd party frameworks to it.
Is it possible? Is there any chance to include? Or I should completely redesign the project to Cocoa app?
I haven't access to the framework source code.
Work with Xcode 9.2.
No, you can't use Cocoa frameworks in pure C++ project.
But you can just create an obj-c project and include all of your existing sources inside - everything will work. Just remember to use .mm extension for the source files, calling C++ code.
You can use swift as well, but that will require to create a wrapper for C++ code.
Related
I am looking for a way to include Webrtc in my iOS project. My project consists some C code which I am looking for a way to call the Webrtc apis from. I am able to do this in Android using a Makefile and linking the webrtc library. However, I haven't been able to do it on iOS. I tried to build a webrtc.framework but I am not sure how to link it to my C code. Any idea?
The WebRTC.framework that gets created by the build script has Objective-C header files. You cannot call Objective-C methods in a C source code (.c) file. You'll need to consume it in an Objective-C (.m) file or Objective C++ (.mm) file.
Google introduced and then quickly decided to drop static library target somewhere in Sep 2018. We usually build static library once a month for ios. I can share libs on github if you like.
project compiles fine, how do I export it as an iOS app though
I have a large C++ project that I'd like to turn into an iOS app... any tips on how I might go about doing this? What I've done so far is to use CMake to generate an XCode project. I've been able to subsequently build (and archive -- but I can't find the archives in the organizer) my project in XCode, but to my understanding this is merely using XCode as an IDE...
Is there an easy way to remedy this situation? Or do I need to reconstruct the project all over again iOS style. If so, any guides you might recommend?
.mm files compile to objective-c++.
This is how you will get c++ code to talk to all the IOS libraries, which unfortunately are only generally easily available in objective-c and swift.
So create c++ interfaces in .h or .hpp files, and back them up with an objective-c++ impl that then talks to the objective-c runtime.
To get cmake to work nicely with iOS, you'll need a toolchain file.
There is a nice collection that you can use as a starting point here:
https://github.com/ruslo/polly
I want to learn C++ on my Mac computer. A lot of forums recommend using Xcode, but when I downloaded it I realized that it only has options for Swift or Objective-C. Is there still a way to use C++ in Xcode?
The parts of a problem that interact with system APIs for making an app have to be Swift or Objective-C. (As such, the project templates that give you the bare skeleton of an app to get started with are only Swift and ObjC.)
However, an Objective-C app can use C++ internally. Just create .mm files instead of .m (or rename the ones you have from the project template) so that the compiler knows you're writing Objective-C++. Then you can write ObjC classes that create C++ objects or call into C++ libraries, write C++ classes or templates that store pointers to ObjC objects, etc.
I have lots of useful platform independent code made in C/C++ such as string/number/private data management, etc.
Now, as a starter to programming to iOS, I want to re-use the library for my project.
I don't think I can use it directly, but before starting, I want to check, but not easy to find the answer at this time.
What I want is
Implement a C++ library with public header files for iOS (not MacOSX) in Xcode.
Build them and get libProject.dynamic / libProject.a / other header files.
Integrate them into Xcode so that other separate client app (object-c) can use it.
If someone help me brief introduction how to achieve above or any other reference would be appreciated.
Thanks,
Hana
In Xcode, you can simply choose "New Project" from the "File" menu, and from the project template chooser, click on "Framework & Library" under the "iOS" section. There is a single entry - "Cocoa Touch Static Library". Use that as your Xcode project template to make the static library. Then you can include it in your other projects just like you would any other static library.
I'm using Eclipse in linux. I have created a project using Cocos2D. It's a Java project, but im opening cpp and headers files to write native code.
Each time, i compile the native code with ./build_native.sh
I will like to know if eclipse could be configure to autocomplete functions in native code.
Example:
CCDirector::sharedDirector()->
Must show the options like getWinSize().
Some ideas? Thanks in advance.
I can't answer to the specifics of your question but in general I had this problem in C/C++ with iostream and STL libs. Even though everything would compile fine it wasn't supporting auto-complete. I ended up digging down into the supplied libraries to the root that held each .h file collection and added those to the directories path. Then I rebuilt the index and then auto-complete started working. So if cocos2d stores .h files in more than one location add each folder.
Have you installed the CDT? That give Eclipse C/C++ capabilities similar to what it already has for Java.