Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Sources/XcodesKit/Services/XcodeSelectionFilesystemService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ public struct XcodeSelectionFilesystemService: Sendable {
let destinationPath = installDirectory/"Xcode\(isBeta ? "-Beta" : "").app"
var replacedExistingSymlink = false

if fileExists(destinationPath.string) {
let attributes = try attributesOfItem(destinationPath.string)
let attributes: [FileAttributeKey: Any]?
do {
attributes = try attributesOfItem(destinationPath.string)
} catch let error as CocoaError where error.code == .fileReadNoSuchFile {
attributes = nil
}

if let attributes {
if attributes[.type] as? FileAttributeType == .typeSymbolicLink {
try removeItem(destinationPath.string)
replacedExistingSymlink = true
Expand Down