![](/img/trans.png)
[英]Xcode : No code signature found, while running application on real device
[英]Xcode - Delete application before running on device
Xcode (4.6) 有沒有辦法在安裝之前刪除設備上的應用程序?
我需要它用於測試目的,如果在再次安裝之前從設備中刪除應用程序會更容易。
是的你可以。
獲取https://github.com/libimobiledevice/ideviceinstaller
這使您能夠在 bash 環境中使用ideviceinstaller --uninstall <app-id>
。
然后在 xcode 的構建配置中做一個腳本,例如: http ://www.runscriptbuildphase.com/
唯一的方法是手動刪除它。 如果這是您的要求,則無法讓 xcode 在每次運行之前從設備中刪除該應用程序。 抱歉,這將是一個很棒的功能,但目前還沒有辦法做到這一點。 甚至在模擬器上也不行。
我認為您應該向蘋果提交錯誤/功能請求! 該功能對我來說會派上用場!
XCode 不提供每次運行時自動從設備中刪除應用程序的選項,但簡單的方法是使用“設備”屏幕一鍵刪除它。
如何創建一個 Xcode 構建腳本來退出模擬器,然后刪除模擬器應用程序目錄的內容。 目錄是
~/Library/Application Support/iPhone Simulator/6.1/Applications/
不,沒有辦法自動刪除應用程序。
但是您可以編寫一個簡單的函數來清除上次運行中的所有應用程序資源,如下所示:
- (void)cleanUp { 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]; }]; }]; }
像 HackyStack 一樣,我認為您必須手動刪除該應用程序。 也就是說,您可以有一個調試啟動方法來清除安裝期間未被覆蓋的內容。 例如,一種刪除文檔目錄內容、與應用程序關聯的鑰匙串項目、iCloud KV 信息和文檔等的方法。這會有點痛苦,但可能會讓你到達你想去的地方......
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 )mobiledevice uninstall_app com.example.bundleid
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.