Posts

Post not yet marked as solved
0 Replies
103 Views
Hi everyone, Is there any way to add a segmented picker in place of a searchbar in the navigationBarDrawer? So that it sticks to the title and is hidden on scroll? Best, Paul
Posted
by paviro.
Last updated
.
Post not yet marked as solved
0 Replies
138 Views
Hi everyone, I am currently writing a script that configures some things on a freshly installed macOS. For this reason I created the following launch daemon that gets installed via startosinstall on macOS install time. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>de.paviro.launchd-setup</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/setup-utility</string> </array> <key>KeepAlive</key> <true/> <key>RunAtLoad</key> <true/> <key>StandardOutPath</key> <string>/Library/Logs/PaViRo/output.log</string> <key>StandardErrorPath</key> <string>/Library/Logs/PaViRo/error.log</string> </dict> </plist> For some reason this daemon does not get started on the initial boot (when Setup Assistant runs) but only after I reboot the machine. I also have a LaunchAgent in place that creates a file when the user is logged in. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>RunAtLoad</key> <true/> <key>Label</key> <string>de.paviro.launchd-setup-trigger</string> <key>ProgramArguments</key> <array> <string>touch</string> <string>/tmp/userloggedin</string> </array> </dict> </plist> Initially I used this file to trigger the daemon via watched paths. As this didn't work on first boot for some reason I tried what I have now and then wait for the file in the setup-utility script. This also doesn't work on first boot however as the daemon is never run. The LaunchAgent is run though, the file userloggedin is present after finishing the Setup Assistant process. No logs of the daemon can be found until the Mac has been rebooted in contrast. If anyone has a hint I would be very grateful! Best, Paul
Posted
by paviro.
Last updated
.
Post marked as solved
2 Replies
355 Views
Hey everyone, This is probably a very ****** question as I have just started botching something together with Swift and therefore know very little as of now 😅 I am trying to write a little SwiftUI application that can download and reinstall macOS with some custom packages. For downloading the installer I use softwareupdate --fetch-full-installer through Process() and then parse the output to show the progress which works fine so far. I do have trouble launching the installer (/Applications/Install macOS Monterey.app/Contents/Resources/startosinstall) though. This is the function I am using. I removed some of the UI code that updates some labels and progress bars. func installMacOS(installPath: String) { let task = Process() task.executableURL = URL(fileURLWithPath: installPath) task.arguments = [ "--nointeraction", "--agreetolicense", "--allowremoval", "--eraseinstall", "--cloneuser", "--stdinpass"] let outputPipe = Pipe() let inputPipe = Pipe() task.standardOutput = outputPipe task.standardInput = inputPipe let outputHandle = outputPipe.fileHandleForReading outputHandle.readabilityHandler = { pipe in if let ouput = String(data: pipe.availableData, encoding: .utf8) { if !ouput.isEmpty { if ouput.lowercased().range(of:"preparing") != nil { print("Preparing macOS install...") } else if ouput.lowercased().range(of:"error") != nil { print("Something is wrong") } else if ouput.lowercased().range(of:"restart") != nil { print("Mac will restart") } else { let result = ouput.trimmingCharacters(in: CharacterSet(charactersIn: "0123456789.").inverted) if let number = Float(result) { print("Progress: " + String(number) + "%") } } } } else { print("Error: \(pipe.availableData)") } } task.launch() // I will replace this with a alert asking for the password at some point but security isn't important for this one so this is fine for now inputPipe.fileHandleForReading.write("Password\n".data(using: .utf8)!) inputPipe.fileHandleForWriting.closeFile() } The function is called like this although the string is assembled through another function but this is the result: installMacOS(installPath: "/Applications/Install macOS Monterey.app/Contents/Resources/startosinstall") Running it results in the app crashing with different errors. Error Logs I would be very grateful for any tipps and hints in what I am doing wrong! Thank you! Best, Paul
Posted
by paviro.
Last updated
.