Sentry Answers>React Native>

Use of bitwise '|' with boolean operands | Xcode 14.3 fails builds using react-native Yoga

Use of bitwise '|' with boolean operands | Xcode 14.3 fails builds using react-native Yoga

Matthew C.

The Problem

When creating the build for a React Native project in Xcode IDE version 14.3 or above, you get the following error:

Click to Copy
Use of bitwise '|' with boolean operands

This is an npm dependency error. It occurs in the Yoga.cpp file of the React Native dependency and layout engine, Yoga. This error only occurs when using React Native version 0.68 or lower or when running unpatched versions of React version 0.6, 0.70, or 0.71.

The Solution

Upgrade to React Native version 0.72+ or to one of the patch releases with an added fix for the issue:

  • Version 0.71.6
  • Version 0.70.8
  • Version 0.69.9

If upgrading is not possible or if you need a quick fix, you can change the bitwise operator | to the boolean operator || yourself. You can use a library such as patch-package to make and keep fixes to the React Native npm dependency.

Another option is to downgrade your Xcode to version 14.2.1 or lower, as older versions do not have the version checks that cause the error.

Note

The C++ Yoga code changed the bitwise operator | to the boolean operator || to guarantee a return of true or false only.

The root cause of the error is that Xcode version 14.3 introduced some version checks, including an iOS version check. React Native uses CocoaPods to manage library dependencies for Xcode projects. The library dependency React-Codegen supports iOS 11, which does not build with Xcode 14.3 as described in this React Native PR.

  • Syntax.fm logo
    Listen to the Syntax Podcast

    Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.

    SEE EPISODES

Considered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.

© 2024 • Sentry is a registered Trademark of Functional Software, Inc.