Skip to content

Commit 4ab397c

Browse files
committed
Document generate_bundle=yes SCons option in Compiling for macOS and iOS
- Reorder instructions to mention ARM64 builds first in macOS, as this is the primary architecture in use now (with all new Macs since 2023 being sold with Apple Silicon only). The `lipo` command still works as before, as it infers the architecture from the input files. - Remove the manual bundle generation steps to make the page shorter (similar to Compiling for Android). - Remove references to the master branch (this was only relevant when 4.0 was still in development).
1 parent 26769a6 commit 4ab397c

File tree

3 files changed

+41
-58
lines changed

3 files changed

+41
-58
lines changed

contributing/development/compiling/compiling_for_ios.rst

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ Requirements
2020
Xcode and need to install iOS support, go to *Xcode -> Settings... -> Platforms*.
2121
- Go to *Xcode -> Settings... -> Locations -> Command Line Tools* and select
2222
an installed version. Even if one is already selected, re-select it.
23-
24-
If you are building the ``master`` branch:
25-
2623
- Download and follow README instructions to build a static ``.xcframework``
2724
from the `MoltenVK SDK <https://github.com/KhronosGroup/MoltenVK#fetching-moltenvk-source-code>`__.
2825

@@ -49,46 +46,40 @@ If you are building the ``master`` branch:
4946
Compiling
5047
---------
5148

52-
Open a Terminal, go to the root dir of the engine source code and type:
49+
Open a Terminal, go to the root folder of the engine source code and type
50+
the following to compile a debug build:
5351

5452
::
5553

56-
scons platform=ios target=template_debug
54+
scons platform=ios target=template_debug generate_bundle=yes
5755

58-
for a debug build, or:
56+
To compile a release build:
5957

6058
::
6159

62-
scons platform=ios target=template_release
63-
64-
for a release build (check ``platform/ios/detect.py`` for the compiler
65-
flags used for each configuration).
60+
scons platform=ios target=template_release generate_bundle=yes
6661

67-
Alternatively, you can run
62+
Alternatively, you can run the following command for Xcode simulator libraries (optional):
6863

6964
::
7065

71-
scons platform=ios target=template_debug ios_simulator=yes arch=x86_64
7266
scons platform=ios target=template_debug ios_simulator=yes arch=arm64
67+
scons platform=ios target=template_debug ios_simulator=yes arch=x86_64 generate_bundle=yes
7368

74-
for a Simulator libraries.
69+
These simulator libraries cannot be used to run the exported project on the
70+
target device. Instead, they can be used to run the exported project directly on
71+
your Mac while still testing iOS platform-specific functionality.
7572

7673
To create an Xcode project like in the official builds, you need to use the
7774
template located in ``misc/dist/ios_xcode``. The release and debug libraries
78-
should be placed in ``libgodot.ios.debug.xcframework`` and ``libgodot.ios.release.xcframework`` respectively.
79-
80-
::
81-
82-
cp -r misc/dist/ios_xcode .
83-
84-
cp libgodot.ios.template_debug.arm64.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64/libgodot.a
85-
lipo -create libgodot.ios.template_debug.arm64.simulator.a libgodot.ios.template_debug.x86_64.simulator.a -output ios_xcode/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a
86-
87-
cp libgodot.ios.template_release.arm64.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64/libgodot.a
88-
lipo -create libgodot.ios.template_release.arm64.simulator.a libgodot.ios.template_release.x86_64.simulator.a -output ios_xcode/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a
89-
90-
The MoltenVK static ``.xcframework`` folder must also be placed in the ``ios_xcode``
91-
folder once it has been created.
75+
should be placed in ``libgodot.ios.debug.xcframework`` and
76+
``libgodot.ios.release.xcframework`` respectively. This process can be automated
77+
by using the ``generate_bundle=yes`` option on the *last* SCons command used to
78+
build export templates (so that all binaries can be included).
79+
80+
The MoltenVK static ``.xcframework`` folder must also be placed in the
81+
``ios_xcode`` folder once it has been created. MoltenVK is always statically
82+
linked on iOS; there is no dynamic linking option available, unlike macOS.
9283

9384
Run
9485
---

contributing/development/compiling/compiling_for_macos.rst

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -119,54 +119,46 @@ To build macOS export templates, you have to compile using the targets without
119119
the editor: ``target=template_release`` (release template) and
120120
``target=template_debug``.
121121

122-
Official templates are universal binaries which support both Intel x86_64 and
123-
ARM64 architectures. You can also create export templates that support only one
124-
of those two architectures by leaving out the ``lipo`` step below.
122+
Official templates are *Universal 2* binaries which support both ARM64 and Intel
123+
x86_64 architectures.
125124

