github.com/AlpineAIO/wails/v2@v2.0.0-beta.32.0.20240505041856-1047a8fa5fef/internal/system/system_darwin.go (about) 1 //go:build darwin 2 // +build darwin 3 4 package system 5 6 import ( 7 "fmt" 8 "os/exec" 9 "strings" 10 "syscall" 11 12 "github.com/AlpineAIO/wails/v2/internal/system/operatingsystem" 13 "github.com/AlpineAIO/wails/v2/internal/system/packagemanager" 14 ) 15 16 // Determine if the app is running on Apple Silicon 17 // Credit: https://www.yellowduck.be/posts/detecting-apple-silicon-via-go/ 18 func init() { 19 r, err := syscall.Sysctl("sysctl.proc_translated") 20 if err != nil { 21 return 22 } 23 24 IsAppleSilicon = r == "\x00\x00\x00" || r == "\x01\x00\x00" 25 } 26 27 func (i *Info) discover() error { 28 var err error 29 osinfo, err := operatingsystem.Info() 30 if err != nil { 31 return err 32 } 33 i.OS = osinfo 34 35 i.Dependencies = append(i.Dependencies, checkXCodeSelect()) 36 i.Dependencies = append(i.Dependencies, checkNodejs()) 37 i.Dependencies = append(i.Dependencies, checkNPM()) 38 i.Dependencies = append(i.Dependencies, checkXCodeBuild()) 39 i.Dependencies = append(i.Dependencies, checkUPX()) 40 i.Dependencies = append(i.Dependencies, checkNSIS()) 41 return nil 42 } 43 44 func checkXCodeSelect() *packagemanager.Dependency { 45 // Check for xcode command line tools 46 output, err := exec.Command("xcode-select", "-v").Output() 47 installed := true 48 version := "" 49 if err != nil { 50 installed = false 51 } else { 52 version = strings.TrimPrefix(string(output), "xcode-select version ") 53 version = strings.TrimSpace(version) 54 version = strings.TrimSuffix(version, ".") 55 } 56 return &packagemanager.Dependency{ 57 Name: "Xcode command line tools ", 58 PackageName: "N/A", 59 Installed: installed, 60 InstallCommand: "xcode-select --install", 61 Version: version, 62 Optional: false, 63 External: false, 64 } 65 } 66 67 func checkXCodeBuild() *packagemanager.Dependency { 68 // Check for xcode 69 output, err := exec.Command("xcodebuild", "-version").Output() 70 installed := true 71 version := "" 72 if err != nil { 73 installed = false 74 } else if l := strings.Split(string(output), "\n"); len(l) >= 2 { 75 version = fmt.Sprintf("%s (%s)", 76 strings.TrimPrefix(l[0], "Xcode "), 77 strings.TrimPrefix(l[1], "Build version ")) 78 } else { 79 version = "N/A" 80 } 81 82 return &packagemanager.Dependency{ 83 Name: "Xcode", 84 PackageName: "N/A", 85 Installed: installed, 86 InstallCommand: "Available at https://apps.apple.com/us/app/xcode/id497799835", 87 Version: version, 88 Optional: true, 89 External: false, 90 } 91 }