1

我在构建阶段添加了一个脚本作为运行脚本,它试图修改应用程序传输安全配置。该脚本似乎不适用于 Xcode New Build System。特别是,当我在 Simulator ( DevelopmentDebug) 中执行应用程序时,我仍然遇到 ATS 错误。

你有没有遇到过同样的问题?

echo "Run Application Transport Security script for ${CONFIGURATION}"

if [[ ${CONFIGURATION} == "DevelopmentDebug" || ${CONFIGURATION} == "DevelopmentRelease" ]]; then
    # Delete any existing NSAppTransportSecurity configurations
    /usr/libexec/PlistBuddy -c "Delete :NSAppTransportSecurity" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"

    # Add the NSAppTransportSecurity dictionary again
    /usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity dict" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"

    # Add NSAllowsArbitraryLoads and set it to true
    /usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool true" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
    # Add NSAllowsArbitraryLoadsInWebContent and set it to true
    /usr/libexec/PlistBuddy -c "Add :NSAppTransportSecurity:NSAllowsArbitraryLoadsInWebContent bool true" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
fi

# Print Info.plist result
/usr/libexec/PlistBuddy -c "Print" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
4

0 回答 0