Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yoga.cpp issue with Xcode 14.3 (14E222b) #36758

Closed
nicolasdevienne opened this issue Apr 1, 2023 · 38 comments
Closed

Yoga.cpp issue with Xcode 14.3 (14E222b) #36758

nicolasdevienne opened this issue Apr 1, 2023 · 38 comments
Labels
Needs: Author Feedback Type: Unsupported Version Issues reported to a version of React Native that is no longer supported

Comments

@nicolasdevienne
Copy link

Description

An issue occurs when we try to build project : "Yoga.cpp : Use of bitwise '|' with boolean operands".
When we double the '|', it works...

React Native Version

0.66.4

Output of npx react-native info

System:
OS: macOS 13.3
CPU: (8) arm64 Apple M1 Pro
Memory: 90.30 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 19.7.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.5.0 - /opt/homebrew/bin/npm
Watchman: 2023.02.27.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.12.0 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
Android SDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9619390
Xcode: 14.3/14E222b - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /opt/homebrew/opt/openjdk@11/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.4 => 0.66.4
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Update Xcode with last version 14.3 (14E222b) and try to build project.

Snack, code example, screenshot, or link to a repository

Capture d’écran 2023-04-01 à 10 35 06

@github-actions github-actions bot added the Type: Unsupported Version Issues reported to a version of React Native that is no longer supported label Apr 1, 2023
@github-actions
Copy link

github-actions bot commented Apr 1, 2023

⚠️ Unsupported Version of React Native
ℹ️ It looks like your issue or the example you provided uses an unsupported version of React Native. Due to the number of issues we receive, we're currently only accepting new issues against one of the supported versions. Please upgrade to latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If you cannot upgrade, please open your issue on StackOverflow to get further community support.

@boyphongsakorn
Copy link

boyphongsakorn commented Apr 2, 2023

yeah i same error as you
how to fix that?

double the '|', it works

@keisan1231
Copy link

double the '|', it works

Me too. Thanks

@kelset
Copy link
Contributor

kelset commented Apr 3, 2023

duplicate #36739

@kelset kelset closed this as completed Apr 3, 2023
@sunnylqm
Copy link
Contributor

sunnylqm commented Apr 3, 2023

@kelset this is NOT a dulicate issue.

This affects rn version < 0.69 with Xcode 14.3
52d8a79

@kelset
Copy link
Contributor

kelset commented Apr 3, 2023

I see, thanks for clarifying. But 0.69 is the lowest version supported, so is there a specific reason we should keep this one one if it's only for versions lower than 0.69?

@sunnylqm
Copy link
Contributor

sunnylqm commented Apr 3, 2023

I have no objection to close this issue, but there should be a link or explanation for the correct fix provided. The use of "duplicate" made me think that issue was the correct fix, but I later found out it was not.

jleach added a commit to bcgov/bc-wallet-mobile that referenced this issue Apr 3, 2023
As noted [here](facebook/react-native#36758) there is a problem with the Yoga package in RN building with Xcode 14.3. This is a temporary work around to peg the build to 14.2 until this issue can be resolved more thoroughly.

Ref. [macOS runners](https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md)
@xhirazi
Copy link

xhirazi commented Apr 4, 2023

+1

double the | can solve the issue but what about he permanent solution?

@sunnylqm
Copy link
Contributor

sunnylqm commented Apr 4, 2023

+1

double the | can solve the issue but what about he permanent solution?

this is the official fix applied on version>=0.69, see my comment and link above

@Abhishek2250
Copy link

I'm also getting this issue on xcode cloud CI using react-native version 0.68.4. How can I fix the issue there?
Any ideas?

Thanks

@awatt-cox
Copy link

We have a pipeline that reinstalls all of the dependencies when it builds the app. Does anyone have a post-install script that can fix the broken line of code so our pipeline can build successfully? We have a large, complex app using react-native 67.5, so "just update to 0.69" is not a quick change.

@sunnylqm
Copy link
Contributor

sunnylqm commented Apr 4, 2023

  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.

@fabiendem
Copy link

  1. install patch-package ds300/patch-package
  2. Modify the source code like this commit 52d8a79
  3. run npx patch-package react-native
  4. commit your changes. Done.

Does that work even if you don't build React Native from the source?

@kthilagarajan
Copy link

  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.

I was in react-native 0.66.4. Xcode version 14.3.

This worked for me. Thankyou.

@shinnthantminn
Copy link

fix error

i am add || [Logical OR] operator in hadOverflow() fix this error

@DIOGO-MOTA
Copy link

image

remove this line of code

it worked for me

@dgdapp
Copy link

dgdapp commented Apr 12, 2023

image

remove this line of code

it worked for me

Yes, it worked for me too!! thankk

@andreas-bergstrom
Copy link

Not sure removing that line is such a good move... Just use patch-package and apply the fix

@a7chax
Copy link

a7chax commented May 27, 2023

i am using react-native 0.64, i fix it by downgrading my xcode to version 14.2, facebook/yoga#1224 (comment)

@pvshum
Copy link

pvshum commented Jun 2, 2023

If you don't want to use patch-package, but rather add a singe line in post install you can just run:

sed -i.bo 's/    node->getLayout()\.hadOverflow() |$/\0|/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

When I run this code, it unfortunately replaces node->getLayout().hadOverflow() | to 0| instead of adding one more pipe.

@yorickshan
Copy link

  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.

worked for me

yangyansong-adbe added a commit to yangyansong-adbe/aepsdk-react-native that referenced this issue Jun 13, 2023
yangyansong-adbe added a commit to adobe/aepsdk-react-native that referenced this issue Jun 14, 2023
)

