1
1
package co.touchlab.xcode.cli
2
2
3
3
import co.touchlab.kermit.Logger
4
- import co.touchlab.xcode.cli.XcodeHelper.Defaults.nonApplePlugins
5
4
import co.touchlab.xcode.cli.util.BackupHelper
6
5
import co.touchlab.xcode.cli.util.Console
7
6
import co.touchlab.xcode.cli.util.File
8
- import co.touchlab.xcode.cli.util.fromString
9
7
import co.touchlab.xcode.cli.util.Path
10
8
import co.touchlab.xcode.cli.util.PropertyList
11
9
import co.touchlab.xcode.cli.util.Shell
12
10
import co.touchlab.xcode.cli.util.Version
11
+ import co.touchlab.xcode.cli.util.fromString
13
12
import kotlinx.serialization.SerialName
14
13
import kotlinx.serialization.Serializable
15
14
import kotlinx.serialization.json.Json
@@ -85,7 +84,7 @@ object XcodeHelper {
85
84
checkNotNull(versionPlist.build?.trim()) { " Couldn't get build number of Xcode at $path ." }
86
85
}
87
86
88
- if (Version .fromString (version) >= Version .fromString( " 15.3 " )) {
87
+ if (version15_3_orHigher (version)) {
89
88
return XcodeInstallation (
90
89
version = version,
91
90
build = build,
@@ -94,10 +93,11 @@ object XcodeHelper {
94
93
}
95
94
96
95
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
+ }
101
101
val pluginCompatabilityId = checkNotNull(pluginCompatabilityIdResult.output?.trim()) {
102
102
" Couldn't get plugin compatibility ID of Xcode at path: ${path} ."
103
103
}
@@ -167,8 +167,13 @@ object XcodeHelper {
167
167
val pluginCompatabilityId : String? = null ,
168
168
) {
169
169
val name: String = " Xcode $version ($build )"
170
+
171
+ fun supported (supportedXcodeUuids : Set <String >): Boolean = version15_3_orHigher(version) ||
172
+ supportedXcodeUuids.contains(pluginCompatabilityId)
170
173
}
171
174
175
+ fun version15_3_orHigher (version : String ) = Version .fromString(version) >= Version .fromString(" 15.3" )
176
+
172
177
@Serializable
173
178
private data class SystemProfilerOutput (
174
179
@SerialName(" SPDeveloperToolsDataType" )
@@ -216,6 +221,7 @@ object XcodeHelper {
216
221
NonApplePlugins (value.dictionary)
217
222
}
218
223
}
224
+
219
225
fun PropertyList.nonApplePlugins (xcodeVersion : String ): NonApplePlugins {
220
226
val backingDictionary = root.dictionary.getOrPut(nonApplePluginsKeyPrefix + xcodeVersion) {
221
227
PropertyList .Object .Dictionary (
0 commit comments