iOS9要求網絡使用HTTPS協議-解決辦法

iOS9要求App內訪問的網絡必須使用HTTPS協議。原有的HTTP請求會報錯,適配方法以下。網絡

打開TARGETS-Build Phases, 添加New Run Script Phase,代碼以下:post

複製代碼
# 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替換爲相應編譯環境便可ui

相關文章
相關標籤/搜索