Last active
January 12, 2018 12:32
-
-
Save onevcat/b4604aecb4ce55651a4a to your computer and use it in GitHub Desktop.
Fuck off ATS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<key>NSAppTransportSecurity</key> | |
<dict> | |
<key>NSAllowsArbitraryLoads</key> | |
<true/> | |
</dict> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/libexec/PlistBuddy -c "Add:NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" ./Info.plist |
写一个 AppleScript 脚本文件:
set plistPath to POSIX path of (choose file of type {"plist"})
tell application "Terminal"
reopen
activate
do script ("/usr/libexec/PlistBuddy -c 'Delete :NSAppTransportSecurity' " & plistPath) in window 1
do script "echo --------------------------------" in window 1
do script "echo 即将添加 NSAppTransportSecurity:NSAllowsArbitraryLoads" in window 1
do script ("/usr/libexec/PlistBuddy -c 'Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool 1' " & plistPath) in window 1
do script "echo --------------------------------" in window 1
do script "echo 添加成功!!!!!!!!!!" in window 1
end tell
运行起来只需要选择目标 Info.plist 文件就可以写入数据了。
使用 Plistbuddy 是否先delete 存在键值比较好,因为存在时add是不行的,需要Set;而且有时手动删除后add,依然报“xxx键已经存在”。
放在AppDelegate中的方法试验没有效果,是使用不正确还是什么问题呢?
@myafer
NSString *str = [NSString stringWithFormat:@"%s", __FILE__]; NSArray *pp = [str componentsSeparatedByString:@"/"]; NSMutableString *mu = [NSMutableString string]; for (int i = 1; i < pp.count - 1; i ++) { [mu appendString:[NSString stringWithFormat:@"/%@", pp[i]]]; } [mu appendString:@"/Info.plist"]; NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithContentsOfFile:mu]; [data setObject:@{@"NSAllowsArbitraryLoads":@(1)} forKey:@"NSAppTransportSecurity"]; [data writeToFile:mu atomically:YES]; NSLog(@"%@", mu);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`
将如下代码保存为 *.sh 文件
将文件放到 Info.plist 所在目录
修改权限 chmod 777 此文件路径
拉入到命令行回车
第二次之后只需要拉到 Info.plist 所在目录 运行就可以了
#!/bin/bash
project_path=$(pwd)
Info_path=$project_path"/Info.plist"
echo ""
echo ""
echo "没检查属性是否存在,警告不用管"
/usr/libexec/PlistBuddy -c 'Delete :NSAppTransportSecurity' $Info_path
echo "--------------------------------"
echo "即将添加 NSAppTransportSecurity:NSAllowsArbitraryLoads"
/usr/libexec/PlistBuddy -c 'Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool 1' $Info_path
echo "--------------------------------"
echo "添加成功!!!!!!!!!!"
echo ""
echo ""
`
将这句放在 Appdelegate 也可以
: '
'