11package co.touchlab.xcode.cli
22
33import co.touchlab.kermit.Logger
4- import co.touchlab.xcode.cli.XcodeHelper.Defaults.nonApplePlugins
54import co.touchlab.xcode.cli.util.BackupHelper
65import co.touchlab.xcode.cli.util.Console
76import co.touchlab.xcode.cli.util.File
8- import co.touchlab.xcode.cli.util.fromString
97import co.touchlab.xcode.cli.util.Path
108import co.touchlab.xcode.cli.util.PropertyList
119import co.touchlab.xcode.cli.util.Shell
1210import co.touchlab.xcode.cli.util.Version
11+ import co.touchlab.xcode.cli.util.fromString
1312import kotlinx.serialization.SerialName
1413import kotlinx.serialization.Serializable
1514import kotlinx.serialization.json.Json
@@ -85,7 +84,7 @@ object XcodeHelper {
8584 checkNotNull(versionPlist.build?.trim()) { " Couldn't get build number of Xcode at $path ." }
8685 }
8786
88- if (Version .fromString (version) >= Version .fromString( " 15.3 " )) {
87+ if (version15_3_orHigher (version)) {
8988 return XcodeInstallation (
9089 version = version,
9190 build = build,
@@ -94,10 +93,11 @@ object XcodeHelper {
9493 }
9594
9695 val xcodeInfoPath = path / " Contents" / " Info"
97- val pluginCompatabilityIdResult = Shell .exec(" /usr/bin/defaults" , " read" , xcodeInfoPath.value, " DVTPlugInCompatibilityUUID" )
98- .checkSuccessful {
99- " Couldn't get plugin compatibility UUID from Xcode at ${path} ."
100- }
96+ val pluginCompatabilityIdResult =
97+ Shell .exec(" /usr/bin/defaults" , " read" , xcodeInfoPath.value, " DVTPlugInCompatibilityUUID" )
98+ .checkSuccessful {
99+ " Couldn't get plugin compatibility UUID from Xcode at ${path} ."
100+ }
101101 val pluginCompatabilityId = checkNotNull(pluginCompatabilityIdResult.output?.trim()) {
102102 " Couldn't get plugin compatibility ID of Xcode at path: ${path} ."
103103 }
@@ -167,8 +167,13 @@ object XcodeHelper {
167167 val pluginCompatabilityId : String? = null ,
168168 ) {
169169 val name: String = " Xcode $version ($build )"
170+
171+ fun supported (supportedXcodeUuids : Set <String >): Boolean = version15_3_orHigher(version) ||
172+ supportedXcodeUuids.contains(pluginCompatabilityId)
170173 }
171174
175+ fun version15_3_orHigher (version : String ) = Version .fromString(version) >= Version .fromString(" 15.3" )
176+
172177 @Serializable
173178 private data class SystemProfilerOutput (
174179 @SerialName(" SPDeveloperToolsDataType" )
@@ -216,6 +221,7 @@ object XcodeHelper {
216221 NonApplePlugins (value.dictionary)
217222 }
218223 }
224+
219225 fun PropertyList.nonApplePlugins (xcodeVersion : String ): NonApplePlugins {
220226 val backingDictionary = root.dictionary.getOrPut(nonApplePluginsKeyPrefix + xcodeVersion) {
221227 PropertyList .Object .Dictionary (
0 commit comments