title: React Native Build Error: Could not read optimization profile file (even after change optimization configuration)
body: <p>I was trying to solve some provision issue with steps in this <a href="https://www.youtube.com/watch?v=TDN1Dp_GqnM" rel="noreferrer">video</a>, after that the building process keeps reporting error.  </p>
  
  <p>The steps in that video are:
  <code>
  1. project -&gt; clean
  2. project -&gt; build
  3. project -&gt; perform action -&gt; Generate Optimization File
  4. Enable Optimazation
  </code> 
  <a href="https://i.stack.imgur.com/qkFcx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qkFcx.png" alt="enter image description here"></a></p>
  
  <p>It does help me to run the App on connected device. But after this, the building process keeps failing with below error message:</p>
  
  <p><code>Could not read profile [My Project Folder]/node_modules/react-native/React/OptimizationProfiles/React.profdata: No such file or directory
  </code></p>
  
  <p>After looking around on SO for hours, I've tried different approaches below but none of them worked:<br>
  1)</p>
  
  <pre><code>Go to Project -&gt; Build Setting -&gt; Apple LLVM 9.2-code generation  
  clear Optimization Profile File // clear is removing the value to empty, correct?  
  Clean project and build again
  </code></pre>
  
  <p>optimization level is <code>none</code> for all targets:
  <a href="https://i.stack.imgur.com/iKiUb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iKiUb.png" alt="optimization level is none for all targets"></a><br>
  <a href="https://stackoverflow.com/questions/48110213/apple-llvm-9-0-error-group-could-not-read-profile-no-such-file-or-directory-fou">source here</a>  </p>
  
  <ol start="2">
  <li><p>Manually set the path of Optimization Profile File to another location(no profdata file generated btw, it is another error, but it runs app on connected device)  </p></li>
  <li><p>Remove <code>DerivedData</code> folder as suggested in <a href="https://stackoverflow.com/questions/27480316/archive-apple-llvm-6-0-error-could-not-read-profile">answers to this question</a>  </p></li>
  <li>Remove Build folder  </li>
  <li>Clear Xcode Preference and reinstall Xcode  </li>
  </ol>
  
  <p>Whenever I build it is still trying to find file in <code>/node_modules/react-native/React/OptimizationProfiles/React.profdata</code>. Same result when using <code>react-native run-ios</code>. Is it some kind of cache?(although I removed DerivedData Folder, Build Folder, and cleaned project after).Here is more info of the error message:<br>
  <a href="https://i.stack.imgur.com/yYugm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yYugm.png" alt="enter image description here"></a>  </p>
  
  <pre><code>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
  </code></pre>
  
  <p>Any idea of other approaches to try? Thanks</p>