Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] iOS/MacOS build and export improvements #205

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions drivers/coreaudio/audio_driver_coreaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ OSStatus AudioDriverCoreAudio::output_device_address_cb(AudioObjectID inObjectID

return noErr;
}

// Switch to kAudioObjectPropertyElementMain everywhere to remove deprecated warnings.
#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED < 120000) || (TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED < 150000)
#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
#endif
#endif

Error AudioDriverCoreAudio::init() {
Expand All @@ -89,7 +94,7 @@ Error AudioDriverCoreAudio::init() {
AudioObjectPropertyAddress prop;
prop.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
prop.mScope = kAudioObjectPropertyScopeGlobal;
prop.mElement = kAudioObjectPropertyElementMaster;
prop.mElement = kAudioObjectPropertyElementMain;

result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &prop, &output_device_address_cb, this);
ERR_FAIL_COND_V(result != noErr, FAILED);
Expand Down Expand Up @@ -319,7 +324,7 @@ void AudioDriverCoreAudio::finish() {
AudioObjectPropertyAddress prop;
prop.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
prop.mScope = kAudioObjectPropertyScopeGlobal;
prop.mElement = kAudioObjectPropertyElementMaster;
prop.mElement = kAudioObjectPropertyElementMain;

result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &prop, &output_device_address_cb, this);
if (result != noErr) {
Expand Down Expand Up @@ -358,7 +363,7 @@ Error AudioDriverCoreAudio::init_input_device() {
AudioObjectPropertyAddress prop;
prop.mSelector = kAudioHardwarePropertyDefaultInputDevice;
prop.mScope = kAudioObjectPropertyScopeGlobal;
prop.mElement = kAudioObjectPropertyElementMaster;
prop.mElement = kAudioObjectPropertyElementMain;

result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &prop, &input_device_address_cb, this);
ERR_FAIL_COND_V(result != noErr, FAILED);
Expand All @@ -375,7 +380,7 @@ Error AudioDriverCoreAudio::init_input_device() {
#ifdef MACOS_ENABLED
AudioDeviceID deviceId;
size = sizeof(AudioDeviceID);
AudioObjectPropertyAddress property = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
AudioObjectPropertyAddress property = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain };

result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &deviceId);
ERR_FAIL_COND_V(result != noErr, FAILED);
Expand Down Expand Up @@ -453,7 +458,7 @@ void AudioDriverCoreAudio::finish_input_device() {
AudioObjectPropertyAddress prop;
prop.mSelector = kAudioHardwarePropertyDefaultInputDevice;
prop.mScope = kAudioObjectPropertyScopeGlobal;
prop.mElement = kAudioObjectPropertyElementMaster;
prop.mElement = kAudioObjectPropertyElementMain;

result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &prop, &input_device_address_cb, this);
if (result != noErr) {
Expand Down Expand Up @@ -504,7 +509,7 @@ PackedStringArray AudioDriverCoreAudio::_get_device_list(bool input) {

prop.mSelector = kAudioHardwarePropertyDevices;
prop.mScope = kAudioObjectPropertyScopeGlobal;
prop.mElement = kAudioObjectPropertyElementMaster;
prop.mElement = kAudioObjectPropertyElementMain;

UInt32 size = 0;
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, nullptr, &size);
Expand Down Expand Up @@ -563,7 +568,7 @@ void AudioDriverCoreAudio::_set_device(const String &output_device, bool input)

prop.mSelector = kAudioHardwarePropertyDevices;
prop.mScope = kAudioObjectPropertyScopeGlobal;
prop.mElement = kAudioObjectPropertyElementMaster;
prop.mElement = kAudioObjectPropertyElementMain;

UInt32 size = 0;
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, nullptr, &size);
Expand Down Expand Up @@ -619,7 +624,7 @@ void AudioDriverCoreAudio::_set_device(const String &output_device, bool input)
// If we haven't found the desired device get the system default one
UInt32 size = sizeof(AudioDeviceID);
UInt32 elem = input ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice;
AudioObjectPropertyAddress property = { elem, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
AudioObjectPropertyAddress property = { elem, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain };

OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &deviceId);
ERR_FAIL_COND(result != noErr);
Expand Down
2 changes: 1 addition & 1 deletion misc/dist/ios_xcode/godot_ios/godot_ios.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
$entitlements_push_notifications
$entitlements_full
</dict>
</plist>
11 changes: 8 additions & 3 deletions misc/dist/macos_template.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ $usage_descriptions
<string>NSApplication</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.$app_category</string>
<key>LSMinimumSystemVersion</key>
<string>$min_version</string>
<key>LSArchitecturePriority</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>LSMinimumSystemVersionByArchitecture</key>
<dict>
<key>arm64</key>
<string>$min_version_arm64</string>
<key>x86_64</key>
<string>$min_version</string>
<string>$min_version_x86_64</string>
</dict>
<key>NSHighResolutionCapable</key>
$highres
Expand Down
13 changes: 10 additions & 3 deletions misc/dist/macos_tools.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>4.3</string>
<key>CFBundleSignature</key>
<string>blazium</string>
<string>BLAZ</string>
<key>CFBundleVersion</key>
<string>4.3</string>
<key>NSMicrophoneUsageDescription</key>
Expand All @@ -28,6 +28,8 @@
<string>Camera access is required to capture video.</string>
<key>NSRequiresAquaSystemAppearance</key>
<false/>
<key>NSCameraUseContinuityCameraDeviceType</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>© 2024-present Blazium Engine Contributors &amp; © 2007-present Juan Linietsky, Ariel Manzur &amp; Godot Engine contributors</string>
<key>CFBundleSupportedPlatforms</key>
Expand All @@ -38,10 +40,15 @@
<string>NSApplication</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>10.12</string>
<key>LSArchitecturePriority</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>LSMinimumSystemVersionByArchitecture</key>
<dict>
<key>arm64</key>
<string>11.0</string>
<key>x86_64</key>
<string>10.12</string>
</dict>
Expand Down
14 changes: 10 additions & 4 deletions modules/camera/camera_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,17 @@ - (void)dealloc {
// CameraMacOS - Subclass for our camera server on macOS

void CameraMacOS::update_feeds() {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
AVCaptureDeviceDiscoverySession *session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:[NSArray arrayWithObjects:AVCaptureDeviceTypeExternalUnknown, AVCaptureDeviceTypeBuiltInWideAngleCamera, nil] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
NSArray *devices = session.devices;
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
AVCaptureDeviceDiscoverySession *session;
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 140000
// Avoid deprecated warning if the minimum SDK is 14.0.
session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:[NSArray arrayWithObjects:AVCaptureDeviceTypeExternal, AVCaptureDeviceTypeBuiltInWideAngleCamera, nil] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
#else
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
session = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:[NSArray arrayWithObjects:AVCaptureDeviceTypeExternalUnknown, AVCaptureDeviceTypeBuiltInWideAngleCamera, nil] mediaType:AVMediaTypeVideo position:AVCaptureDevicePositionUnspecified];
#endif
NSArray<AVCaptureDevice *> *devices = session.devices;
#else
NSArray<AVCaptureDevice *> *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
#endif

// remove devices that are gone..
Expand Down
22 changes: 19 additions & 3 deletions platform/ios/doc_classes/EditorExportPlatformIOS.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
<member name="capabilities/access_wifi" type="bool" setter="" getter="">
If [code]true[/code], networking features related to Wi-Fi access are enabled. See [url=https://developer.apple.com/support/required-device-capabilities/]Required Device Capabilities[/url].
</member>
<member name="capabilities/additional" type="PackedStringArray" setter="" getter="">
Additional data added to the [code]UIRequiredDeviceCapabilities[/code] array of the [code]Info.plist[/code] file.
</member>
<member name="capabilities/performance_a12" type="bool" setter="" getter="">
Requires the graphics performance and features of the A12 Bionic and later chips (devices supporting all Vulkan renderer features).
Enabling this option limits supported devices to: iPhone XS, iPhone XR, iPad Mini (5th gen.), iPad Air (3rd gen.), iPad (8th gen) and newer.
Expand All @@ -84,15 +87,28 @@
Requires the graphics performance and features of the A17 Pro and later chips.
Enabling this option limits supported devices to: iPhone 15 Pro and newer.
</member>
<member name="capabilities/push_notifications" type="bool" setter="" getter="">
If [code]true[/code], push notifications are enabled. See [url=https://developer.apple.com/support/required-device-capabilities/]Required Device Capabilities[/url].
</member>
<member name="custom_template/debug" type="String" setter="" getter="">
Path to the custom export template. If left empty, default template is used.
</member>
<member name="custom_template/release" type="String" setter="" getter="">
Path to the custom export template. If left empty, default template is used.
</member>
<member name="entitlements/additional" type="String" setter="" getter="">
Additional data added to the root [code]&lt;dict&gt;[/code] section of the [url=https://developer.apple.com/documentation/bundleresources/entitlements].entitlements[/url] file. The value should be an XML section with pairs of key-value elements, for example:
[codeblock lang=text]
&lt;key&gt;key_name&lt;/key&gt;
&lt;string&gt;value&lt;/string&gt;
[/codeblock]
</member>
<member name="entitlements/game_center" type="bool" setter="" getter="">
Enable to allow access to Game Center features. [url=https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_game-center]com.apple.developer.game-center[/url].
</member>
<member name="entitlements/increased_memory_limit" type="bool" setter="" getter="">
Enable if app may perform better with a higher memory limit. [url=https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_kernel_increased-memory-limit]com.apple.developer.kernel.increased-memory-limit[/url].
</member>
<member name="entitlements/push_notifications" type="String" setter="" getter="">
Environment for Apple Push Notification service. See [url=https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment]aps-environment[/url].
</member>
<member name="icons/app_store_1024x1024" type="String" setter="" getter="">
App Store application icon file. If left empty, it will fallback to [member ProjectSettings.application/config/icon]. See [url=https://developer.apple.com/design/human-interface-guidelines/foundations/app-icons]App icons[/url].
</member>
Expand Down
27 changes: 23 additions & 4 deletions platform/ios/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,15 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
plugins_changed.clear();
plugins = found_plugins;

r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "entitlements/increased_memory_limit"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "entitlements/game_center"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "entitlements/push_notifications", PROPERTY_HINT_ENUM, "Disabled,Production,Development"), "Disabled"));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "entitlements/additional", PROPERTY_HINT_MULTILINE_TEXT), ""));

