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 |
使用 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
写一个 AppleScript 脚本文件:
运行起来只需要选择目标 Info.plist 文件就可以写入数据了。