126-
- For Intel x86_64::
125+
- To support ARM64 (Apple Silicon) + Intel x86_64::
127126

128-
scons platform=macos target=template_release arch=x86_64
127+
scons platform=macos target=template_debug arch=arm64
128+
scons platform=macos target=template_release arch=arm64
129129
scons platform=macos target=template_debug arch=x86_64
130+
scons platform=macos target=template_release arch=x86_64 generate_bundle=yes
130131

131-
- For Arm64 (Apple M1)::
132+
- To support ARM64 (Apple Silicon) only (smaller file size, but less compatible with older hardware)::
132133

133-
scons platform=macos target=template_release arch=arm64
134134
scons platform=macos target=template_debug arch=arm64
135-
136-
To support both architectures in a single "Universal 2" binary, run the above
137-
two commands blocks and then use ``lipo`` to bundle them together::
138-
139-
lipo -create bin/godot.macos.template_release.x86_64 bin/godot.macos.template_release.arm64 -output bin/godot.macos.template_release.universal
140-
lipo -create bin/godot.macos.template_debug.x86_64 bin/godot.macos.template_debug.arm64 -output bin/godot.macos.template_debug.universal
135+
scons platform=macos target=template_release arch=arm64 generate_bundle=yes
141136

142137
To create an ``.app`` bundle like in the official builds, you need to use the
143-
template located in ``misc/dist/macos_template.app``. The release and debug
144-
builds should be placed in ``macos_template.app/Contents/MacOS`` with the names
145-
``godot_macos_release.universal`` and ``godot_macos_debug.universal`` respectively. You can do so
146-
with the following commands (assuming a universal build, otherwise replace the
147-
``.universal`` extension with the one of your arch-specific binaries)::
148-
149-
cp -r misc/dist/macos_template.app .
150-
mkdir -p macos_template.app/Contents/MacOS
151-
cp bin/godot.macos.template_release.universal macos_template.app/Contents/MacOS/godot_macos_release.universal
152-
cp bin/godot.macos.template_debug.universal macos_template.app/Contents/MacOS/godot_macos_debug.universal
153-
chmod +x macos_template.app/Contents/MacOS/godot_macos*
138+
template located in ``misc/dist/macos_template.app``. This process can be automated by using
139+
the ``generate_bundle=yes`` option on the *last* SCons command used to build export templates
140+
(so that all binaries can be included). This option also takes care of calling ``lipo`` to create
141+
an *Universal 2* binary from two separate ARM64 and x86_64 binaries (if both were compiled beforehand).
154142

155143
.. note::
156144

157-
If you are building the ``master`` branch, you also need to include support
158-
for the MoltenVK Vulkan portability library. By default, it will be linked
159-
statically from your installation of the Vulkan SDK for macOS.
160-
You can also choose to link it dynamically by passing ``use_volk=yes`` and
161-
including the dynamic library in your ``.app`` bundle::
145+
You also need to include support for the MoltenVK Vulkan portability
146+
library. By default, it will be linked statically from your installation of
147+
the Vulkan SDK for macOS. You can also choose to link it dynamically by
148+
passing ``use_volk=yes`` and including the dynamic library in your ``.app``
149+
bundle::
162150

163151
mkdir -p macos_template.app/Contents/Frameworks
164152
cp <Vulkan SDK path>/macOS/libs/libMoltenVK.dylib macos_template.app/Contents/Frameworks/libMoltenVK.dylib
165153

154+
In most cases, static linking should be preferred as it makes distribution
155+
easier. The main upside of dynamic linking is that it allows updating
156+
MoltenVK without having to recompile export templates.
157+
166158
You can then zip the ``macos_template.app`` folder to reproduce the ``macos.zip``
167159
template from the official Godot distribution::
168160

169-
zip -q -9 -r macos.zip macos_template.app
161+
zip -r9 macos.zip macos_template.app
170162

171163
Using Pyston for faster development
172164
-----------------------------------

tutorials/export/exporting_for_macos.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Exporting for macOS
1111

1212
macOS apps exported with the official export templates are exported as a single "Universal 2" binary ``.app`` bundle, a folder with a specific structure which stores the executable, libraries and all the project files.
1313
This bundle can be exported as is, packed in a ZIP archive or DMG disk image (only supported when exporting from a computer running macOS).
14-
`Universal binaries for macOS support both Intel x86_64 and ARM64 (Apple silicon, i.e. M1) architectures <https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary>`__.
14+
`Universal binaries for macOS support both Intel x86_64 and ARM64 (Apple Silicon) architectures <https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary>`__.
1515

1616
.. warning::
1717
Due to file system limitations, raw ``.app`` bundles exported from Windows lack ``executable`` flag and won't run on macOS.

0 commit comments

Comments
 (0)