`React/RCTBridgeModule.h` file not found

后端 未结 21 2329
执笔经年
执笔经年 2020-11-30 00:31

Getting this error while building a react-native iOS app on xcode.

Started getting this error after npm install and rpm linking react-native-fs library. But

21条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 01:00

    If you want to keep Parallelise Build enabled and avoid the missing header problems, then provide a pre-build step in your scheme to put the react headers into the derived-data area. Notice the build settings are coming from the React project in this case. Yes it's not a thing of beauty but it gets the job done and also shaves a lot of time off the builds. The prebuild step output ends up in prebuild.log. The exact headers you'll need to copy over will depend on your project react-native dependencies, but you'll get the jist from this.

    Get the derived data directory from the environment variables and copy the required react headers over.

    #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/" \;
    

    The script does get invoked during a build-clean - which is not ideal. In my case there is one env variable which changes letting me exit the script early during a clean.

    if [ "$RUN_CLANG_STATIC_ANALYZER" != "NO" ] ; then
        exit 0 
    fi
    

提交回复
热议问题