apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 990 forks source link

feat: add preference to disable MacOS target #1274

Closed tiagoappereira closed 4 weeks ago

tiagoappereira commented 1 year ago

Xcode 14 considers that iOS apps should support by default not only iPhone and iPad, but also Mac (with Apple Silicon processors). With the introduction of “Designed for iPad“, IPAs can be installed on these devices, and Apple wants to make this the default behaviour/experience.

Also, when apps with the Mac target are submitted to the App Store they are available for Mac by default as well. They can be found in a specific “iPhone & iPad Apps“ tab.

Therefore, with the suggested preference in this PR, developers can disable the aforementioned default behaviour.

Description

To disable Mac target, the following lines need to be added to the .pbxproj:

SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
The Mac support removal (or not) is controlled by a preference called SupportMac: SupportMac Mac target
N/A enabled
true enabled
false disabled

Testing

Created a local iOS Cordova project based on this cordova-ios branch and the .pbxproj was:

Checklist

dpogue commented 1 year ago

We have an existing target-device preference that supports handset, tablet, and universal as values, and sets the TARGETED_DEVICE_FAMILY.

Maybe we can find a way to add this functionality to that existing preference?

tiagoappereira commented 1 year ago

We have an existing target-device preference that supports handset, tablet, and universal as values, and sets the TARGETED_DEVICE_FAMILY.

Maybe we can find a way to add this functionality to that existing preference?

If the idea is to expand the target-device supported values, doing so would change what the preference represents. From the official documentation

This property maps directly to TARGETED_DEVICE_FAMILY in the xcode project.

which would no longer be true.

dpogue commented 1 year ago

The documentation can be updated to reflect what the preference actually does, so I wouldn't worry too much about that aspect.

I don't have strong feelings about it, but I do wonder if it's easier or more consistent to have a single preference that controls the output platforms (similar to the 3 checkboxes in Xcode) vs a combination of multiple preferences that might interact in unusual ways.

dpogue commented 1 year ago

My current thinking around this is to disable the iPad-on-macOS thing by default, and to allow explicitly building a macOS app from the same codebase targeting Catalyst. That means there would be an extra step for those who want to distribute a macOS app, but it should be a better result (in terms of user experience and platform fit) than the iPad-on-macOS option.