80

Just updated my XCode to Version 14.3 today and build is failing with below error in Yoga file

Use of bitwise '|' with boolean operands

Looks like we have some issues with iOS yoga package. I don't want to rollback to lower version again. If someone can help to get over it, that would be nice.

I tried removing cached data and derived data & cleaning build. Tried removing pods and node_modules as well. But nothing has helped.

Mitesh Baraiya
  • 2,095
  • 2
  • 3
  • 11
  • 1
    Here's a link to the react-native issue and suggested workaround for react-native 0.66 users: https://github.com/facebook/react-native/issues/36758#issuecomment-1496210081 – Carl G Apr 15 '23 at 05:29

2 Answers2

124

I resolved it by putting 2 Vertical bars || instead of one | in the code where it is failing.

Then cleared the build and it is working fine now on XCode 14.3. I Hope this helps someone.

Edit:

Above one is temporary solution. By using following solution we do not need to make change on every npm installation. It is suggested by @Carl G. @Mykola Odnosumov 's Solution in this thread is also helpful, it is similar solution. Thank you @Carl G and @Mykola Odnosumov

https://github.com/facebook/react-native/issues/36758#issuecomment-1496210081

  1. install patch-package https://github.com/ds300/patch-package
  2. Modify the source code like this commit 52d8a79
  3. run npx patch-package react-native
  4. commit your changes. Done.
Mitesh Baraiya
  • 2,095
  • 2
  • 3
  • 11
  • Did you have to address this in a CI pipeline? I need to fix this when the repo is cloned on each build – cBlaine Apr 17 '23 at 11:21
  • 1
    This is an excellent temporary solution, but for me, it keeps going back to one `|` every once in a while (I think after each pod install). Is there a better, permanent solution to this? – Cezar Cobuz Apr 19 '23 at 07:41
  • Hey @CezarCobuz, I have edited the answer. Please follow above steps so you won't need to make this change on every once in a while. – Mitesh Baraiya Apr 27 '23 at 06:37
  • Just update "|" to "||" in Yoga.cpp (line:2232) is OK – Soul Clinic Aug 28 '23 at 03:42
38

General

This issue's been fixed in Yoga v1.19.0

Check out this commit dated Apr 12, 2022, and release v1.19.0 dated May 21, 2021.

How to fix

  1. Update the Yoga package to v1.19.0, if possible.
  2. Use patch-package for development ease
    1. Add postinstall script to package.json file with patch-package call
    2. Edit react-native/ReactCommon/yoga/yoga/Yoga.cpp to fix the issue with incorrect operator used
    3. Execute npx patch-package react-native to generate .patch file
    4. Make sure to add patches/ directory to git
  • 5
    Note that if you are not using standalone Yoga (meaning its a dependency instead), there will be no 1.19.0 available to use. plus, it appears the latest podspec for Yoga is **still** 1.14.0, even on the release tagged 1.19.0, so not sure if that's a mistake on their github? – stonedauwg Apr 05 '23 at 17:46
  • correct @stonedauwg, looks like using the patch-package would be the only working solution for now – Mitesh Baraiya Apr 27 '23 at 06:40
  • Worked for me! No need to clean the project! Thanks. – Maicon Gilton May 13 '23 at 13:51
  • Worked for me on M1 Max! Thanks! – Todd Jul 15 '23 at 18:14
  • Just manually fix the issue in /node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp file node->getLayout().hadOverflow() || – Manoj Alwis Aug 17 '23 at 00:09