react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

Undefined symbols for architecture arm64: "_OBJC_CLASS_$_RNSScreenView", referenced from: REAUIManager.o

Open tapz opened this issue 3 years ago • 15 comments

Description

When compiling for iOS in Xcode I get the following error in linking phase:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_RNSScreenView", referenced from:
      objc-class-ref in REAUIManager.o
ld: symbol(s) not found for architecture arm64

Expected behavior

No errors.

Actual behavior & steps to reproduce

Build fails in Xcode.

  1. Select build from code.

Snack or minimal code example

podfile:

platform :ios, '11.0'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
project 'MyApp.xcodeproj'

install! 'cocoapods', :deterministic_uuids => false

def pods
  config = use_native_modules!
  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => false
  )
  use_frameworks!
  
  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
  pod 'ReachabilitySwift'
end

target 'MyApp' do
    pods
end

pre_install do |installer|
  installer.pod_targets.each do |pod|
    if pod.name.eql?('RNScreens')
      def pod.build_type
        Pod::BuildType.static_library
      end
    end
  end

  Pod::Installer::Xcode::TargetValidator.send(
    :define_method,
    :verify_no_static_framework_transitive_dependencies
  ) {}
end

post_install do |installer|
  react_native_post_install(installer)
  __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['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
    end
    
    if (target.name&.eql?('FBReactNativeSpec'))
      target.build_phases.each do |build_phase|
        if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
          target.build_phases.move(build_phase, 0)
        end
      end
    end
  end

  # Flipper requires a crude patch to bump up iOS deployment target, or "error: thread-local storage is not supported for the current target"
  # I'm not aware of any other way to fix this one other than bumping iOS deployment target to match react-native (iOS 11 now)
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
      end
  end

  # ...but if you bump iOS deployment target, Flipper barfs again "Time.h:52:17: error: typedef redefinition with different types"
  # We need to make one crude patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1
  # https://github.com/facebook/flipper/issues/834 - 84 comments and still going...
  `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
end

Package versions

  • React Native: 0.66.0
  • React Native Reanimated: 2.3.0-beta.2
  • React Native Screens: 3.8.0
  • NodeJS: 14.18.0
  • Xcode: 13.0 (13A233)
  • Java & Gradle: OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing), Gradle 7.2
  • CocoaPods: 1.11.2

Affected platforms

  • [ ] Android
  • [X] iOS
  • [ ] Web

tapz avatar Oct 15 '21 13:10 tapz

Issue validator

The issue is valid!

github-actions[bot] avatar Oct 15 '21 13:10 github-actions[bot]

Maybe REAnimated 2.3.0-beta2 and React Native Screens 3.8.0 are not compatible.

tapz avatar Oct 15 '21 13:10 tapz

Any solution Please update me

codal-mpawar avatar Dec 08 '21 06:12 codal-mpawar

Hey !

Any update on this issue would be highly appreciated 👍 I've tried with 2.3.0-beta2 and the most recent 2.3.1 release, but still having this very issue when building archive in xCode. My react-native-screens is set to 3.7.0

jmazier-j2d avatar Dec 16 '21 12:12 jmazier-j2d

It seems like you are building screens statically, you may have to add this library to your app target.

In "General" tab: image

image

Please let me know if it helped.

jakub-gonet avatar Jan 28 '22 10:01 jakub-gonet

@jakub-gonet solution didn't work for me. I've been facing this issue with RN-reanimated 2.3.x, 2.4.x. I'm stuck on v2.2.4 which is the last one to work

play-station avatar Feb 07 '22 15:02 play-station

@architect-aimonkey I supposed that cause of your issue is a little different but has the same symptoms as this issue. Is it possible for you to provide me with a repro to reproduce your issue?

piaskowyk avatar Feb 08 '22 11:02 piaskowyk

@piaskowyk I upgraded from reanimated 2.2.4 to 2.8.0 and it works on Android but on iOS I get the message

Undefined symbols for architecture arm64: "OBJC_CLASS$_RNSScreenView", referenced from: objc-class-ref in REAUIManager.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm using XCode 13.2.1, node 14, tried targeting from iOS 12 to 14.3 React Native 0.68.1

play-station avatar May 01 '22 11:05 play-station

Hello, same error as @architect-aimonkey here with RN 0.63.4 and RN 0.66.4. So as we didn't find any solution for this ios build error, we stay in reanimated 2.2.4 and upgrade to 2.8.0 on demand when we need to debug remotely on android.

Aurelienlajoinie avatar May 02 '22 07:05 Aurelienlajoinie

Hi, any update on this issue? We cannot get past reanimated 2.2.4 on iOS

play-station avatar May 08 '22 15:05 play-station

Hi, any update on this issue? We cannot get past reanimated 2.2.4 on iOS

Same

barak109 avatar May 10 '22 11:05 barak109

btw I've just tested 3.0.0-rc and the issue is still there

play-station avatar May 23 '22 16:05 play-station

Hi guys, any update on a possible fix? I tested reanimated 2.9.1 and it has the same issue

play-station avatar Jul 20 '22 04:07 play-station

Hello guys,

Finally this morning i was able to build RN 0.66.4 project with reanimated v2.9.1 for this i have to

  • Upgrade react-native-screens to v3.15.0
  • Remove RNScreens from static library preinstall script from Podfile
target 'myTarget' do
  inherit! :complete
  use_expo_modules!

  config = use_native_modules!
  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  # here come my pods
  ...

  use_frameworks!
end



$static_libraries = [
  # 'RNScreens' <==== remove it
  'RNVectorIcons', 'RNPermissions', ...
]

pre_install do |installer|
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
  installer.pod_targets.each do |pod|
    if $static_libraries.include?(pod.name) || pod.name.start_with?('Permission-')
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

post_install do |installer|
    ....
end

I still have a problem with bottom-sheet on debug but its another fight :D Now im able to build both android and iOS and debug remotely works again on android !

Hope it can help you :)

Aurelienlajoinie avatar Jul 20 '22 09:07 Aurelienlajoinie

The solution provided by @Aurelienlajoinie works like a charm! Thank you very much. Also, do not add RNScreens to the app target, contrary to what @jakub-gonet suggested.

play-station avatar Jul 20 '22 17:07 play-station

I can confirm that above-mentioned solution works, thank you for help and discussion!

Latropos avatar Oct 23 '23 07:10 Latropos

@Latropos the problem still continue in RN V 0.72.6 with the following libraries

    "react-native-reanimated": "3.5.4",
    "react-native-screens": "3.27.0",
    "react-native-safe-area-context": "4.7.4",
Screenshot 2023-10-27 at 00 24 22

pedrogoiania avatar Oct 27 '23 04:10 pedrogoiania

Facing kind of same issue Undefined symbols for architecture arm64:

"facebook::hermes::inspector_modern::chrome::enableDebugging(std::__1::unique_ptr<facebook::hermes::inspector_modern::RuntimeAdapter, std::__1::default_delete<facebook::hermes::inspector_modern::RuntimeAdapter>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)", referenced from:
    reanimated::ReanimatedHermesRuntime::ReanimatedHermesRuntime(std::__1::unique_ptr<facebook::hermes::HermesRuntime, std::__1::default_delete<facebook::hermes::HermesRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in libRNReanimated.a(ReanimatedHermesRuntime.o)
"facebook::hermes::inspector_modern::chrome::disableDebugging(int)", referenced from:
    reanimated::ReanimatedHermesRuntime::~ReanimatedHermesRuntime() in libRNReanimated.a(ReanimatedHermesRuntime.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
    "react-native-safe-area-context": "^4.8.2",
    "react-native-screens": "^3.29.0",
    "react-native": "0.73.1",
    "react-native-reanimated": "^3.6.1",

SohelKabir avatar Jan 05 '24 08:01 SohelKabir

Facing kind of same issue Undefined symbols for architecture arm64:

"facebook::hermes::inspector_modern::chrome::enableDebugging(std::__1::unique_ptr<facebook::hermes::inspector_modern::RuntimeAdapter, std::__1::default_delete<facebook::hermes::inspector_modern::RuntimeAdapter>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)", referenced from:
    reanimated::ReanimatedHermesRuntime::ReanimatedHermesRuntime(std::__1::unique_ptr<facebook::hermes::HermesRuntime, std::__1::default_delete<facebook::hermes::HermesRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in libRNReanimated.a(ReanimatedHermesRuntime.o)
"facebook::hermes::inspector_modern::chrome::disableDebugging(int)", referenced from:
    reanimated::ReanimatedHermesRuntime::~ReanimatedHermesRuntime() in libRNReanimated.a(ReanimatedHermesRuntime.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
    "react-native-safe-area-context": "^4.8.2",
    "react-native-screens": "^3.29.0",
    "react-native": "0.73.1",
    "react-native-reanimated": "^3.6.1",

solved the issue by removing use_frameworks! :linkage => :static from pod file, which i added to support another library.

SohelKabir avatar Jan 05 '24 09:01 SohelKabir

I had this issue after updating react-native from 0.68 to 0.73. For me, the fix was in adding the next lines in the Podfile:

pre_install do |installer|
      installer.pod_targets.each do |pod|
        if pod.name.eql?('RNScreens')
          def pod.build_type
            Pod::BuildType.static_library
          end
        end
//     ==== add this =>
        if pod.name.eql?('RNReanimated')
          def pod.build_type
            Pod::BuildType.static_library
          end
        end
//       <= end of add this ====
        end
      end
    end

Hope it will help someone.

SandraBLOK avatar Mar 11 '24 14:03 SandraBLOK

Hey! Same error with

"react-native-reanimated": "^3.9.0",
"react-native-screens": "^3.31.1",
Undefined symbols for architecture arm64:
  "facebook::hermes::inspector_modern::chrome::enableDebugging(std::__1::unique_ptr<facebook::hermes::inspector_modern::RuntimeAdapter, std::__1::default_delete<facebook::hermes::inspector_modern::RuntimeAdapter>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)", referenced from:
      reanimated::ReanimatedHermesRuntime::ReanimatedHermesRuntime(std::__1::unique_ptr<facebook::hermes::HermesRuntime, std::__1::default_delete<facebook::hermes::HermesRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in libRNReanimated-tvOS.a[29](ReanimatedHermesRuntime.o)
  "facebook::hermes::inspector_modern::chrome::disableDebugging(int)", referenced from:
      reanimated::ReanimatedHermesRuntime::~ReanimatedHermesRuntime() in libRNReanimated-tvOS.a[29](ReanimatedHermesRuntime.o)
ld: symbol(s) not found for architecture arm64

The solution provided by @SandraBLOK doesn't work anymore..

This is my Podfile

source 'https://github.com/react-native-tvos/react-native-tvos-podspecs.git'
source 'https://cdn.cocoapods.org/'

# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

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

target 'UFairTV' do
  config = use_native_modules!
  platform :ios, min_ios_version_supported

  # 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],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'UFairTVTests' do
    inherit! :complete
    # Pods for testing
  end

end

target 'UFairTV-tvOS' do
  config = use_native_modules!
  platform :tvos, min_ios_version_supported

  # 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],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'UFairTV-tvOSTests' do
    inherit! :complete
    # Pods for testing
  end

end

pre_install do |installer|
  installer.pod_targets.each do |pod|
    # if pod.name.eql?('RNScreens')
    #   def pod.build_type
    #     Pod::BuildType.static_library
    #   end
    # end
    if pod.name.eql?('RNReanimated')
      def pod.build_type
        Pod::BuildType.static_library
      end
    end
  end
end

post_install do |installer|
  config = use_native_modules!
  # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
  react_native_post_install(
    installer,
    config[:reactNativePath],
    :mac_catalyst_enabled => false
  )
  # __apply_Xcode_12_5_M1_post_install_workaround(installer)
end

Any help? Thanks a lot!

mrigo avatar Apr 30 '24 15:04 mrigo