繁体   English   中英

如何从命令行中删除iOS 8 Simulator中的应用程序?

[英]How do I remove app from iOS 8 Simulator from command line?

我在iOS模拟器中运行自动化,我必须在另一次运行之前删除它。 如何从命令行中删除iOS模拟器中的应用程序?

对于每个模拟器设备目录(位于~/Library/Developer/CoreSimulator/Devices/* ),我尝试删除./data/Containers/Bundle/Application/./data/Containers/Data/Application/

即使我试图通过长时间按下模拟器中的应用程序来删除应用程序(应用程序变得晃动)并单击X按钮,用户默认值也没有被清除。 我希望应用程序状态100%干净。

我找到了解决这个问题的好方法。

使用Xcode 6.1,要卸载应用程序,请使用以下命令:

xcrun simctl uninstall booted com.example.apple-samplecode.UICatalog

其中com.example.apple-samplecode.UICatalog是您要卸载的应用程序的包标识符。

我们发现删除用户默认值的一种方法是删除./data/Library/Preferences/*中的所有文件以及删除应用程序和数据目录。

但是,在Xcode 6中,命令xcrun有一个名为simctl新子命令,它允许我管理iOS模拟器,包括重置模拟器和安装应用程序。

我想出的解决方案是使用该命令

xcrun simctl erase [device ID]

如果xcrun simctl list )返回

9DDA0CFE-7CEC-40B6-A343-1EC01F282B22 (active, disconnected)
    Watch: Apple Watch Series 2 - 42mm (88474523-163E-4021-B591-2AECBFA26997) (Shutdown)
    Phone: iPhone 7 Plus (5785E680-15CD-42D3-82AB-597286A270C5) (Shutdown)

然后运行这两个命令

xcrun simctl erase 88474523-163E-4021-B591-2AECBFA26997
xcrun simctl erase 5785E680-15CD-42D3-82AB-597286A270C5

设备ID可以从运行中获得

xcrun simctl list

这将重置模拟器(相当于iOS Simulator > Reset Contents and Settings...菜单项)。

使用Xcode 6.0.1(Build 6A317),存在一个错误或行为更改,当您卸载应用程序时,不会删除用户默认值。

Usage: simctl [--noxpc] [--set <set path>] <subcommand> ... | help [subcommand]
Command line utility to control the iOS Simulator

For subcommands that require a <device> argument, you may specify a device UDID
or the special "booted" string which will cause simctl to pick a booted device.
If multiple devices are booted when the "booted" device is selected, simctl
will choose one of them.

Subcommands:
    create        Create a new device.
    delete        Delete a device.
    erase         Erase a device's contents and settings.
    boot          Boot a device.
    shutdown      Shutdown a device.
    rename        Rename a device.
    getenv        Print an environment variable from a running device.
    openurl       Open a URL in a device.
    addphoto      Add a photo to the photo library of a device.
    install       Install an app on a device.
    uninstall     Uninstall an app from a device.
    launch        Launch an application by identifier on a device.
    spawn         Spawn a process on a device.
    list          List available devices, device types, or runtimes.
    notify_post   Post a darwin notification on a device.
    icloud_sync   Trigger iCloud sync on a device.
    help          Prints the usage for a given subcommand.

在一个命令中重置所有内容和设置

  1. 退出iPhone模拟器
  2. 在终端中,运行:

     xcrun simctl erase all 

这将重置Xcode的活动版本( xcode-select -p引用的那个)的所有模拟器的内容和设置。

xcrun simctl uninstall simulatorIdentifier appBundleId

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM