First you need to link alle the required object files into the libchuckle.a this can be done with CMake: To make this cross platform you need to change a few things. You can tell by the size of libchuckle.a (1,9Mb) that it should contain everything we need to proceed :-D make it cross platform Start by creating a directory and a few files:Ĭmake_minimum_required ( VERSION 3.19 ) project ( chuckle ) set ( CMAKE_CXX_STANDARD 17 ) set ( CPR_BUILD_TESTS OFF ) set ( CPR_BUILD_TESTS_SSL OFF ) include ( FetchContent ) FetchContent_Declare ( cpr GIT_REPOSITORY GIT_TAG 1.6.2 ) FetchContent_MakeAvailable ( cpr ) FetchContent_Declare ( json GIT_REPOSITORY GIT_TAG v3.7.3 ) FetchContent_GetProperties ( json ) if ( NOT json_POPULATED ) FetchContent_Populate ( json ) add_subdirectory ( $ All will be done via CMake, the ios-cmake toolchain and a small shell script. To enable multi-architectures we'll use fat-libs and to enable multi-platform support we'll stuff these fat-libs into a xcframework. Let's first create a little library in C++ that uses some random dependencies and cross-compile that for iPhone, iPhone simulators and the Mac running on Intel or Apple-Silicon. I do want to mention that Swift is – by far – the coolest programming language that I've came across and that it runs on Darwin, Linux and Windows and that you should really revistit your life choices if you manouvered yourself in the corner googleing for an article like this ) Start easy - create a demo library If you read through the end you know enough to decide wether or not this is for you. There're definitely a few other – more straight forward ways – of doing Swift/C++ interoperability not all great though and with different trade offs. Well first it's fun, second you can learn a few things along the way and third: Given the right situation and constraints this can be a great idea! Warning I'll use another gRPC server written in Swift so that not only the Swift part can call into C++ via gRPC but the C++ part can call into Swift via gRPC as well – all in the same process, of course :-D But why? I will show you how you can embed a gRPC server written in C++ in a Swift programm that you can run on a Mac or an iPhone.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |