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

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
  • iOS
  • Web

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 21 (3 by maintainers)

Most upvoted comments

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 😄 Now im able to build both android and iOS and debug remotely works again on android !

Hope it can help you 😃

@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

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.

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

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

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.

@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

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.

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