I'm looking for a solution to create an iOS project with C++.
Do you know if there is other manners than mix C++ with Objective-C ?
It's for a game written in C++, using some librairies : OpenGL, SDL, ...
Do you know if it's possible to use these librairies with an iOS project ?
I found something like this kind of stuff :
http://philjordan.eu/article/mixing-objective-c-c++-and-objective-c++
On this website you'll see in a video how to port your SDL game to iOS.
This link might be useful too; a step by step tutorial on how to use SDL.
This is basically it:
Create a new iPhone view based application project.
Build the SDL libraries statically (libSDL.a and libSDLSimulator.a) for iOS and include them in your project. XCode will ignore the library that is not currently of the correct architecture, hence your app will work both on iPhone and in the iPhone Simulator.
Include the SDL header files in your project. (e.g. #include "SDL.h")
Remove AppDelegate.h and AppDelegate.m -- SDL for iPhone provides its own UIApplicationDelegate. Remove your storyboard -- SDL for iPhone produces its user interface programmatically.
Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell XCode not to use the project prefix file, as it includes Objective-C code.
Related
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.
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 am currently working on a project in console mode in which I wish to implement a sound. Our choice then turned to SFML, we get to install and use on OS X. However, we need to make it compatible with Qt project for rendering, I generate a.Profile and integrate our code and the library.
In OS X, no problem, installation and use possible. However, for this project, we need to integrate it into the code to make only archive. But every attempt to link our project with the aforementioned library, we run into errors.
Could you tell us exactly what files are to be included in the project? Working on protecting machines, we cannot install packages. Here is the screen of the integration window, the button exhilarating. We cannot select the Library.
You just have to use the external library instead of the internal.
I am very new to adding c/c++ library to iOS project. My requirement is to add DICOM toolkit (written in c/c++) to my swift ios project. I have spent two days with googling to find steps how to include and use it, but i could not find any such blogs that are using DICOM toolkit by Mergecom.
Can somebody help here..
Thanks.
There is nothing (apparent) special about the merge toolkit. Look at any tutorial about using C code/libraries.
Here is one;
https://maniacdev.com/2015/02/tutorial-a-quick-guide-to-using-c-libraries-within-swift-code
Have you asked Merge for a sample app?
I've done this. If you are working from the publicly available sources, you'll need to:
1 - make the DCMTK sources build their libraries for iOS using Xcode
2 - make a Objective-C bridging library, like iiDicom work on iOS
3 - create additional Objective-C bridging code to access DCMTK via Swift
To get DCMTK + iiDicom working under iOS, it will take about a month of off-and-on work to get both libraries ready for initial use with Xcode.
I am an amateur mac user and I'm trying to make a c++ project in Xcode. Everywhere I go I am told to make a Command Line tool project in Xcode.
This is frustrating because I intend to make an OpenGL app and so I don't want it to be a console app.
This may be a very amateur question but I'm not familiar with Mac's. How can I make a non-console (terminal), C++ app in Xcode that I can make my OpenGL application in?
EDIT: Could I use SDL for windowing rather than cocoa?
You'll have to make a Cocoa application, and change the extensions of your files from .m to .mm. This tells the compiler you will also be using C++ with Objective-C.
The way Mac handles windowing pretty much requires the use of Objective-C, so you need the base Cocoa to make the window and the GL view, and then you will be able to write the rest in C++ as you would normally.
If you really want to be entirely C++, you could use a framework like GLUT that handles windowing itself.
On this case you probably do want a command line project.
The Xcode templates are to include a Cocoa nib if you are doing all the GUI with call to another library the it is a pure C++ project and no need for these templates.
You might need to do more if you are making it appear to be an OSX app that is an .app bundle that can be run directly from Finder or dock. In this case choose a Cocoa application and remove main.m (replacing by a main.cc) and the nibs.
You can make a Cocoa application and set up the OpenGL context using the native APIs, and then integrate your C++ code into that, or you can create a command line application that uses the GLUT library to set up OpenGL. Those are the two main ways.
Note: OpenGL 3+ isn't supported by GLUT on OS X yet, I don't think.