gpt4 book ai didi

ios - 如何从命令行在模拟器上构建和运行xcodeproj?

转载 作者:行者123 更新时间:2023-12-01 18:05:41 32 4
gpt4 key购买 nike

我想要做的就是能够与Cmd + R在Xcode中能够做的相同的事情,除了在终端机上。但是到目前为止,您会发现多个堆栈溢出帖子和文章使我迷失了方向。

到目前为止,我已经能够从命令行运行模拟器:

open -a Simulator --args -CurrentDeviceUDID <UDID for iPhone 7>

但是我无法使用这些命令安装和启动应用程序
xcrun simctl install booted <PATH-TO-APPLICATION-BUNDLE>
xcrun simctl launch booted <BUNDLE-ID-OF-APP-BUNDLE>

我不知道如何找到 <PATH-TO-APPLICATION-BUNDLE>。我假设这不像将路径放入 .xcodeproj那样简单...

如果有人可以编写步骤和特定命令,我需要(1)从命令行构建 .xcodeproj,以及(2)从命令行在模拟器上运行应用程序,将不胜感激!

附言我知道有些像 ios-sim这样的工具可能会使整个过程更容易,但是我想原始地做(即使用Xcode命令行工具)

最佳答案

(1)要构建您的项目,我建议您检查此链接
https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html

(2)这是我如何在模拟器上启动应用程序的示例

列出设备

xcrun simctl list

引导设备

(例)
xcrun simctl boot "iPhone 5"

要么
(例)
xcrun simctl boot E9469085-68B9-450A-A716-87F013C9AF56

安装.app (必须找到您的Library文件夹。

格式:xcrun simctl install <设备> <.app路径>
(例)
xcrun simctl install "iPhone 5" "MyUserPath/Library/Developer/Xcode/DerivedData/CustomTransitions-edghiwbzifosladnxssmsfwzykxg/Build/Products/Debug-iphonesimulator/CustomTransitions.app"

关闭设备
xcrun simctl boot "iPhone 5"

打开模拟器(这是我的路径。您的路径可以不同)
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app

启动应用程序

格式:xcrun simctl启动已启动<软件包ID>
xcrun simctl launch booted "com.example.apple-samplecode.CustomTransitions"

关于ios - 如何从命令行在模拟器上构建和运行xcodeproj?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45643961/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com