Skip to content

Instantly share code, notes, and snippets.

@onevcat
Last active January 12, 2018 12:32
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save onevcat/b4604aecb4ce55651a4a to your computer and use it in GitHub Desktop.
Save onevcat/b4604aecb4ce55651a4a to your computer and use it in GitHub Desktop.
Fuck off ATS
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
/usr/libexec/PlistBuddy -c "Add:NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" ./Info.plist
@github641
Copy link

github641 commented Nov 24, 2016

使用 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