一 学习目标
mac开机后自动开启应用
二 学习效果

image.png
三 主要操作步骤
3.1 使用Swift Package Manager添加LaunchAtLogin库

image.png

image.png

image.png

image.png
3.2 自启动设置开关
import SwiftUI
import LaunchAtLogin
struct ContentView: View {
var body: some View {
VStack{
LaunchAtLogin.Toggle {
Text("电脑开机时,自动启动软件")
}
}.frame(width: 400, height: 400, alignment: .center)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}