ok after struggling for few days trying to adapt cmake to generate a valid xcode project.
I find the task quite difficult. No impossible I actually have a project, but there are few things that are still impossible, one is the bridging between CPP and Switf.
I could not find a way to generate a project that links without errors. It looks like xcode create some special in the project, that can only be does using xcode.
It seems xcode is a moving target.
so I decided to make manual libraries in xcode.
I am surprice there are no samples of how to integrate cpp and xcode. not even on the Apple support sites. most of them are contradictory and misleading. they mention cpp interoperability, but it is a baith and switch, the interoperability is an Apple version of cpp they call objective cpp.
I did find a minimal sample CppInteropInlineExample and that the one I am using.
Any way I am adding the library and mange to link them with a switf project, that can instanciate the word, but even in switf every thing is is changing.
here is an example in this file. (created but xcode id and edicted)
- Code: Select all
import SwiftUI
struct ContentView: View {
let number = myFavoriteNumber()
let newton = UnsafeMutablePointer<Void>(CreateWorld())
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, No. \(number)!")
}
.padding()
}
}
the line that instanciate the engine is this
let newton = UnsafeMutablePointer<Void>(CreateWorld())
but xcode is unhappy and generate a warning saying to use UnsafeMutableRawPointer
instead of UnsafeMutablePointer
but I could not find a simple example of how to use that. and if my pass experience with xcode and apply, is correct when they issues a warning, it means that next time you open the project your code will not compiled because apple just removed it.
I found the integration between Switf and native C++ too difficult and incomplete on Apple,
and I get the impression that Apple is also on its way to flush out Cpp from their system,
the solution they are providing seem to be a really bad band aid.
anyway I will add all the libraries and see if I figure out how to run at least a simple test.
but if it turns out that I will have to write c or objective c glue code, that no something I want to spend time on.
In their video that claim it is possible to make call to cpp classes, but they talk of objective cpp
right now, I am stuck on how to insatiate a cpp class and them how to make call to member functions of the class.