Skip to content

Commit 22c40a7

Browse files
committed
Fix info command for 15.3
1 parent 595d5b0 commit 22c40a7

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/macosMain/kotlin/co/touchlab/xcode/cli/XcodeHelper.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package co.touchlab.xcode.cli
22

33
import co.touchlab.kermit.Logger
4-
import co.touchlab.xcode.cli.XcodeHelper.Defaults.nonApplePlugins
54
import co.touchlab.xcode.cli.util.BackupHelper
65
import co.touchlab.xcode.cli.util.Console
76
import co.touchlab.xcode.cli.util.File
8-
import co.touchlab.xcode.cli.util.fromString
97
import co.touchlab.xcode.cli.util.Path
108
import co.touchlab.xcode.cli.util.PropertyList
119
import co.touchlab.xcode.cli.util.Shell
1210
import co.touchlab.xcode.cli.util.Version
11+
import co.touchlab.xcode.cli.util.fromString
1312
import kotlinx.serialization.SerialName
1413
import kotlinx.serialization.Serializable
1514
import 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(

src/macosMain/kotlin/co/touchlab/xcode/cli/command/Info.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ class Info: BaseXcodeListSubcommand("info", "Shows information about the plugin"
4343
echo("Installed Xcode versions:")
4444
val longestNameLength = xcodeInstallations.maxOf { it.name.length }
4545
for (install in xcodeInstallations) {
46-
val spacesAfterName = (1..(longestNameLength - install.name.length)).joinToString(separator = "") { " " }
47-
val compatibilityMark = if (supportedXcodeUuids.contains(install.pluginCompatabilityId)) "" else "x"
46+
val spacesAfterName =
47+
(1..(longestNameLength - install.name.length)).joinToString(separator = "") { " " }
48+
val compatibilityMark = if (install.supported(supportedXcodeUuids)) "" else "x"
4849
echo("$compatibilityMark\t${install.name}$spacesAfterName\t${install.pluginCompatabilityId}\t${install.path}")
4950
}
5051

0 commit comments

Comments
 (0)