software-mansion / react-native-screens

Native navigation primitives for your React Native app.
MIT License
2.9k stars 498 forks source link

iOS build fails with Undefined symbols: facebook::jsi::HostObject::~HostObject() #2117

Closed taksvals closed 2 weeks ago

taksvals commented 2 months ago

Description

Hi, I am trying to upgrade my app from react-native 0.72.4 -> 0.73.7 and I am encountering an issue with react-native-screens. After updating react-native-screens to latest(3.31.1) I can't build iOS. Android is build successfully.

Error: ld: Undefined symbols: facebook::jsi::HostObject::~HostObject(), referenced from: RNScreens::RNScreensTurboModule::RNScreensTurboModule(std::__1::function<std::__1::array<int, 2ul> (int)>, std::__1::function<void (int, double)>, std::__1::function<void (int, bool)>, std::__1::function<void (int)>) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::~RNScreensTurboModule() in RNScreensTurboModule.o facebook::jsi::Value::Value(facebook::jsi::Value&&), referenced from: facebook::jsi::Value::operator=(facebook::jsi::Value&&) in RNScreensTurboModule.o facebook::jsi::Value::Value(facebook::jsi::Runtime&, facebook::jsi::Value const&), referenced from: facebook::jsi::detail::toValue(facebook::jsi::Runtime&, facebook::jsi::Value const&) in RNScreensTurboModule.o facebook::jsi::Value::~Value(), referenced from: RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o ... facebook::jsi::JSError::JSError(facebook::jsi::Runtime&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>), referenced from: facebook::jsi::JSError::JSError(facebook::jsi::Runtime&, char const*) in RNScreensTurboModule.o facebook::jsi::JSError::~JSError(), referenced from: RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::updateTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::finishTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::disableSwipeBackForTopScreen(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o facebook::jsi::Value::asNumber() const, referenced from: RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::updateTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::updateTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::finishTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::disableSwipeBackForTopScreen(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o typeinfo for facebook::jsi::HostObject, referenced from: typeinfo for RNScreens::RNScreensTurboModule in RNScreensTurboModule.o typeinfo for facebook::jsi::JSError, referenced from: RNScreens::RNScreensTurboModule::startTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::updateTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::finishTransition(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o RNScreens::RNScreensTurboModule::disableSwipeBackForTopScreen(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) in RNScreensTurboModule.o vtable for facebook::jsi::HostObject, referenced from: facebook::jsi::HostObject::HostObject() in RNScreensTurboModule.o clang: error: linker command failed with exit code 1 (use -v to see invocation)

When using older version 3.25.0 iOS is build successfully, but Android fails with this issue #1515. I saw similar issue #2054 and tried using 3.27.0 but it didn't work, every version starting from 3.26.0 crushes on iOS.

Steps to reproduce

  1. Upgrade react-native to 0.73.7
  2. Upgrade react-native-screens to 3.31.1
  3. Try running iOS

Snack or a link to a repository

--

Screens version

3.31.1

React Native version

0.73.7

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Real device

Device model

iPhone 11 17.4.1

Acknowledgements

Yes

github-actions[bot] commented 2 months ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] commented 2 months ago

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Snack or a link to a repository section.

tboba commented 1 month ago

Hi, @taksvals! After creating a minimal repro from npx react-native init with version 0.73.7 and adding react-native-screens dependency along with react-native-safe-area-context, I'm unfortunately unable to reproduce this issue. Could you send us a minimal reproducer that reproduces this bug, or at least:

zhangfushuai commented 1 month ago

@tboba I have the same error on IOS

npx react-native info info Fetching system and libraries information... System: OS: macOS 14.4.1 CPU: (8) arm64 Apple M1 Memory: 1.30 GB / 16.00 GB Shell: version: 3.2.57 path: /bin/bash Binaries: Node: version: 18.20.2 path: /opt/homebrew/opt/node@18/bin/node Yarn: version: 1.22.22 path: /opt/homebrew/bin/yarn npm: version: 10.5.0 path: /opt/homebrew/opt/node@18/bin/npm Watchman: version: 2024.05.06.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms:

and the podfile is use_frameworks! require Pod::Executable.execute_command('node', ['-p', 'require.resolve( "react-native/scripts/react_native_pods.rb", {paths: [process.argv[1]]}, )', dir]).strip platform :ios, min_ios_version_supported prepare_react_native_project!

linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end tep = 1 target 'detectiveRN' do config = use_native_modules! tep = config

Flags change depending on the env values.

flags = get_default_flags()

use_react_native!( :path => config[:reactNativePath],

Hermes is now enabled by default. Disable by setting this flag to false.

:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.

:flipper_configuration => flipper_config,

# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."

)

target 'detectiveRNTests' do inherit! :complete

Pods for testing

end

end

post_install do |installer| react_native_post_install( installer, tep[:reactNativePath], :mac_catalyst_enabled => false ) __apply_Xcode_12_5_M1_post_install_workaround(installer) installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' config.build_settings['CODE_SIGN_IDENTITY'] = '' if config.name == 'Debug' config.build_settings['OTHER_SWIFT_FLAGS'] = ['$(inherited)', '-Onone'] config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Owholemodule' end end end end

itlijunjie commented 1 month ago

I think it's because you're using use_frameworks! in your Podfile My solution was to add the following to RNScreens.podspec file:

s.requires_arc = true
# Add the code below
if ENV["USE_HERMES"] == "1"
    s.dependency "hermes-engine"
else
    s.dependency "React-jsi"
end

The corresponding implementations are found in both React-RCTBlob.podspec and some other Pods.

taksvals commented 2 weeks ago

After updating react-native to 0.74.0 and react-native-screens to 3.31.1 I can build both iOS and Android Thanks for the support, will close the issue.