facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.41k stars 24.36k forks source link

0.74.2: RCTDeprecation/RCTDeprecation.h file not found #45029

Closed fbp93 closed 4 months ago

fbp93 commented 5 months ago

Description

I'm trying to bump my project to React Native 0.74.2, but iOS is failing to compile due to the following issue:

RCTDeprecation/RCTDeprecation.h file not found in RCTBridgeModule

This is happening only when I try to link a static library to my project which contains some object C code that imports React native. I reproduced the issue on a template project and tested with different versions:

Steps to reproduce

Perform the following commands:

  1. yarn
  2. cd ios
  3. bundle install
  4. bundle exec pod install
  5. cd ..
  6. yarn ios --simulator="iPhone 14" or try to build from xcode the main target or the AudioManager library

React Native Version

0.74.2

Affected Platforms

Other (please specify)

Output of npx react-native info

System:
  OS: macOS 14.2.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 95.41 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.2
    path: ~/Library/Caches/fnm_multishells/92447_1718654768551/bin/node
  Yarn:
    version: 3.6.4
    path: /usr/local/bin/yarn
  npm:
    version: 10.5.0
    path: ~/Library/Caches/fnm_multishells/92447_1718654768551/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK:
    Android NDK: 24.0.8215888
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10671973
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.23
    path: /opt/homebrew/Cellar/openjdk@11/11.0.23/bin/javac
  Ruby:
    version: 3.0.0
    path: /Users/work/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.2
    wanted: 0.74.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

Ld /Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/RNTemplate.app/RNTemplate normal (in target 'RNTemplate' from project 'RNTemplate')
    cd /Users/work/Documents/Fab/Progetti/Evernote/RNTemplateTest-0.74.2/ios
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -Xlinker -reproducible -target arm64-apple-ios13.4-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk -O0 -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk/usr/lib/swift -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/DoubleConversion -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/RCT-Folly -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/RCTDeprecation -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/RCTTypeSafety -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-Codegen -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-Core -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-CoreModules -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-Fabric -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-FabricImage -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-ImageManager -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-Mapbuffer -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-NativeModulesApple -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTAnimation -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTAppDelegate -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTBlob -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTFabric -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTImage -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTLinking -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTNetwork -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTSettings -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTText -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RCTVibration -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RuntimeApple -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RuntimeCore -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-RuntimeHermes -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-cxxreact -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-debug -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-featureflags -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-graphics -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-hermes -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-jserrorhandler -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-jsi -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-jsiexecutor -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-jsinspector -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-logger -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-nativeconfig -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-perflogger -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-rendererdebug -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-runtimescheduler -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/React-utils -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/ReactCommon -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/SocketRocket -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/Yoga -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/fmt -L/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/glog -F/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator -F/Users/work/Documents/Fab/Progetti/Evernote/RNTemplateTest-0.74.2/ios/Pods/hermes-engine/destroot/Library/Frameworks/universal -F/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/hermes-engine/Pre-built -filelist /Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Intermediates.noindex/RNTemplate.build/Debug-iphonesimulator/RNTemplate.build/Objects-normal/arm64/RNTemplate.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Intermediates.noindex/RNTemplate.build/Debug-iphonesimulator/RNTemplate.build/Objects-normal/arm64/RNTemplate_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -stdlib\=libc++ -fobjc-arc -fobjc-link-runtime -ObjC -lDoubleConversion -lRCT-Folly -lRCTDeprecation -lRCTTypeSafety -lReact-Codegen -lReact-Core -lReact-CoreModules -lReact-Fabric -lReact-FabricImage -lReact-ImageManager -lReact-Mapbuffer -lReact-NativeModulesApple -lReact-RCTAnimation -lReact-RCTAppDelegate -lReact-RCTBlob -lReact-RCTFabric -lReact-RCTImage -lReact-RCTLinking -lReact-RCTNetwork -lReact-RCTSettings -lReact-RCTText -lReact-RCTVibration -lReact-RuntimeApple -lReact-RuntimeCore -lReact-RuntimeHermes -lReact-cxxreact -lReact-debug -lReact-featureflags -lReact-graphics -lReact-hermes -lReact-jserrorhandler -lReact-jsi -lReact-jsiexecutor -lReact-jsinspector -lReact-logger -lReact-nativeconfig -lReact-perflogger -lReact-rendererdebug -lReact-runtimescheduler -lReact-utils -lReactCommon -lSocketRocket -lYoga -lc++ -lc++abi -lfmt -lglog -licucore -framework Accelerate -framework AudioToolbox -framework CFNetwork -framework JavaScriptCore -framework MobileCoreServices -framework Security -framework UIKit -framework hermes -ObjC -lc++ -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Intermediates.noindex/RNTemplate.build/Debug-iphonesimulator/RNTemplate.build/RNTemplate.app-Simulated.xcent -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __ents_der -Xlinker /Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Intermediates.noindex/RNTemplate.build/Debug-iphonesimulator/RNTemplate.build/RNTemplate.app-Simulated.xcent.der /Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/libAudioManager.a -lPods-RNTemplate -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Intermediates.noindex/RNTemplate.build/Debug-iphonesimulator/RNTemplate.build/Objects-normal/arm64/RNTemplate_dependency_info.dat -o /Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/RNTemplate.app/RNTemplate

clang: error: no such file or directory: '/Users/work/Library/Developer/Xcode/DerivedData/RNTemplate-cpqmrbqjvkisymbbqpaozslyhsbg/Build/Products/Debug-iphonesimulator/libAudioManager.a'

