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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26394596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:53:08  来源:igfitidea点击:

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

iosxcodeios-simulatorxcode6build-automation

提问by Frank

I have an automation running in the iOS Simulator that I have to remove before another run. How do I remove the app from the iOS Simulator from the command line?

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

For each simulator device directory (located at ~/Library/Developer/CoreSimulator/Devices/*), I tried to delete ./data/Containers/Bundle/Application/and ./data/Containers/Data/Application/.

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

Even when I tried to delete the app by long pressing the app in the Simulator (the app becomes jiggly) and click on the X button, the user defaults were not being cleared. I want the app state to be 100% clean.

即使我尝试通过在模拟器中长按应用程序(应用程序变得摇晃)并单击 X 按钮来删除应用程序,也没有清除用户默认设置。我希望应用程序状态 100% 干净。

I found a good solution to solve this problem.

我找到了一个很好的解决方案来解决这个问题。

采纳答案by Frank

One approach that we found for deleting user defaults is to delete all files in the ./data/Library/Preferences/*in addition to deleting application and data directories.

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

However, in Xcode 6, the command xcrunhas new subcommand called simctlthat allows me to manage iOS Simulator including resetting the simulator, and installing the application.

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

The solution that I came up with is to use the command

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

xcrun simctl erase [device ID]

Example

例子

If xcrun simctl list(?) returns

如果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)

then run these 2 commands

然后运行这两个命令

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


(?) The device ID can be obtained from running

( ?)可以通过运行获得设备ID

xcrun simctl list

This will reset the simulator (equivalent to iOS Simulator > Reset Contents and Settings...menu item).

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

With Xcode 6.0.1 (Build 6A317), there is either a bug or a change in behavior where when you uninstall an application, user defaults are not removed.

在 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.

回答by Archana

With Xcode 6.1, to uninstall an app, use the following command:

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

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

where com.example.apple-samplecode.UICatalogis the bundle identifier of the application you wish to uninstall.

com.example.apple-samplecode.UICatalog您要卸载的应用程序的包标识符在哪里。

回答by SwiftArchitect

Reset all Content & Settings in a single command

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

  1. Quit iPhone Simulator
  2. In Terminal, run:

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

    xcrun simctl erase all
    

This will reset content and settings of all the simulators for the active version of Xcode (the one referenced by xcode-select -p).

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

回答by Loveleen Saini

xcrun simctl uninstall simulatorIdentifier appBundleId