Skip to content

Commit

Permalink
[darwin] Show Xcode version in wails doctor
Browse files Browse the repository at this point in the history
  • Loading branch information
stffabi committed Nov 14, 2022
1 parent 2365709 commit 10f9f8e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
48 changes: 40 additions & 8 deletions v2/internal/system/system_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
package system

import (
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
"fmt"
"os/exec"
"strings"
"syscall"

"github.com/wailsapp/wails/v2/internal/system/packagemanager"

"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
)

Expand All @@ -31,6 +33,15 @@ func (i *Info) discover() error {
}
i.OS = osinfo

i.Dependencies = append(i.Dependencies, checkXCodeSelect())
i.Dependencies = append(i.Dependencies, checkNPM())
i.Dependencies = append(i.Dependencies, checkXCodeBuild())
i.Dependencies = append(i.Dependencies, checkUPX())
i.Dependencies = append(i.Dependencies, checkNSIS())
return nil
}

func checkXCodeSelect() *packagemanager.Dependency {
// Check for xcode command line tools
output, err := exec.Command("xcode-select", "-v").Output()
installed := true
Expand All @@ -42,18 +53,39 @@ func (i *Info) discover() error {
version = strings.TrimSpace(version)
version = strings.TrimSuffix(version, ".")
}
xcodeDep := &packagemanager.Dependency{
Name: "xcode command line tools ",
return &packagemanager.Dependency{
Name: "Xcode command line tools ",
PackageName: "N/A",
Installed: installed,
InstallCommand: "xcode-select --install",
Version: version,
Optional: false,
External: false,
}
i.Dependencies = append(i.Dependencies, xcodeDep)
i.Dependencies = append(i.Dependencies, checkNPM())
i.Dependencies = append(i.Dependencies, checkUPX())
i.Dependencies = append(i.Dependencies, checkNSIS())
return nil
}

func checkXCodeBuild() *packagemanager.Dependency {
// Check for xcode
output, err := exec.Command("xcodebuild", "-version").Output()
installed := true
version := ""
if err != nil {
installed = false
} else if l := strings.Split(string(output), "\n"); len(l) >= 2 {
version = fmt.Sprintf("%s (%s)",
strings.TrimPrefix(l[0], "Xcode "),
strings.TrimPrefix(l[1], "Build version "))
} else {
version = "N/A"
}

return &packagemanager.Dependency{
Name: "Xcode",
PackageName: "N/A",
Installed: installed,
InstallCommand: "Available at https://apps.apple.com/us/app/xcode/id497799835",
Version: version,
Optional: true,
External: false,
}
}
1 change: 1 addition & 0 deletions website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Added `OpenInspectorOnStartup` to debug options to allow opening the WebInspector during startup of the application in debug mode. Added by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2080)
- On macOS `wails doctor` now also shows the version of Xcode installed. Added by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2087)

### Fixed
- The `noreload` flag in wails dev wasn't applied. Fixed by @stffabi in this [PR](https://github.com/wailsapp/wails/pull/2081)
Expand Down

0 comments on commit 10f9f8e

Please sign in to comment.