Reproducer

https://github.com/fbp93/RN-0.74.2

Screenshots and Videos

No response

fbp93 commented 5 months ago

I also checked and it's breaking starting from 0.74.0

fbp93 commented 5 months ago

@cipolleschi can you have a look when you have some time? thanks 🙏

max-quirk commented 5 months ago

Also getting this issue :'(

cipolleschi commented 5 months ago

Looking into it. We probably make a mistake in configuring the RCTDeprecation podspec.

cipolleschi commented 5 months ago

@fbp93 I tried the app and the main target builds fine with static libraries and static frameworks.

AudioManager fails, but it fails because React/RCTBridgeModule.h' file not found, not RCTDeprecation not found

Screenshot 2024-06-27 at 17 57 37

I think that the problem is in the header search paths. If you look at the search paths for the main project, they look like this:

Screenshot 2024-06-27 at 18 06 38

The header search paths of the AudioManager looks like this:

Screenshot 2024-06-27 at 18 07 05

The structure of React-Core on disk is like this:

Screenshot 2024-06-27 at 18 07 35

And, as you can see, there is no folder called Public after Headers.

This type of setup, anyway, is not something we recommend: it would be better to create a proper pod for an external library, to benefit from all the automations we are building for autolinking.

That said, @fbp93 and @max-quirk, if you can provide a reproducer where I can see the RCTDeprecation.h file not found happen, I'll be glad to dig into it more closely!

fbp93 commented 4 months ago

And, as you can see, there is no folder called Public after Headers.

@cipolleschi Shouldn't the header search path link to the headers in the pods? Because there I see the public folder. Have you been able to make the audio manager build by that change ? 🤔 Screenshot 2024-06-28 at 09 35 32

This type of setup, anyway, is not something we recommend: it would be better to create a proper pod for an external library, to benefit from all the automations we are building for autolinking.

Unfortunatly I have a lots of them with the current setup, so it's not something I was plan to do immediatly, but I'll definitely consider it

cipolleschi commented 4 months ago

Shouldn't the header search path link to the headers in the pods?

nope, because with frameworks, the items that are copied to the bundle and used for linking are the content of the .framework folder.

Have you been able to make the audio manager build by that change ?

Unfortunately not, once I saw that the setup was not standard and the error was different, I stopped. I think we should first understand why we are seeing two different errors.

Unfortunatly I have a lots of them with the current setup, so it's not something I was plan to do immediatly, but I'll definitely consider it

😞 But I understand. Working with legacy projects is tough. I'm going to be on PTO next week, but I plan to resume the work on this when I'm back.

fbp93 commented 4 months ago

nope, because with frameworks, the items that are copied to the bundle and used for linking are the content of the .framework folder.

the weird thing is that the same setup was working fine with the previous react and even if I try to remove the public it's not working anyway 🤔

Unfortunately not, once I saw that the setup was not standard and the error was different, I stopped. I think we should first understand why we are seeing two different errors.

Actually it seems that sometimes I get your same error and sometimes the RCTDeprecation one, so I think it's kind of related. Probably if we are able to make it build we may fix both or understand more 🤔

cipolleschi commented 4 months ago

@fbp93 any news on this?

In 0.73, we didn't have the RCTDeprecation module, so that's probably why it was working.

cipolleschi commented 4 months ago

@fbp93 I investigated this a little bit more.

First of all, my bad. I was trying to build with use_frameworks, but after reading the issue again, I can see that that was not the case. Without frameworks, the search path you were using ($(SRCROOT)/../../ios/Pods/Headers/Public/React-Core) is correct.

I added another search path there: $(SRCROOT)/../../ios/Pods/Headers/Public.

Screenshot 2024-07-09 at 15 42 33

and after that, it builds correctly.

The problem is that the Audio Manager was not finding the header in the available search paths. Starting from Public, the RCTDeprecation.h header is in the path RCTDeprecation/RCTDeprecation.h that is exactly the same import you have in the file.

This is not a standard and officially supported setup, so I don't think we can/should modify core to automate this. I hope this is enough to understand how these search paths work and to fix them forward for all the modules.

fbp93 commented 4 months ago

thanks! It seems working now (at least this building phase). I'll late you know if I have any other issue while migrating to the latest version. I'm gonna close the issue

amoiseenko-sc commented 4 months ago

@fbp93 How did you resolve the issue?

fbp93 commented 4 months ago

@fbp93 How did you resolve the issue?

I changed the header path as suggested in the above message

dcisneros2 commented 4 months ago

@fbp93 Any other steps you did? For me the issue is still reproducible even after those steps above with header change.

cipolleschi commented 3 months ago

@dcisneros2 can you provide a reproducer for your project? @fbp93 project setup was quite different from the standard, so the solution that works for them might not be applicable to your case.

Japoncio3k commented 3 months ago

Hi! I am facing this issue when using use_frameworks! :linkage => :static, the solution didn't work for me and my Pods/Headers doesn't have any RCTDeprecated file/folder

cipolleschi commented 3 months ago

@Japoncio3k which version are you using? Have you tried to re run yarn install and pod install? The folder has to be there.

If you can provide a reproducer, I can help out.

Japoncio3k commented 3 months ago

Yes, I am running on 0.74.5 I have already tried to delete node_modules and yarn.lock and used pod deintegrate too Will try to make a reproducer

Japoncio3k commented 3 months ago

I was able to fix this by removing use_frameworks! :linkage => :static and adding :modular_headers => true to pods that needed the use_frameworks!