【问题标题】:Xcode - Delete application before running on deviceXcode - 在设备上运行之前删除应用程序
【发布时间】:2013-02-21 22:02:51
【问题描述】:

Xcode (4.6) 有没有办法在安装之前删除设备上的应用程序?

我需要它来进行测试,如果在重新安装之前将应用程序从设备中删除会更容易。

【问题讨论】:

    标签: ios iphone xcode


    【解决方案1】:

    是的,你可以。

    获取https://github.com/libimobiledevice/ideviceinstaller

    这使您能够在 bash 环境中使用ideviceinstaller --uninstall <app-id>

    然后在你的构建配置中在xcode中做一个脚本,比如:http://www.runscriptbuildphase.com/

    【讨论】:

    • 让我补充一点,安装 ideviceinstaller 的简单方法是按照macappstore.org/ideviceinstaller 中的说明进行操作
    • 另外,如果您在运行--uninstall 命令时,碰巧遇到错误:“无法连接到lockdownd。退出。”,然后访问:github.com/libimobiledevice/ideviceinstaller/issues/58
    • 请注意,ideviceinstaller 只允许您从设备上卸载应用程序。如果要从模拟器中卸载应用程序,可以使用以下命令:xcrun simctl uninstall sim-udid bundle-id 详细说明here
    • 使用 brew 安装 ideviceinstallerbrew install ideviceinstaller
    【解决方案2】:

    唯一的方法是手动删除它。如果这是您所要求的,则无法让 xcode 在每次运行之前从设备中删除该应用程序。抱歉,这将是一个很棒的功能,但目前还没有办法做到这一点。甚至在模拟器上也没有。

    我认为你应该向苹果提交错误/功能请求!该功能对我来说会派上用场!

    【讨论】:

      【解决方案3】:

      XCode 不提供每次运行时自动从设备中删除应用程序的选项,但简单的方法是使用“设备”屏幕一键将其删除。

      Link to the Apple documentation

      【讨论】:

      • 该链接现已断开。当前使用 XCode 从设备上卸载您正在开发的应用程序的方法是:Window -> Devices and Simulators。选择设备。在INSTALLED APPS 下选择- 按钮。`
      【解决方案4】:

      如何创建一个 Xcode 构建脚本来退出模拟器,然后删除模拟器应用程序目录的内容。目录是

      ~/Library/Application Support/iPhone Simulator/6.1/Applications/
      

      【讨论】:

      • 好主意,但我需要将其从设备中删除
      【解决方案5】:

      不,没有办法自动删除应用程序。

      但是您可以编写一个简单的函数来清除上次运行的所有应用程序资源,如下所示:

      -(无效)清理{ NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *context) { [[NSManagedObjectModel MR_defaultManagedObjectModel].entities enumerateObjectsUsingBlock:^(NSEntityDescription *entityDescription, NSUInteger idx, BOOL *stop) { [NSClassFromString([entityDescription managedObjectClassName]) MR_truncateAllInContext:context]; }]; }]; }

      【讨论】:

      • 我应该把这个放在哪里?在 viewDidLoad() 的开头?
      • @Andrej,在[MagicalRecord setupCoreDataStack] 行之后的 AppDelegate 中调用此方法。但请注意,您必须手动清理您的应用可能写入某处的所有数据。
      【解决方案6】:

      像 HackyStack 一样,我认为你必须手动删除应用程序。也就是说,您可以使用调试启动方法来清除安装期间未覆盖的内容。例如,删除文档目录的内容、与应用程序关联的钥匙串项目、iCloud KV 信息和文档等的方法。这会有点痛苦,但可能会让你去你想去的地方......

      【讨论】:

        【解决方案7】:

        2021 年更新(macOS 11.2.3、Xcode12.4):我必须将mobiledevice uninstall_app com.example.bundleid 添加到构建阶段


        使用 macOS 10.15.2、Xcode11.3、iOS13.3 (iPhone XS)、iOS12.4.4 (iPhone 5S) 的工作解决方案

        • 安装:brew install mobiledevice (https://github.com/imkira/mobiledevice)
        • 重启 macOS
        • 创建/克隆方案
        • 在运行/预操作中添加这一行:mobiledevice uninstall_app com.example.bundleid

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2012-07-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-05-28
          • 2012-04-16
          相关资源
          最近更新 更多