Skip to content

Commit

Permalink
[macOS] Rebuilding Launch Services database (#4588)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsame committed Dec 1, 2021
1 parent f4306a6 commit 6f66247
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion images/macos/helpers/Xcode.Installer.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ function Build-XcodeSymlinks {
}
}

function Rebuild-XcodeLaunchServicesDb {
param(
[Parameter(Mandatory)]
[string]$Version
)

$xcodePath = Get-XcodeRootPath -Version $Version
$lsregister = '/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister'
Get-ChildItem -Recurse -Filter "*.app" $xcodePath | Foreach-Object { & $lsregister -f $_.FullName}
}

function Build-ProvisionatorSymlink {
param(
[Parameter(Mandatory)]
Expand Down Expand Up @@ -216,4 +227,4 @@ function Set-XcodeDeveloperDirEnvironmentVariables {
Write-Host "Set ${variableName}=${variableValue}"
"export ${variableName}=${variableValue}" | Out-File "$env:HOME/.bashrc" -Append
}
}
}
5 changes: 5 additions & 0 deletions images/macos/provision/core/xcode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ $xcodeVersions | ForEach-Object {
}
}

Write-Host "Rebuilding Launch Services database ..."
$xcodeVersions | ForEach-Object {
Rebuild-XcodeLaunchServicesDb -Version $_.link
}

Write-Host "Setting default Xcode to $defaultXcode"
Switch-Xcode -Version $defaultXcode
New-Item -Path "/Applications/Xcode.app" -ItemType SymbolicLink -Value (Get-XcodeRootPath -Version $defaultXcode) | Out-Null
Expand Down

0 comments on commit 6f66247

Please sign in to comment.