Tealium / tealium-react-native

Other
13 stars 26 forks source link

ERROR: Undefined symbols for architecture arm64: "_OBJC_CLASS_$_TealiumReactNative" #165

Open Fedd9 opened 9 months ago

Fedd9 commented 9 months ago

Hello everyone, we're having a problem related to a RN migration from v0.63 to v0.73: while upgrading all the libraries and used frameworks, we've encountered this error:

Undefined symbols for architecture arm64: "_OBJCCLASS$_TealiumReactNative", referenced from: objc-class-ref in libtealium-react-native.a(TealiumReactNative.o) _OBJC$_CATEGORYTealiumReactNative$_RCTExternModule in libtealium-react-native.a(TealiumReactNative.o) "_OBJCCLASS$_TealiumWrapper", referenced from: objc-class-ref in libtealium-react-native.a(TealiumReactNative.o) _OBJC$_CATEGORYTealiumWrapper$_RCTExternModule in libtealium-react-native.a(TealiumReactNative.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Now, considering everything, we managed to understand a solution related ([https://github.com/Tealium/tealium-react-native/issues/129]) but this is not working for us.

pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

    installer.pod_targets.each do |pod|
      if pod.name.start_with?('tealium-react-native')
        def pod.build_type;
          Pod::BuildType.static_library # >= 1.9
        end
      end
    end
  end

We can't use use_frameworks! :linkage => :static because it is not compatible with Flipper. For reference, I'm also attaching the podfile.

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

platform :ios, '13.4'
prepare_react_native_project!
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
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

permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"

target 'Memi_PROD' do 
  $config = use_native_modules!
  flags = get_default_flags()
  pod 'Realm', '~>10', :modular_headers => true
  pod 'RealmSwift', '~>10', :modular_headers => true
  pod 'AEPCore', '~> 3.0'
  pod 'AEPLifecycle', '~> 3.0'
  pod 'AEPIdentity', '~> 3.0'
  pod 'AEPSignal', '~> 3.0'
  pod 'AEPUserProfile', '~> 3.0'

  use_react_native!(
    :path => $config[:reactNativePath],
    :flipper_configuration => flipper_config,
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
end

target 'Memi_PRE' do 
  $config = use_native_modules!
  flags = get_default_flags()
  pod 'Realm', '~>10', :modular_headers => true
  pod 'RealmSwift', '~>10', :modular_headers => true
  pod 'AEPCore', '~> 3.0'
  pod 'AEPLifecycle', '~> 3.0'
  pod 'AEPIdentity', '~> 3.0'
  pod 'AEPSignal', '~> 3.0'
  pod 'AEPUserProfile', '~> 3.0'

  use_react_native!(
    :path => $config[:reactNativePath],
    :flipper_configuration => flipper_config,
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
end

target 'Memi_MOCKOON' do
  $config = use_native_modules!
  flags = get_default_flags()
  pod 'Realm', '~>10', :modular_headers => true
  pod 'RealmSwift', '~>10', :modular_headers => true
  pod 'AEPCore', '~> 3.0'
  pod 'AEPLifecycle', '~> 3.0'
  pod 'AEPIdentity', '~> 3.0'
  pod 'AEPSignal', '~> 3.0'
  pod 'AEPUserProfile', '~> 3.0'

  use_react_native!(
    :path => $config[:reactNativePath],
    :flipper_configuration => flipper_config,
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
end

pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

    installer.pod_targets.each do |pod|
      if pod.name.start_with?('tealium-react-native')
        def pod.static_framework?;
          true
        end
        def pod.build_type;
          Pod::BuildType.static_library # >= 1.9
        end
      end
    end
  end

post_install do |installer|
  react_native_post_install(
    installer,
    :mac_catalyst_enabled => false
  )

  installer.pods_project.targets.each do |t|
    if t.name.start_with?("AEP")
      t.build_configurations.each do |bc|
          bc.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -no-verify-emitted-module-interface'
      end
    end
  end
end

Hope you can help me

craigrouse commented 9 months ago

@Fedd9 sorry for the delayed reply. We are looking into this for you.

trne commented 5 months ago

is there any update on this?

Enricoza commented 1 month ago

It looks like this issue was missed, sorry about that. @Fedd9 and @trne were you able to resolve it?

By having a look at your Podfile it seems that you are missing a line:

  pod "tealium-react-native-swift", :path => '../node_modules/tealium-react-native/tealium-react-native-swift.podspec'

That is necessary starting from tealium-react-native 2.2.0 onwards as written in the documentation here.

Let us know if you are still facing the issue and sorry again for missing this.