2016-01-13 98 views

回答

2

我找到的解决方案需要使用的PlistBuddy

在您的项目设置,选择Build期>单击+添加一个新的运行脚本生成阶段。

命名阶段“App Transport Security”。 粘贴以下脚本:

if [ "${CONFIGURATION}" = "Release" ]; 
then 
    /usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads false" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" 
else 
    /usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsArbitraryLoads true" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}" 
fi