* bump the major version for all packages to 3.0.0 (assurance to 5.0.0)

* align up all package versions and fix Lerna bootstrap issue

* update Xcode to 14.1.0

* show verbose logs when building the ios app

* Fix Yoga issue (facebook/react-native#36758)

* try to fix the Xcode issue
yangyansong-adbe added a commit to adobe/aepsdk-react-native that referenced this issue Jun 20, 2023
* bump the major version for all packages to adopt the iOS SDK 4.0.0 (#271)

* bump the major version for all packages to 3.0.0 (assurance to 5.0.0)

* align up all package versions and fix Lerna bootstrap issue

* update Xcode to 14.1.0

* show verbose logs when building the ios app

* Fix Yoga issue (facebook/react-native#36758)

* try to fix the Xcode issue

* update docs and disable ios build step on CI (#273)
yangyansong-adbe added a commit to adobe/aepsdk-react-native that referenced this issue Jun 20, 2023
* bump the major version for all packages to adopt the iOS SDK 4.0.0 (#271)

* bump the major version for all packages to 3.0.0 (assurance to 5.0.0)

* align up all package versions and fix Lerna bootstrap issue

* update Xcode to 14.1.0

* show verbose logs when building the ios app

* Fix Yoga issue (facebook/react-native#36758)

* try to fix the Xcode issue

* update docs and disable ios build step on CI (#273)

* fix install issue (#275)
@TatianaMatumoto
Copy link

image

remove this line of code

it worked for me

i don't know if this is a good solution, but that worked for me. Adding more '|' throws error on everything on my project.

Tranks for the solution!

IgorNadj added a commit to beyondessential/tupaia that referenced this issue Jul 14, 2023
@fondue-tech
Copy link

Another day another Yoga issue.
The patch file is the best solution right now, especially if you can't just migrate to another react native version.

@danmoz
Copy link

danmoz commented Aug 7, 2023

If you don't want to use patch-package, but rather add a singe line in post install you can just run:
sed -i.bo 's/ node->getLayout().hadOverflow() |$/\0|/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

When I run this code, it unfortunately replaces node->getLayout().hadOverflow() | to 0| instead of adding one more pipe.

Try this instead:

sed -i -e 's/ \|$/ ||/g' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

@miallo
Copy link
Contributor

miallo commented Aug 8, 2023

If you don't want to use patch-package, but rather add a singe line in post install you can just run:

sed -i.bo 's/ node->getLayout().hadOverflow() |$/\0|/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

When I run this code, it unfortunately replaces node->getLayout().hadOverflow() | to 0| instead of adding one more pipe.

Are you sure that you have the \ in front of the 0? \0 is referencing the matched search instead of the literal "0". Otherwise you can just type the same thing again that was in the search part of the command...

@fujikazu
Copy link

fujikazu commented Sep 2, 2023

My error message was

The following build commands failed:
	CompileC /Users/*****/Library/Developer/Xcode/DerivedData/*****-app-efbyvyvzhapcgcaazbonipqeicgj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Yoga.build/Objects-normal/x86_64/Yoga.o /Users/*****/Desktop/*****-app/*****-app-develop/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Yoga' from project 'Pods')
(1 failure)

The following build commands failed:CompileC  (in target 'Yoga' from project 'Pods')

and I tried this command.

./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

sed -i.bo 's/    node->getLayout()\.hadOverflow() |$/\0|/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

this worked for me .

@richarddrum
Copy link

richarddrum commented Sep 9, 2023

If you don't want to use patch-package, but rather add a singe line in post install you can just run:

sed -i.bo 's/    node->getLayout()\.hadOverflow() |$/\0|/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

When I run this code, it unfortunately replaces node->getLayout().hadOverflow() | to 0| instead of adding one more pipe.

You can try this instead:
sed -i.bo 's/ node->getLayout()\.hadOverflow() |/ node->getLayout()\.hadOverflow() ||/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

@jerodji
Copy link

jerodji commented Sep 22, 2023

it works for me,add (int)

    node->setLayoutHadOverflow(
        (int)node->getLayout().hadOverflow |
        (int)currentRelativeChild->getLayout().hadOverflow);

@sufyansalim
Copy link

If you don't want to use patch-package, but rather add a singe line in post install you can just run:

sed -i.bo 's/    node->getLayout()\.hadOverflow() |$/\0|/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

When I run this code, it unfortunately replaces node->getLayout().hadOverflow() | to 0| instead of adding one more pipe.

You can try this instead: sed -i.bo 's/ node->getLayout()\.hadOverflow() |/ node->getLayout()\.hadOverflow() ||/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

after adding this line i get the following build commands failed: CompileC /Users/myname/projects/projectname/ios/DerivedData/aido/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/arm64/json.o /Users/myname/projects/projectname/ios/Pods/RCT-Folly/folly/json.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'RCT-Folly' from project 'Pods') (1 failure)

@matthewbal
Copy link

You can try this instead: sed -i.bo 's/ node->getLayout()\.hadOverflow() |/ node->getLayout()\.hadOverflow() ||/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

By the way, for our version of RN/Yoga, this sed command will also find replace 2 other occurrences which should not be changed and may cause subtle build issues.

We recommend using sed with a line number restriction so that it only changes the one line causing the issue, here is the completed command that we are using in our pipeline to make yoga work with node 16.

sed -i.bo '2289s/ node->getLayout()\.hadOverflow() |/ node->getLayout()\.hadOverflow() ||/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

For us the line number was 2289 with react native 0.64.0, for other versions of RN/yoga it may be a different line number so make sure you check your xcode error and only replace the specific line number you have the issue on.

@sufyansalim
Copy link

i

You can try this instead: sed -i.bo 's/ node->getLayout()\.hadOverflow() |/ node->getLayout()\.hadOverflow() ||/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

By the way, for our version of RN/Yoga, this sed command will also find replace 2 other occurrences which should not be changed and may cause subtle build issues.

We recommend using sed with a line number restriction so that it only changes the one line causing the issue, here is the completed command that we are using in our pipeline to make yoga work with node 16.

sed -i.bo '2289s/ node->getLayout()\.hadOverflow() |/ node->getLayout()\.hadOverflow() ||/' ./node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp

For us the line number was 2289 with react native 0.64.0, for other versions of RN/yoga it may be a different line number so make sure you check your xcode error and only replace the specific line number you have the issue on.

i even manually changed the line didnt work work me instead i get
after adding this line i get the following build commands failed: CompileC /Users/myname/projects/projectname/ios/DerivedData/aido/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/arm64/json.o /Users/myname/projects/projectname/ios/Pods/RCT-Folly/folly/json.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'RCT-Folly' from project 'Pods') (1 failure)

@moustaouiSalaheddine
Copy link

install patch-package
solution commit
in yoga/Yoga.cpp
change this
node->getLayout().hadOverflow() |
to this
node->getLayout().hadOverflow() ||

run patch-package to create a .patch file
npx patch-package react-native

after that commit and push your changes

@Symous
Copy link

Symous commented Dec 21, 2023

use patch-packgae or modify the source code manually is too heavy, I provide another elegant way.

in ios/Podfile add find_add_replace method (I copy this method from the community to solve other XCode related issue before):

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

in pod_install section use find_and_replace to replace the related lines:

find_and_replace("../node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp",
  "node->getLayout().hadOverflow() |\n","node->getLayout().hadOverflow() ||\n")

execute pod install and run again.

@mochadwi
Copy link

use patch-packgae or modify the source code manually is too heavy, I provide another elegant way.

in ios/Podfile add find_add_replace method (I copy this method from the community to solve other XCode related issue before):

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

in pod_install section use find_and_replace to replace the related lines:

find_and_replace("../node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp",
  "node->getLayout().hadOverflow() |\n","node->getLayout().hadOverflow() ||\n")

execute pod install and run again.

unfortunately, when run in CI this is not possible. I tried to run through Xcode Cloud, it failed.

@andreas-bergstrom
Copy link

use patch-packgae or modify the source code manually is too heavy, I provide another elegant way.

in ios/Podfile add find_add_replace method (I copy this method from the community to solve other XCode related issue before):

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

in pod_install section use find_and_replace to replace the related lines:

find_and_replace("../node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp",
  "node->getLayout().hadOverflow() |\n","node->getLayout().hadOverflow() ||\n")

execute pod install and run again.

How is it "too heavy", it's just a few steps and a few min at most?

Shameless plug:
https://dev.to/andreasbergstrom/patch-package-the-essential-tool-for-managing-dependencies-in-both-modern-and-legacy-projects-4hnn

@Symous
Copy link

Symous commented Jun 18, 2024

@andreas-bergstrom what I said "too heavy" is that use patch-package to apply the changes will generate extra but not "important and necessary" patch files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Author Feedback Type: Unsupported Version Issues reported to a version of React Native that is no longer supported
Projects
None yet
Development

No branches or pull requests