iOS9要求App内访问的网络必须使用HTTPS协议。原有的HTTP请求会报错,适配方法如下。

打开TARGETS-Build Phases, 添加New Run Script Phase,代码如下:

# Add exception for Debug builds
if [ "${CONFIGURATION}" == "Debug" ]
then
# Remove exception existing builds
/usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity:NSAllowsArbitraryLoads" "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}"
exitCode=$? #Supresses failure

/usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}"
fi

 

其中"${CONFIGURATION}" == "Debug"的Debug替换为相应编译环境即可

相关文章:

  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-07-27
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2021-05-24
  • 2022-12-23
  • 2021-06-28
  • 2021-10-29
  • 2022-02-03
  • 2022-12-23
  • 2021-11-11
相关资源
相似解决方案