mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-04-26 14:57:37 +00:00
Allow launching and copying the path of an installed Xcode
This commit is contained in:
parent
adad238b2a
commit
912ac0a28e
2 changed files with 21 additions and 2 deletions
|
|
@ -191,6 +191,18 @@ class AppState: ObservableObject {
|
||||||
// TODO:
|
// TODO:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func launch(id: Xcode.ID) {
|
||||||
|
guard let installedXcode = Current.files.installedXcodes(Path.root/"Applications").first(where: { $0.version == id }) else { return }
|
||||||
|
NSWorkspace.shared.openApplication(at: installedXcode.path.url, configuration: .init())
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyPath(id: Xcode.ID) {
|
||||||
|
guard let installedXcode = Current.files.installedXcodes(Path.root/"Applications").first(where: { $0.version == id }) else { return }
|
||||||
|
NSPasteboard.general.declareTypes([.URL, .string], owner: nil)
|
||||||
|
NSPasteboard.general.writeObjects([installedXcode.path.url as NSURL])
|
||||||
|
NSPasteboard.general.setString(installedXcode.path.string, forType: .string)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
|
||||||
private func updateAllXcodes(_ xcodes: [AvailableXcode]) {
|
private func updateAllXcodes(_ xcodes: [AvailableXcode]) {
|
||||||
|
|
|
||||||
|
|
@ -65,12 +65,19 @@ struct XcodeListView: View {
|
||||||
Button(action: { xcode.installed ? appState.xcodeBeingConfirmedForUninstallation = xcode : self.appState.install(id: xcode.id) }) {
|
Button(action: { xcode.installed ? appState.xcodeBeingConfirmedForUninstallation = xcode : self.appState.install(id: xcode.id) }) {
|
||||||
Text(xcode.installed ? "Uninstall" : "Install")
|
Text(xcode.installed ? "Uninstall" : "Install")
|
||||||
}
|
}
|
||||||
|
Divider()
|
||||||
if xcode.installed {
|
if xcode.installed {
|
||||||
|
Button(action: { self.appState.select(id: xcode.id) }) {
|
||||||
|
Text("Select")
|
||||||
|
}
|
||||||
|
Button(action: { self.appState.launch(id: xcode.id) }) {
|
||||||
|
Text("Launch")
|
||||||
|
}
|
||||||
Button(action: { self.appState.reveal(id: xcode.id) }) {
|
Button(action: { self.appState.reveal(id: xcode.id) }) {
|
||||||
Text("Reveal in Finder")
|
Text("Reveal in Finder")
|
||||||
}
|
}
|
||||||
Button(action: { self.appState.select(id: xcode.id) }) {
|
Button(action: { self.appState.copyPath(id: xcode.id) }) {
|
||||||
Text("Select")
|
Text("Copy Path")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue