【问题标题】:React Native Build Error: Could not read optimization profile file (even after change optimization configuration)React Native Build Error:无法读取优化配置文件(即使在更改优化配置后)
【发布时间】:2018-01-28 03:49:10
【问题描述】:

我试图通过video 中的步骤解决一些配置问题,之后构建过程不断报告错误。

该视频中的步骤是: 1. project -> clean 2. project -> build 3. project -> perform action -> Generate Optimization File 4. Enable Optimazation

它确实帮助我在连接的设备上运行应用程序。但在此之后,构建过程一直失败,并显示以下错误消息:

Could not read profile [My Project Folder]/node_modules/react-native/React/OptimizationProfiles/React.profdata: No such file or directory

在 SO 上看了几个小时后,我尝试了以下不同的方法,但都没有奏效:
1)

Go to Project -> Build Setting -> Apple LLVM 9.2-code generation  
clear Optimization Profile File // clear is removing the value to empty, correct?  
Clean project and build again

所有目标的优化级别为none
source here

  1. 手动将优化配置文件的路径设置到另一个位置(顺便说一句,没有生成profdata文件,这是另一个错误,但它在连接的设备上运行应用程序)

  2. 按照answers to this question 中的建议删除DerivedData 文件夹

  3. 删除构建文件夹
  4. 清除 Xcode Preference 并重新安装 Xcode

每当我构建它时,它仍在尝试在/node_modules/react-native/React/OptimizationProfiles/React.profdata 中查找文件。使用react-native run-ios 时的结果相同。它是某种缓存吗?(尽管我删除了 DerivedData 文件夹、构建文件夹和清理项目之后)。这里是错误消息的更多信息:

CompileC `MyProjectFolder`/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/yoga.build/Objects-normal/x86_64/YGNodeList.o `MyProjectFolder`/node_modules/react-native/ReactCommon/yoga/yoga/YGNodeList.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/'ausername'/Documents/dev_fs/RecycleWizard/node_modules/react-native/React
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/`SomeUserName`/anaconda/bin:/Users/'SomeUserName'/Documents/apache-maven-3.0.5/bin:/usr/local/heroku/bin:./node_modules/.bin:/Users/'SomeUserName'/.rvm/gems/ruby-2.0.0-p451/bin:/Users/'SomeUserName'/.rvm/gems/ruby-2.0.0-p451@global/bin:/Users/'SomeUserName'/.rvm/rubies/ruby-2.0.0-p451/bin:/Library/JAVA/Home/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/`SomeUserName`/.rvm/bin:/Users/`SomeUserName`/.rvm/bin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fmodules -fmodules-cache-path=`MyProjectFolder`/ios/build/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=`MyProjectFolder`/ios/build/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wmissing-prototypes -Werror=return-type -Wunreachable-code -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wshadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wnewline-eof -DDEBUG=1 -DRCT_DEBUG=1 -DRCT_DEV=1 -DRCT_NSASSERT=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -mios-simulator-version-min=8.0 -g -Wno-sign-conversion -Winfinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -fprofile-instr-use=`MyProjectFolder`/node_modules/react-native/React/OptimizationProfiles/React.profdata -index-store-path `MyProjectFolder`/ios/build/Index/DataStore -I`MyProjectFolder`/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/yoga.build/yoga.hmap -I`MyProjectFolder`/ios/build/Build/Products/Debug-iphonesimulator/include -I`MyProjectFolder`/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/yoga.build/DerivedSources/x86_64 -I`MyProjectFolder`/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/yoga.build/DerivedSources -Wextra -Wall -Wno-semicolon-before-method-body -F`MyProjectFolder`/ios/build/Build/Products/Debug-iphonesimulator -MMD -MT dependencies -MF `MyProjectFolder`/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/yoga.build/Objects-normal/x86_64/YGNodeList.d --serialize-diagnostics `MyProjectFolder`/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/yoga.build/Objects-normal/x86_64/YGNodeList.dia -c `MyProjectFolder`/node_modules/react-native/ReactCommon/yoga/yoga/YGNodeList.c -o `MyProjectFolder`/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/yoga.build/Objects-normal/x86_64/YGNodeList.o

有其他方法可以尝试吗?谢谢

【问题讨论】:

    标签: ios xcode react-native optimization react-native-ios


    【解决方案1】:

    找到了解决方案(但它需要一定程度的重复设置工作),如果您遇到相同的问题并且问题中列出的方法都不起作用,您可以尝试这个(作为最后的手段):

    react-native run-ios 失败后我查看了登录终端并出现以下错误:

    Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier 
    build/Build/Products/Debug-iphonesimulator/SomeProject.app/Info.plist
    Print: Entry, ":CFBundleIdentifier", Does Not Exist  
    

    按照herereact-native upgrade 的建议(react-native 版本是0.47.2),为了确保清理所有缓存,我也按照this thread 中的说明进行了此操作:

    watchman watch-del-all
    rm -rf $TMPDIR/react-*
    rm -rf yarn.lock
    rm -rf ./node_modules
    yarn install
    

    在这些步骤之后,剩下的基本上就是重新设置项目了,我做了react native link和所有其他的react native插件配置(比如更新info.plist)。但之后项目可以成功构建。

    我不确定这是否是 Xcode 或 RN 中的错误(在我使用 perform action -> generate optimization file 之后)它一直试图找到该文件 /node_modules/react-native/React/OptimizationProfiles/React.profdata,这很奇怪。

    希望这会有所帮助。

    【讨论】:

    • 你的回答很有趣,是同一个视频误导了我。
    • @DanielBarde 很高兴它有帮助:)
    【解决方案2】:

    我也有类似的问题。 The only thing i didn't do was run react-native upgrade . 这样做消除了优化配置文件错误。

    删除ios/build 文件夹

    watchman watch-del-all
    rm -rf $TMPDIR/react-*
    rm -rf yarn.lock
    rm -rf ./node_modules
    yarn install
    

    【讨论】:

      【解决方案3】:

      我发现所有在线答案的问题是他们告诉您删除项目级别的优化,而我需要在目标级别完成

      所以点击你的项目 -> 然后选择你的目标 -> 构建设置 -> 使用优化配置文件

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-04-14
        • 1970-01-01
        • 2010-09-08
        • 1970-01-01
        • 1970-01-01
        • 2010-12-28
        • 2021-10-11
        • 1970-01-01
        相关资源
        最近更新 更多