如果要保持启用Parallelise Build并避免缺少标头的问题,请在方案中提供一个预构建步骤,以将react标头放入派生数据区域。注意,在这种情况下,构建设置来自React项目。是的,这不是美的事,但它可以完成工作,而且可以节省大量时间。prebuild步骤的输出最终在prebuild.log中。您需要复制的确切头文件将取决于您的项目react-native依赖项,但是您将从中得到了第一要务。
从环境变量获取派生数据目录,然后复制所需的react标头。
#build_prestep.sh (chmod a+x)
derived_root=$(echo $SHARED_DERIVED_FILE_DIR|sed 's/DerivedSources//1')
react_base_headers=$(echo $PROJECT_FILE_PATH|sed 's#React.xcodeproj#Base/#1')
react_view_headers=$(echo $PROJECT_FILE_PATH|sed 's#React.xcodeproj#Views/#1')
react_modules_head=$(echo $PROJECT_FILE_PATH|sed 's#React.xcodeproj#Modules/#1')
react_netw_headers=$(echo $PROJECT_FILE_PATH|sed 's#React/React.xcodeproj#Libraries/Network/#1')
react_image_header=$(echo $PROJECT_FILE_PATH|sed 's#React/React.xcodeproj#Libraries/Image/#1')
echo derived root = ${derived_root}
echo react headers = ${react_base_headers}
mkdir -p ${derived_root}include/React/
find "${react_base_headers}" -type f -iname "*.h" -exec cp {} "${derived_root}include/React/" \;
find "${react_view_headers}" -type f -iname "*.h" -exec cp {} "${derived_root}include/React/" \;
find "${react_modules_head}" -type f -iname "*.h" -exec cp {} "${derived_root}include/React/" \;
find "${react_netw_headers}" -type f -iname "*.h" -exec cp {} "${derived_root}include/React/" \;
find "${react_image_header}" -type f -iname "*.h" -exec cp {} "${derived_root}include/React/" \;
该脚本确实在构建清理期间被调用-这不是理想的选择。在我的情况下,有一个env变量会更改,使我可以在清理过程中尽早退出脚本。
if [ "$RUN_CLANG_STATIC_ANALYZER" != "NO" ] ; then
exit 0
fi