# How do I compile Babylon.js project into Iphone app?

**URL:** <https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088>\
**Category:** Questions\
**Created:** [June 30, 2020, 9:10am UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088 "2020-06-30T09:10:07Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johny\_Mickey](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johny_mickey/32/24948_2.png) [@Johny\_Mickey](https://forum.babylonjs.com/u/Johny_Mickey)\
**Post date:** [June 30, 2020, 9:10am UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/1 "2020-06-30T09:10:08Z")

</div>

Hello dudes,

how can I compile a program in Babylon.js into Iphone format? I want to run the program not in a browser but as an iphone application. Is tehre a way how to do it? Is there any instructions, or better tutorial for this? I searched the internet for information but did not find real tutorial. thanks for explaining in advance.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 30, 2020, 12:10pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/2 "2020-06-30T12:10:14Z")

</div>

So for most web frameworks it would be pretty hard but fortunately, despite being still early maybe what you are looking into is babylon native 🙂

Let me add @bghgary and @Cedric who can provide more info on this front.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [June 30, 2020, 7:43pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/3 "2020-06-30T19:43:40Z")

</div>

Website: [https://www.babylonjs.com/native](https://www.babylonjs.com/native)  
GitHub: [GitHub - BabylonJS/BabylonNative: Build cross-platform native applications with the power of the Babylon.js JavaScript framework](https://github.com/BabylonJS/BabylonNative)

That should give you an idea hopefully.

---

<div class="post-metadata">

**Author:** ![Johny\_Mickey](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johny_mickey/32/24948_2.png) [@Johny\_Mickey](https://forum.babylonjs.com/u/Johny_Mickey)\
**Post date:** [July 1, 2020, 3:48pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/4 "2020-07-01T15:48:41Z")

</div>

Thanks for your answer. Link number one is going to the Babylon.js native promotional page. Something about multiplatformity… For more information, see the babylon.js forum and friendly community(important note :D). See link 2 for more information. A) you can download babylon.js native. But there is no executable file anywhere. Is CMake likely to build it? I tried to use cmake-gui.exe, but I got a compilation error. From the materials I still do not understand the philosophy of workflow, operation, assembly…Why should I use some other external programs like CMake?

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 1, 2020, 3:56pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/5 "2020-07-01T15:56:02Z")

</div>

Babylon Native does not have a prebuilt executable as it’s a library intended to be integrated into an executable. It’s up to you how to do that. You need to build it yourself using the instructions from the [readme](https://github.com/BabylonJS/BabylonNative#quick-start-guide).

Perhaps this is not what you are looking for? Maybe you are looking for [progressive web apps](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)?

---

<div class="post-metadata">

**Author:** ![Johny\_Mickey](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johny_mickey/32/24948_2.png) [@Johny\_Mickey](https://forum.babylonjs.com/u/Johny_Mickey)\
**Post date:** [July 1, 2020, 4:25pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/6 "2020-07-01T16:25:09Z")

</div>

Thanks for next info. I will read more about it then I can make more concrete question.

---

<div class="post-metadata">

**Author:** ![DisownedWheat](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@DisownedWheat](https://forum.babylonjs.com/u/DisownedWheat)\
**Post date:** [July 2, 2020, 5:34am UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/7 "2020-07-02T05:34:23Z")

</div>

You could also look at some tools like [Cordova](https://cordova.apache.org/) or [Ionic](https://ionicframework.com/) but a PWA is a much easier option.

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [July 2, 2020, 8:47am UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/8 "2020-07-02T08:47:36Z")

</div>

> [@bghgary](#):
>
> Website: [https://www.babylonjs.com/native](https://www.babylonjs.com/native)  
> GitHub: [GitHub - BabylonJS/BabylonNative: Build cross-platform native applications with the power of the Babylon.js JavaScript framework](https://github.com/BabylonJS/BabylonNative)

Holy Crap Nuts 🙂

i just really taking a look at this and the native project… And Holy Crap Nuts 🙂

Yo @bghgary … You know i gonna have a few questions about how to actually implement a project in BabylonNative.

First of all, from what i can tell the **KEY** native code that really does everything is the **Babylon::ScriptLoader** class. This looks like some kind of encapsulated V8 Javascript Engine for Babylon.js runtime (basically any javascript is looks like ???). You can **eval** script right into the **runtime loader** or actually **LoadScript** using the **app://** protocol.

Thats really it… all it does from a native host application point of view (besides some native input manager pointer stuff).

The fact that is render scene content or loading gltf scene files is because one of the loaded javascript files is using babylon javascript to create a scene and optionally append gltf scene content… And script code starts the engine render loop… basically the same kind of shit you would do in Babylon Playground… Again… Holy Crap Nuts 🙂

QUESTIONS:

1… Should i be able to run my SceneManager extension that registers its GLTF Loader so my Unity GLTF Parsing that i use in a regular babylon.js environment (provided I remove all the HTML DOM stuff)

2… Does **console.log** and **console.warn** work in BabylonNative ???

3… Does GLTF PBR Materials and shaders work… Basically can i still use PBRCustomMaterial the way i do in a regular babylon.js environment ???

4… Does babylon.gui.js work ???

Am i on the right track ???

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 2, 2020, 5:52pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/9 "2020-07-02T17:52:44Z")

</div>

> [@MackeyK24](#):
>
> 1… Should i be able to run my SceneManager extension that registers its GLTF Loader so my Unity GLTF Parsing that i use in a regular babylon.js environment (provided I remove all the HTML DOM stuff)

Yes, once everything is in place. There will be bugs. 🙂

> [@MackeyK24](#):
>
> 2… Does **console.log** and **console.warn** work in BabylonNative ???

Yes. Though all it does right now is log to the debug output in the examples. This can be replaced to anything you want.

> [@MackeyK24](#):
>
> 3… Does GLTF PBR Materials and shaders work… Basically can i still use PBRCustomMaterial the way i do in a regular babylon.js environment ???

Yes, once all the shader processing issues are resolved. We haven’t tested PBRCustomMaterials yet, but it should work.

> [@MackeyK24](#):
>
> 4… Does babylon.gui.js work ???

3D GUI should work barring font rendering which we are eventually going to do, but it’s not there right now. 2D GUI uses HTML, so that’s not in scope.

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [July 3, 2020, 12:42am UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/10 "2020-07-03T00:42:22Z")

</div>

How do you specify what javascript you want available ??

Cant tell how it knows what script files to package up that will be available via the app:// protocol ???

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 6, 2020, 7:05pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/11 "2020-07-06T19:05:38Z")

</div>

> [@MackeyK24](#):
>
> How do you specify what javascript you want available ??

The ScriptLoader is intended help with this. Call ScriptLoader::LoadScript to load scripts in order. The contract for this class is not fully baked yet as it behaves a bit strange in some situation, but it should work for simple cases.

> [@MackeyK24](#):
>
> Cant tell how it knows what script files to package up that will be available via the app:// protocol ???

This is up to the app. Babylon Native is currently a static library. The app consuming Babylon Native is responsible for how the package is built. The `app:///` protocol will get the file inside the app package. It is different depending on which platform. Android uses `AAssetManager`. iOS/macOS uses `[NSBundle mainBundle]`. Window UWP uses `ApplicationModel::Package::Current().InstalledLocation().GetFileAsync`. WIN32 currently doesn’t support `app:///` protocol, but maybe it can load from the executable path. This part certainly can use some documentation. 🙂

---

<div class="post-metadata">

**Author:** ![blairmacintyre](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blairmacintyre/32/6398_2.png) [@blairmacintyre](https://forum.babylonjs.com/u/blairmacintyre)\
**Post date:** [October 22, 2020, 7:36pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/12 "2020-10-22T19:36:16Z")

</div>

(reviving)

Is there a way to load scripts from Javascript? (on the web, I’d just append a script tag to the DOM). So, for example, is `loadScript` exposed somehow? I admit that for debugging, being able to set up the app to dump and reload the scripts without rebuilding would be nice.

What about debugging? Can I point a web browser debugger at this somehow?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 22, 2020, 7:40pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/13 "2020-10-22T19:40:10Z")

</div>

@bghgary, @Cedric and @syntheticmagus are our best bet on this front 🙂

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [October 22, 2020, 8:41pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/14 "2020-10-22T20:41:50Z")

</div>

> [@blairmacintyre](#):
>
> Is there a way to load scripts from Javascript? (on the web, I’d just append a script tag to the DOM). So, for example, is `loadScript` exposed somehow?

The contract for this is not stable yet, but you can right now use BABYLON.Tools.LoadScript to do it (assuming you have Babylon.js already loaded). We are considering removing the C++ ScriptLoader contract and replacing it with something in JavaScript.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [October 22, 2020, 8:44pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/15 "2020-10-22T20:44:40Z")

</div>

> [@blairmacintyre](#):
>
> What about debugging? Can I point a web browser debugger at this somehow?

For HL2, this isn’t possible yet. We are investigating enabling Chrome DevTools for V8 when targeting HL2. If you are using Chakra and running on desktop, you can debug the JavaScript by using Visual Studio. Note that you can’t debug both C++ and JavaScript with one instance of Visual Studio. You can however debug both at the same time with two instances of VS.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [October 22, 2020, 8:47pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/16 "2020-10-22T20:47:28Z")

</div>

> [@blairmacintyre](#):
>
> I admit that for debugging, being able to set up the app to dump and reload the scripts without rebuilding would be nice.

Sorry for multiple messages. 🙂 We have a keyboard shortcut (‘R’) set up to reload the scripts in the sample playground app. This isn’t super easy to do with HL2, but it’s possible.

---

<div class="post-metadata">

**Author:** ![blairmacintyre](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blairmacintyre/32/6398_2.png) [@blairmacintyre](https://forum.babylonjs.com/u/blairmacintyre)\
**Post date:** [October 23, 2020, 2:01pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/17 "2020-10-23T14:01:27Z")

</div>

Thanks for all the replies @bghgary … you’re making me remember why I hated doing native, non-web apps (ugh, Unity) on mobile devices. 😆

Now that I have it working, these are all useful things to know and think about. I was mostly investigating for some colleagues who are wanting a web-based AR system on H2, and this seems feasible until/if the Hololens team gets a browser up with WebXR

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [October 23, 2020, 3:59pm UTC](https://forum.babylonjs.com/t/how-do-i-compile-babylon-js-project-into-iphone-app/12088/18 "2020-10-23T15:59:19Z")

</div>

> [@blairmacintyre](#):
>
> you’re making me remember why I hated doing native, non-web apps (ugh, Unity) on mobile devices

I know what you mean. 🙂 We will make this experience better for HL2. It’s not quite there yet right now.
