zoontek / react-native-dev-menu

Add custom items to the React Native dev menu.
MIT License
204 stars 25 forks source link

Undefined symbols for architecture arm64 on RN 0.62.2 #17

Open Almouro opened 4 years ago

Almouro commented 4 years ago

Hello!

Describe your environment

Also note the project uses use_frameworks!

How to repeat issue and example

Upgrading to RN 0.62.2 broke the build with this error:

Undefined symbols for architecture arm64
> Symbol: _OBJC_CLASS_$_RCTDevMenuItem
> Referenced from: objc-class-ref in RNDevMenu.o

I tried already:

Not really a solution

The weird part is if I symlink RNDevMenu.h and RNDevMenu.m in the project and make sure it's not installed as a Pod, then it works

Let me know if you need any additional details!

zoontek commented 4 years ago

Hello!

This is related to use_frameworks usage (which is broken by design). A simple solution is to add this in your Podfile:

use_frameworks!

# Set every dep you want to build as static libraries here
$static_libs = ['RNDevMenu']

pre_install do |installer|
  installer.pod_targets.each do |pod|
    if $static_libs.include?(pod.name)
      puts "Flag #{pod.name} as static_library"
      def pod.build_type;
        # Uncomment one line depending on your CocoaPods version
        # Pod::BuildType.static_library # >= 1.9
        # Pod::Target::BuildType.static_library # < 1.9
      end
    end
  end
end

It's a workaround, but until CocoaPods 2.0 I'm afraid we have no choice.