react-native: Undefined symbol on Flipper using 0.62 on real iOS device

Description

I’m not able to run the 0.62 version of the react native when I target a real device on the XCode. Using the simulator is running normally. I’ve got this error:

Undefined symbol: FlipperState::start(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
Undefined symbol: folly::ScopedEventBaseThread::ScopedEventBaseThread()
Undefined symbol: facebook::flipper::FlipperClient::instance()
Undefined symbol: folly::ScopedEventBaseThread::~ScopedEventBaseThread()
Undefined symbol: facebook::flipper::FlipperClient::getStateElements()
Undefined symbol: facebook::flipper::FlipperClient::getState()
Undefined symbol: facebook::flipper::FlipperClient::getPlugin(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Undefined symbol: facebook::flipper::FlipperClient::setStateListener(std::__1::shared_ptr<FlipperStateUpdateListener>)
Undefined symbol: FlipperStep::complete()
Undefined symbol: facebook::flipper::FlipperClient::performAndReportError(std::__1::function<void ()> const&)
Undefined symbol: facebook::flipper::FlipperClient::init(facebook::flipper::FlipperInitConfig)
Undefined symbol: facebook::flipper::FlipperClient::removePlugin(std::__1::shared_ptr<facebook::flipper::FlipperPlugin>)
Undefined symbol: facebook::flipper::FlipperClient::addPlugin(std::__1::shared_ptr<facebook::flipper::FlipperPlugin>)
Undefined symbol: facebook::flipper::FlipperClient::refreshPlugins()

React Native version:

System: OS: macOS 10.15.3 CPU: (8) x64 Intel® Core™ i7-2600 CPU @ 3.40GHz Memory: 1.23 GB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 13.11.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.13.7 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2 Android SDK: Not Found IDEs: Android Studio: 3.6 AI-192.7142.36.36.6241897 Xcode: 11.4/11E146 - /usr/bin/xcodebuild Languages: Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.11.0 => 16.11.0 react-native: 0.62.0 => 0.62.0 npmGlobalPackages: react-native: Not Found

Steps To Reproduce

  1. Created a new project with react-native init
  2. Added a team on the XCode
  3. Opened the Flipper application
  4. Build using a real iPad as target device

Expected Results

Expected to run like on the simulator

Snack, code example, screenshot, or link to a repository:

image

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 24
  • Comments: 27 (3 by maintainers)

Most upvoted comments

As explained by @charway opening the Pods.xcproj project within the workspace, selecting each of the Flipper* targets, and editing the “Valid Architectures” to remove armv7 and armv7s stops Xcode trying to build all the Flipper pods for actual devices. This gets overwritten every time pod install is run, however, so instead adding the following to the flipper_post_install section of the Podfile will apply that change automatically on every install:

# Post Install processing for Flipper
def flipper_post_install(installer)
  installer.pods_project.targets.each do |target|
    if target.name == 'YogaKit'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.1'
      end
    end

    # Enable Flipper for simulators only
    if target.name.start_with?('Flipper')
      target.build_configurations.each do |config|
        config.build_settings['VALID_ARCHS'] = 'arm64 arm64e'
      end
    end
  end
end

Then since it’s no longer being built for those architectures, to stop importing/applying Flipper on actual devices edit your app’s AppDelegate.m file, replacing the #if DEBUG macros with #if DEBUG && TARGET_OS_SIMULATOR as below:

// ...

#if DEBUG && TARGET_OS_SIMULATOR
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>

static void InitializeFlipper(UIApplication *application) {
  FlipperClient *client = [FlipperClient sharedClient];
  SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
  [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
  [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
  [client addPlugin:[FlipperKitReactPlugin new]];
  [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
  [client start];
}
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if DEBUG && TARGET_OS_SIMULATOR
  InitializeFlipper(application);
#endif

// ...

The app should now build successfully for actual devices again (the log will show all the Flipper components were skipped).

im starting to move to flutter because react native start to contain so many issue with no fixed

if you use react-native-flipper, then you can solve it like this (disable auto-linking for ios react-native-flipper, linking manually for debugging only)

./react-native.config.js

module.exports = {
    dependencies: {
        'react-native-flipper': {
            platforms: {
                ios: null,
            },
        },
    },
};

./ios/Podfile

def add_flipper_pods!(versions = {})
  ...
  
  pod 'react-native-flipper', :path => '../node_modules/react-native-flipper', :configuration => 'Debug'
end

rm -rf ios/Pods/; cd ios; pod install; cd ..

@AndrewMorsillo @SaveYourTime can you plz check the solution here ? facebook/flipper#976

Thank for the suggestion. Finally, I fixed it and successfully build and run with Xcode. 😄

For anyone who is facing the same issue with the react native version v0.62.0 or v0.62.1. Check this out!

  1. Following the upgrade helper to upgrade your project to react native v0.62.2
  2. Checking your dependencies

If you don’t have react-native-flipper and flipper-plugin-rn-redux-inspector in your dependencies, the issue must be fixed after upgraded.

  1. If you have either react-native-flipper or flipper-plugin-rn-redux-inspector just remove both of them.

npm uninstall react-native-flipper flipper-plugin-rn-redux-inspector

  1. Remove node_modules and Pods
  2. Run npm install (or yarn, if you use yarn) and cd ios && pod install

After trying these steps I still can’t build for generic device in debug configuration.

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_FlipperClient", referenced from:
      objc-class-ref in libreact-native-flipper.a(FlipperReactNativeJavaScriptPluginManager.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Try remove the “armv7” in VALID_ARCHS of Build Settings @jfbaraky

As explained by @charway opening the Pods.xcproj project within the workspace, selecting each of the Flipper* targets, and editing the “Valid Architectures” to remove armv7 and armv7s stops Xcode trying to build all the Flipper pods for actual devices. This gets overwritten every time pod install is run, however, so instead adding the following to the flipper_post_install section of the Podfile will apply that change automatically on every install:

# Post Install processing for Flipper
def flipper_post_install(installer)
  installer.pods_project.targets.each do |target|
    if target.name == 'YogaKit'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.1'
      end
    end

    # Enable Flipper for simulators only
    if target.name.start_with?('Flipper')
      target.build_configurations.each do |config|
        config.build_settings['VALID_ARCHS'] = 'arm64 arm64e'
      end
    end
  end
end

Then since it’s no longer being built for those architectures, to stop importing/applying Flipper on actual devices edit your app’s AppDelegate.m file, replacing the #if DEBUG macros with #if DEBUG && TARGET_OS_SIMULATOR as below:

// ...

#if DEBUG && TARGET_OS_SIMULATOR
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>

static void InitializeFlipper(UIApplication *application) {
  FlipperClient *client = [FlipperClient sharedClient];
  SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
  [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
  [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
  [client addPlugin:[FlipperKitReactPlugin new]];
  [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
  [client start];
}
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if DEBUG && TARGET_OS_SIMULATOR
  InitializeFlipper(application);
#endif

// ...

The app should now build successfully for actual devices again (the log will show all the Flipper components were skipped).

I’m wondering why this is not part of release 0.63.0? Now I have to patch my RN again…

@adamaveray thanks. I’ve build my app under iOS 13.1 succefuly. But build fails for iOS 10.3 with Library not found for “-lFlipper-DoubleConversion”, so I’ve modified flipper pod post install step:

# Post Install processing for Flipper
def flipper_post_install(installer)
  installer.pods_project.targets.each do |target|
    if target.name == 'YogaKit'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.1'
      end
    end

    # Enable Flipper for simulators only
    if target.name.start_with?('Flipper') || target.name == 'Flipper'
      target.build_configurations.each do |config|
        config.build_settings['VALID_ARCHS'] = 'arm64 arm64e'
        config.build_settings['ARCHS'] = '${ARCHS_STANDARD_64_BIT}'
      end
    end
  end

  installer.pods_project.save
end

@AlinDev, In AppDelegate.m the code should look like this, the only thing to replace is ‘#if DEBUG’ with ‘#if DEBUG && TARGET_OS_SIMULATOR’

Example: // …

#if DEBUG && TARGET_OS_SIMULATOR #import <FlipperKit/FlipperClient.h> #import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h> #import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h> #import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h> #import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h> #import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>

static void InitializeFlipper(UIApplication *application) { FlipperClient *client = [FlipperClient sharedClient]; SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; [client addPlugin:[FlipperKitReactPlugin new]]; [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; [client start]; } #endif

@implementation AppDelegate

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { #if DEBUG && TARGET_OS_SIMULATOR InitializeFlipper(application); #endif

// …

And in the podfile, just change the flipper version to: 0.49.1 & DoubleConversion to 1.1.7

I found another solution

In podfile, just make sure that the flipper & DoubleConversion versions are:

versions[‘Flipper’] ||= ‘> 0.49.1’ versions[‘DoubleConversion’] ||= ‘1.1.7’

And in the AppDelegate.m file just add: TARGET_OS_SIMULATOR to the flipper implementation in line 8, and in didFinishLaunchingWithOptions after the ‘#if DEBUG’

thats all, now the app will work on both real devices and simulators.

I have same problem, I update react-native-flipper and update Flipper in pods file to version 0.37.0 and have same problem, with I build Generic Device, but if I replace Generic device by other devices it’s working

image

and build success

image

can someone help me with this problem?

Just in case someone else is having the same problem as me… I was getting this same error simply because I forgot to edit the scheme in Xcode and switch to Release