iOS权限警报 - 删除或禁止 [英] iOS permission Alerts - removing or suppressing
问题描述
我有一个在ios模拟器上运行的简单应用程序(在应用程序的某个时刻),提示用户授权以下内容:
I have a simple app running on ios simulator which will (at some point in the app), prompt the user to authorize the following:
- 位置设置
- 地址联系簿
- 图片/相册
因为我正在iOS模拟器上进行自动化测试(在虚拟机上有几千个),有没有办法强制iOS模拟器在安装应用程序时将这些权限设置为yes?
Because I am doing automation testing on the iOS simulator (several thousand on virtual machines), is there a way to force iOS simulator to have these permissions already set to yes when the app is installed?
我依旧记得有一种方法可以使用与iOS模拟器关联的plist文件来操纵它,但我不是百分之百确定它是否在我脑海中 。我在谷歌上找不到太多。
I vaguely remember there was a way to manipulate this using a plist file associated with iOS simulator, but I'm not 100% sure if "its all in my head". I'm not finding much on google.
推荐答案
根据上面Felipe Sabino的评论,我得出以下结论。 iOS for Xcode 6的权限文件存储在以下位置:〜/ Library / Developer / CoreSimulator / Devices /< device> /data/Library/TCC/TCC.db
。所以我们在控制台上使用sqlite3修改db文件。
Based on the comment by Felipe Sabino above I worked out the following. The permissions file of iOS for Xcode 6 is stored at location: ~/Library/Developer/CoreSimulator/Devices/<device>/data/Library/TCC/TCC.db
. So we modify the db file using sqlite3 on the console.
从终端使用以下Perl脚本。这可以用任何语言完成。
Used the following Perl script from terminal. This could be done in any language really.
$folderLocations = `xcrun simctl list`; // running "xcrun simctl list" on terminal returns iOS device locations
$currentUserID = `id -un`; // get current user
chomp($currentUserID); // remove extra white space from user string
print "currentUserID: $currentUserID"; // debug logs
while($folderLocations =~ /iPad Air \((.{8}-.*?)\)/g) { // Use regex to loop through each iPad Air device found in $folderLocations. Insert the permissions in the database of each.
print "folderLocations <1>: $1\n"; // debug logs
`sqlite3 /Users/$currentUserID/Library/Developer/CoreSimulator/Devices/$1/data/Library/TCC/TCC.db "insert into access values('kTCCServiceAddressBook','com.apple.store.MyApp', 0, 1, 0, 0)"`;
print "\n"; // neat logs
}
这一个覆盖 kTCCServiceAddressBook
权限,但还有 kTCCServiceCalendar
和 kTCCServicePhotos
。
This one overrides kTCCServiceAddressBook
permission, but there is also kTCCServiceCalendar
and kTCCServicePhotos
.
这篇关于iOS权限警报 - 删除或禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!