1.首先打开模拟器应用
open "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/"
2.启动你喜欢的模拟器
2.1 打印可用模拟器列表
xcrun simctl list
image.png
2.2 关闭已经打开的设备模拟器
xcrun simctl shutdown booted
2.3 打开IPhone13的设备模拟器
xcrun simctl boot "iPhone 13"
3.安装APP
xcrun simctl install "iPhone 13" "testAPP.app的路径"
4.启动APP
xcrun simctl launch "iPhone 13" "testAPP的包名"
5.build工程项目 生成testAPP.app
clean
xcodebuild clean -workspace APP.xcworkspace -scheme APP -configuration Debug -sdk iphonesimulator15.5
编译
xcodebuild build -workspace APP.xcworkspace -scheme APP -configuration Debug -sdk iphonesimulator15.5
编译成功后可以在Products目录下看到.app文件。
-sdk iphonesimulator15.5是模拟器模式编译,如果不知道你的模拟器sdk版本,可以使用xcodebuild -showsdks查看支持的sdk
结束
其他指令可以xcrun simctl help自行了解
xcrun simctl help