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

Add possibility to modify the macOS minimum version #4271

Merged
merged 1 commit into from
Feb 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ abstract class AbstractMacOSPlatformSettings : AbstractPlatformSettings() {
var dmgPackageVersion: String? = null
var dmgPackageBuildVersion: String? = null
var appCategory: String? = null
var minimumSystemVersion: String? = null


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ internal fun JvmApplicationContext.configurePlatformSettings(
)
packageTask.macAppStore.set(mac.appStore)
packageTask.macAppCategory.set(mac.appCategory)
packageTask.macMinimumSystemVersion.set(mac.minimumSystemVersion)
val defaultEntitlements = defaultResources.get { defaultEntitlements }
packageTask.macEntitlementsFile.set(mac.entitlementsFile.orElse(defaultEntitlements))
packageTask.macRuntimeEntitlementsFile.set(mac.runtimeEntitlementsFile.orElse(defaultEntitlements))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ abstract class AbstractJPackageTask @Inject constructor(
@get:Optional
val macAppCategory: Property<String?> = objects.nullableProperty()

@get:Input
@get:Optional
val macMinimumSystemVersion: Property<String?> = objects.nullableProperty()

@get:InputFile
@get:Optional
@get:PathSensitive(PathSensitivity.ABSOLUTE)
Expand Down Expand Up @@ -499,11 +503,12 @@ abstract class AbstractJPackageTask @Inject constructor(
.writeToFile(jpackageResources.ioFile.resolve("Info.plist"))

if (macAppStore.orNull == true) {
val systemVersion = macMinimumSystemVersion.orNull ?: "10.13"
val productDefPlistXml = """
<key>os</key>
<array>
<string>10.13</string>
</array>
<key>os</key>
<array>
<string>$systemVersion</string>
</array>
""".trimIndent()
InfoPlistBuilder(productDefPlistXml)
.writeToFile(jpackageResources.ioFile.resolve("product-def.plist"))
Expand Down Expand Up @@ -581,7 +586,8 @@ abstract class AbstractJPackageTask @Inject constructor(
private fun setInfoPlistValues(plist: InfoPlistBuilder) {
check(currentOS == OS.MacOS) { "Current OS is not macOS: $currentOS" }

plist[PlistKeys.LSMinimumSystemVersion] = "10.13"
val systemVersion = macMinimumSystemVersion.orNull ?: "10.13"
plist[PlistKeys.LSMinimumSystemVersion] = systemVersion
plist[PlistKeys.CFBundleDevelopmentRegion] = "English"
plist[PlistKeys.CFBundleAllowMixedLocalizations] = "true"
val packageName = packageName.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ abstract class AbstractNativeMacApplicationPackageAppDirTask : AbstractNativeMac
@get:Optional
val copyright: Property<String?> = objects.nullableProperty()

@get:Input
@get:Optional
val minimumSystemVersion: Property<String?> = objects.nullableProperty()

override fun createPackage(destinationDir: File, workingDir: File) {
val packageName = packageName.get()
val appDir = destinationDir.resolve("$packageName.app").apply { mkdirs() }
Expand All @@ -60,7 +64,7 @@ abstract class AbstractNativeMacApplicationPackageAppDirTask : AbstractNativeMac
}

private fun InfoPlistBuilder.setupInfoPlist(executableName: String) {
this[PlistKeys.LSMinimumSystemVersion] = KOTLIN_NATIVE_MIN_SUPPORTED_MAC_OS
this[PlistKeys.LSMinimumSystemVersion] = minimumSystemVersion.getOrElse(KOTLIN_NATIVE_MIN_SUPPORTED_MAC_OS)
this[PlistKeys.CFBundleDevelopmentRegion] = "English"
this[PlistKeys.CFBundleAllowMixedLocalizations] = "true"
this[PlistKeys.CFBundleExecutable] = executableName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<string>12.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleAllowMixedLocalizations</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ compose.desktop {
packageName = "TestPackage"
macOS {
dockName = "CustomDockName"
minimumSystemVersion = "12.0"
infoPlist {
extraKeysRawXml = extraInfoPlistKeys
}
Expand Down
2 changes: 2 additions & 0 deletions tutorials/Native_distributions_and_local_execution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ The following platform-specific options are available
* `packageName` — a name of the application;
* `dockName` — a name of the application displayed in the menu bar, the "About <App>" menu item, in the dock, etc.
Equals to `packageName` by default.
* `minimumSystemVersion` — a minimum macOS version required to run the application.
See [LSMinimumSystemVersion](https://developer.apple.com/documentation/bundleresources/information_property_list/lsminimumsystemversion) for details;
* `signing`, `notarization`, `provisioningProfile`, and `runtimeProvisioningProfile` — see
[the corresponding tutorial](/tutorials/Signing_and_notarization_on_macOS/README.md)
for details;
Expand Down
Loading