Skip to content

Commit

Permalink
Merge pull request #200 from RobotsAndPencils/MakeSymLinkOnSelect
Browse files Browse the repository at this point in the history
Add Preference to make Symbolic Link Automatic on Xcode Select
  • Loading branch information
MattKiazyk authored Apr 14, 2022
2 parents b36ef47 + f7b4c5e commit 44bef1a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 11 additions & 1 deletion Xcodes/Backend/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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>()
Expand Down Expand Up @@ -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
},
Expand Down
15 changes: 14 additions & 1 deletion Xcodes/Frontend/Preferences/AdvancedPreferencePane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit 44bef1a

Please sign in to comment.