r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/access_wifi"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/push_notifications"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/performance_gaming_tier"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/performance_a12"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "capabilities/additional"), PackedStringArray()));

r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "user_data/accessible_from_files_app"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "user_data/accessible_from_itunes_sharing"), false));
Expand Down Expand Up @@ -481,9 +486,20 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
strnew += lines[i].replace("$docs_in_place", ((bool)p_preset->get("user_data/accessible_from_files_app")) ? "<true/>" : "<false/>") + "\n";
} else if (lines[i].contains("$docs_sharing")) {
strnew += lines[i].replace("$docs_sharing", ((bool)p_preset->get("user_data/accessible_from_itunes_sharing")) ? "<true/>" : "<false/>") + "\n";
} else if (lines[i].contains("$entitlements_push_notifications")) {
bool is_on = p_preset->get("capabilities/push_notifications");
strnew += lines[i].replace("$entitlements_push_notifications", is_on ? "<key>aps-environment</key><string>development</string>" : "") + "\n";
} else if (lines[i].contains("$entitlements_full")) {
String entitlements;
if ((String)p_preset->get("entitlements/push_notifications") != "Disabled") {
entitlements += "<key>aps-environment</key>\n<string>" + p_preset->get("entitlements/push_notifications").operator String().to_lower() + "</string>" + "\n";
}
if ((bool)p_preset->get("entitlements/game_center")) {
entitlements += "<key>com.apple.developer.game-center</key>\n<true/>\n";
}
if ((bool)p_preset->get("entitlements/increased_memory_limit")) {
entitlements += "<key>com.apple.developer.kernel.increased-memory-limit</key>\n<true/>\n";
}
entitlements += p_preset->get("entitlements/additional").operator String() + "\n";

strnew += lines[i].replace("$entitlements_full", entitlements);
} else if (lines[i].contains("$required_device_capabilities")) {
String capabilities;

Expand All @@ -504,6 +520,9 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
for (int idx = 0; idx < capabilities_list.size(); idx++) {
capabilities += "<string>" + capabilities_list[idx] + "</string>\n";
}
for (const String &cap : p_preset->get("capabilities/additional").operator PackedStringArray()) {
capabilities += "<string>" + cap + "</string>\n";
}

strnew += lines[i].replace("$required_device_capabilities", capabilities);
} else if (lines[i].contains("$interface_orientations")) {
Expand Down
4 changes: 4 additions & 0 deletions platform/ios/godot_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,17 @@ - (void)handleMotion {

UIInterfaceOrientation interfaceOrientation = UIInterfaceOrientationUnknown;

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 140000
interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
#else
if (@available(iOS 13, *)) {
interfaceOrientation = [UIApplication sharedApplication].delegate.window.windowScene.interfaceOrientation;
#if !defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR
} else {
interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
#endif
}
#endif

switch (interfaceOrientation) {
case UIInterfaceOrientationLandscapeLeft: {
Expand Down
2 changes: 1 addition & 1 deletion platform/macos/display_server_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2342,7 +2342,7 @@
wd.wb_offset = p_offset / scale;
wd.wb_offset = wd.wb_offset.maxi(12);
if (wd.window_button_view) {
[wd.window_button_view setOffset:NSMakePoint(wd.wb_offset.x, wd.wb_offset.y)];
[(GodotButtonView *)wd.window_button_view setOffset:NSMakePoint(wd.wb_offset.x, wd.wb_offset.y)];
}
}

Expand Down
17 changes: 10 additions & 7 deletions platform/macos/doc_classes/EditorExportPlatformMacOS.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
<member name="application/icon_interpolation" type="int" setter="" getter="">
Interpolation method used to resize application icon.
</member>
<member name="application/min_macos_version" type="String" setter="" getter="">
Minimum version of macOS required for this application to run in the [code]major.minor.patch[/code] or [code]major.minor[/code] format, can only contain numeric characters ([code]0-9[/code]) and periods ([code].[/code]).
<member name="application/min_macos_version_arm64" type="String" setter="" getter="">
Minimum version of macOS required for this application to run on Apple Silicon Macs, in the [code]major.minor.patch[/code] or [code]major.minor[/code] format, can only contain numeric characters ([code]0-9[/code]) and periods ([code].[/code]).
</member>
<member name="application/min_macos_version_x86_64" type="String" setter="" getter="">
Minimum version of macOS required for this application to run on Intel Macs, in the [code]major.minor.patch[/code] or [code]major.minor[/code] format, can only contain numeric characters ([code]0-9[/code]) and periods ([code].[/code]).
</member>
<member name="application/short_version" type="String" setter="" getter="">
Application version visible to the user, can only contain numeric characters ([code]0-9[/code]) and periods ([code].[/code]). Falls back to [member ProjectSettings.application/config/version] if left empty.
Expand Down Expand Up @@ -73,11 +76,11 @@
Array of the additional command line arguments passed to the code signing tool.
</member>
<member name="codesign/entitlements/additional" type="String" setter="" getter="">
Additional data added to the root [code]&lt;dict&gt;[/code] section of the [url=https://developer.apple.com/documentation/bundleresources/entitlements].entitlements[/url] file. The value should be an XML section with pairs of key-value elements, e.g.:
[codeblock lang=text]
&lt;key&gt;key_name&lt;/key&gt;
&lt;string&gt;value&lt;/string&gt;
[/codeblock]
Additional data added to the root [code]&lt;dict&gt;[/code] section of the [url=https://developer.apple.com/documentation/bundleresources/entitlements].entitlements[/url] file. The value should be an XML section with pairs of key-value elements, for example:
[codeblock lang=text]
&lt;key&gt;key_name&lt;/key&gt;
&lt;string&gt;value&lt;/string&gt;
[/codeblock]
</member>
<member name="codesign/entitlements/address_book" type="bool" setter="" getter="">
Enable to allow access to contacts in the user's address book, if it's enabled you should also provide usage message in the [member privacy/address_book_usage_description] option. See [url=https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_personal-information_addressbook]com.apple.security.personal-information.addressbook[/url].
Expand Down
Loading
Loading