Implement logic to check if xcode is beta

This commit is contained in:
Maxim Lobanov
2020-10-01 13:11:30 +03:00
parent 28a8724352
commit da68de0a09
2 changed files with 12 additions and 2 deletions

View File

@@ -45,6 +45,14 @@ function Switch-Xcode {
Invoke-Expression "sudo xcode-select --switch ${XcodeRootPath}" Invoke-Expression "sudo xcode-select --switch ${XcodeRootPath}"
} }
function Test-XcodeStableRelease {
param([string] $XcodeRootPath)
$licenseInfoPlistPath = Join-Path $XcodeRootPath "Contents" "Resources" "LicenseInfo.plist"
$releaseType = & defaults read $licenseInfoPlistPath "licenseType"
return -not ($releaseType -match "beta")
}
function Get-XcodeSimulatorsInfo { function Get-XcodeSimulatorsInfo {
param( param(
[string] $Filter [string] $Filter
@@ -102,6 +110,6 @@ function Test-XcodeStableVersion {
if ($Version -match "GM") { if ($Version -match "GM") {
return $false return $false
} }
return $true return $true
} }

View File

@@ -46,7 +46,8 @@ function Get-XcodeInfoList {
$versionInfo = Get-XcodeVersionInfo $versionInfo = Get-XcodeVersionInfo
$versionInfo.Path = $xcodeRootPath $versionInfo.Path = $xcodeRootPath
$versionInfo.IsDefault = ($xcodeRootPath -eq $defaultXcodeRootPath) $versionInfo.IsDefault = ($xcodeRootPath -eq $defaultXcodeRootPath)
$versionInfo.IsStable = Test-XcodeStableRelease -XcodeRootPath $xcodeRootPath
$xcodeInfo.Add($xcodeRootPath, [PSCustomObject] @{ $xcodeInfo.Add($xcodeRootPath, [PSCustomObject] @{
VersionInfo = $versionInfo VersionInfo = $versionInfo
SDKInfo = Get-XcodeSDKList SDKInfo = Get-XcodeSDKList
@@ -91,6 +92,7 @@ function Build-XcodeTable {
$xcodeList = $xcodeInfo.Values | ForEach-Object { $_.VersionInfo } | Sort-Object $sortRules $xcodeList = $xcodeInfo.Values | ForEach-Object { $_.VersionInfo } | Sort-Object $sortRules
return $xcodeList | ForEach-Object { return $xcodeList | ForEach-Object {
$defaultPostfix = If ($_.IsDefault) { " (default)" } else { "" } $defaultPostfix = If ($_.IsDefault) { " (default)" } else { "" }
$betaPostfix = If ($_.IsStable) { "" } else { " (beta)" }
return [PSCustomObject] @{ return [PSCustomObject] @{
"Version" = $_.Version.ToString() + $betaPostfix + $defaultPostfix "Version" = $_.Version.ToString() + $betaPostfix + $defaultPostfix
"Build" = $_.Build "Build" = $_.Build