Merge pull request #200 from RobotsAndPencils/MakeSymLinkOnSelect

Add Preference to make Symbolic Link Automatic on Xcode Select
This commit is contained in:
Matt Kiazyk 2022-04-14 14:41:38 -05:00 committed by GitHub
commit 44bef1a5f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View file

@ -68,7 +68,13 @@ class AppState: ObservableObject {
Current.defaults.set(unxipExperiment, forKey: "unxipExperiment")
}
}
@Published var createSymLinkOnSelect = false {
didSet {
Current.defaults.set(createSymLinkOnSelect, forKey: "createSymLinkOnSelect")
}
}
// MARK: - Publisher Cancellables
var cancellables = Set<AnyCancellable>()
@ -489,6 +495,10 @@ class AppState: ObservableObject {
if case let .failure(error) = completion {
self.error = error
self.presentedAlert = .generic(title: "Unable to select Xcode", message: error.legibleLocalizedDescription)
} else {
if self.createSymLinkOnSelect {
createSymbolicLink(xcode: xcode)
}
}
self.selectPublisher = nil
},

View file

@ -43,7 +43,20 @@ struct AdvancedPreferencePane: View {
.font(.footnote)
.fixedSize(horizontal: false, vertical: true)
}
}
.groupBoxStyle(PreferencesGroupBoxStyle())
GroupBox(label: Text("Active/Select")) {
VStack(alignment: .leading) {
Toggle(
"Automatically create symbolic link to Xcodes.app",
isOn: $appState.createSymLinkOnSelect
)
Text("When making an Xcode version Active/Selected, try and create a symbolic link named Xcode.app in the installation directory")
.font(.footnote)
.fixedSize(horizontal: false, vertical: true)
}
.fixedSize(horizontal: false, vertical: true)
}
.groupBoxStyle(PreferencesGroupBoxStyle())