Integrate Babylon native in existing Swift project

Is the git submodule gone?

Edit:
Oh, I found this PR a day later.

I may need to know about UNITY_BUILD

I was able to manually place IOS-cmake in the project and proceed, but cmake --build . but I can’t run it because of openXR_loader.


GatherProvisioningInputs

CreateBuildDescription

Build description signature: 86ced6bfdd018ec74a18a3130f4fdbdf

Build description path: /Users/iori/src/BabylonNative/build/build/XCBuildData/86ced6bfdd018ec74a18a3130f4fdbdf.xcbuilddata

note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Playground' from project 'BabylonNative')

note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'UnitTests' from project 'BabylonNative')

note: Run script build phase 'Generate CMakeFiles/ALL_BUILD' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'ALL_BUILD' from project 'BabylonNative')

note: Run script build phase 'Generate CMakeFiles/ZERO_CHECK' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'ZERO_CHECK' from project 'BabylonNative')

/Users/iori/src/BabylonNative/build/BabylonNative.xcodeproj: error: Signing for "openxr_loader" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'openxr_loader' from project 'BabylonNative')

note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'openxr_loader' from project 'BabylonNative')

BUILD FAILED

This is just my personal opinion, and you can ignore it, but I think there are many use cases for integrating BabylonNative into existing Swift projects, and there should be documentation for that.

Alternatively, please revive PR293.

It’s possible to use BN in a swift project.
Take a look at iOS playground : BabylonNative/Apps/Playground/iOS at master · BabylonJS/BabylonNative · GitHub
The documentation from the readme should be up to date and, as a reference, here are the build steps for iOS:

2 Likes

Thank you very much! Now that the build is done I can proceed with my development.

mkdir buildiOS
cd buildiOS
cmake … -G Xcode -D IOS=ON -D DEPLOYMENT_TARGET=17.0 -D CMAKE_UNITY_BUILD=ON

1 Like

I’m doing something wrong, but I don’t know what I’m missing

unity build is optional and more meant to be used on CI and I would use ios 15 or 16 instead because of compatibility issues with 17.

So, try this:

cmake .. -G Xcode -D IOS=ON -D DEPLOYMENT_TARGET=15
1 Like

I re-read this post and added NODE_ADDON_API_ and it solved the problem. However, I still get an error and am not able to build.
It’s a pretty complicated build system, so I’m going to read Configure XCode manually carefully and try to unravel it a little bit at a time. Thanks again.

Hi, ive successfully built BabylonNative into a XCode project on iOS, following instruction HERE

cmake -B build/iOS -G Xcode -D IOS=ON

im now trying to copy binaries and headers to a install folder

cmake --install . --prefix="./install"

although receiving the following error:

any advice would be appreciated, thanks.

Babylon Native (v7.12.0)
master branch - d0c97077d07da3a4f07d92473155db11c2e5a6c3

I’m taking a look!

EDIT: I can repro. I’m working on a fix…

1 Like

Can you check this fix works on your side

Installation expects a Release build to be available.

2 Likes

Hi @Cedric, that seems to have worked!
Tomorrow I’ll try including these files in a project with fresh eyes.

Just a note for the next person doing this:
cmake --install build/iOS --prefix="./install" failed and expected an absolute path.
cmake --install build/iOS --prefix="/Users/absolutepath/BabylonNative/build/iOS/install" worked.


Q1
i was expecting to see more folders for all the other libraries in the include folder.
just want to confirm the screen grab below is correct?


Q2
how to go about building Debug binaries?

many thanks!

yes, for iOS, prefix needs to be absolute path. I need to put that somewhere in the documentation.
It looks good to me for the include folder. I can see the same files for the win32 install.
Debug symbols should still be present in static libs because there is no task in the toolchain to strip them. You can check using nm tool.

1 Like

ok its working!
ive added the files and configured my existing XCode project and have the experience.js examples working. amazing, thanks @Cedric for your help.

one issue i ran into was the cmake --install process did not build libxr.a
for now, ive copied this file directly from the BabylonNative XCode project.
it would be good if install/lib/libxr.a was also provided so others don’t get tripped up by this.

another issues which was specific to my project but others might experience,
in Build Settings, C++ Language Dialect had to be changed to C++17 since the default setting for my project was using C++11

Good catch for libxr! I’ve updated Test installation iOS/Linux/MacOS by CedricGuillemet · Pull Request #1401 · BabylonJS/BabylonNative · GitHub
Yes, c++17 is now old enough to consider it the minimum version of c++ language.