Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_FlipperKitNetworkPlugin" etc. for iOS production #90

Closed
emersonhsieh opened this issue Jul 22, 2020 · 13 comments
Labels

Comments

@emersonhsieh
Copy link

emersonhsieh commented Jul 22, 2020

Environment

System:
    OS: macOS 10.15.3
    CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
    Memory: 49.42 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.2.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.14.4 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.8.4 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 26, 28, 29
      Build Tools: 26.0.2, 28.0.3, 29.0.1, 29.0.2
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4/11E146 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_212 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: 3.1.0 => 3.1.0 
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.1 => 0.63.1 
  npmGlobalPackages:
    *react-native*: Not Found

Upgrading version

0.63.2

Description

I upgraded from React Native 0.62.2 to 0.63.1 manually using the upgrade helper, because the automatic helper wasn't working. The application builds successfully in Debug (Product -> Scheme -> Build Configuration -> Debug), but fails for the Release build configuration with the following error:

image

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_FlipperKitNetworkPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_SKIOSNetworkAdapter", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FlipperKitReactPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FKUserDefaultsPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FlipperKitLayoutPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_SKDescriptorMapper", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FlipperClient", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reproducible demo

AppDelegate.m.txt
Podfile.txt

Attached is my Podfile and AppDelegate.m (added txt so that it would upload to Github). Looking at the upgrade helper, I should mention that I have the following in AppDelegate.m. I also tried commenting out the #ifdef FB_SONARKIT_ENABLED and #endif but it still failed.

#ifdef FB_SONARKIT_ENABLED
#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

and in didFinishLaunchingWithOptions:

  #ifdef FB_SONARKIT_ENABLED
    InitializeFlipper(application);
  #endif

In the Podfile, the only differences from the sample are the app name, OneSignal extension, and expo unimodules. Thanks for the help in advance!

@emersonhsieh emersonhsieh changed the title Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_FlipperKitNetworkPlugin" etc. Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_FlipperKitNetworkPlugin" etc. on iOS Jul 22, 2020
@emersonhsieh emersonhsieh changed the title Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_FlipperKitNetworkPlugin" etc. on iOS Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_FlipperKitNetworkPlugin" etc. for iOS production Jul 22, 2020
@emersonhsieh
Copy link
Author

emersonhsieh commented Jul 22, 2020

I've tried everything in #30 (comment) and facebook/flipper#816 (comment). Because add_flipper_pods was moved to within the react native package, I did not modify that. I also followed #13 when upgrading to 0.62.2 from 0.61.1, including re-adding the bridging header. However, I'm still getting this error.

@emersonhsieh
Copy link
Author

Update: same issue persists after upgrading to react native 0.63.2

@curiousdustin
Copy link

I had the same errors in my app after upgrading from RN 0.62.2 to 0.63.2.

I was able to get my app to build for release by removing this line from Build Settings > Other C Flags > Release

-DFB_SONARKIT_ENABLED=1

I have no idea if this is a proper way to fix this or not. Can anyone confirm?

@github-actions github-actions bot added 0.63.2 and removed 0.63.1 labels Jul 23, 2020
@emersonhsieh
Copy link
Author

@curiousdustin I can confirm that it worked! Now I'm getting another error (#87) which seems unrelated to this issue.

@emersonhsieh
Copy link
Author

@curiousdustin Also, after checking the project.pbxproj of the sample app, there isn't the -DFB_SONARKIT_ENABLED=1 anywhere in the file. Therefore, I believe your fix is the correct one.

@Taylor123
Copy link

setting -DFB_SONARKIT_ENABLED=1 shouldn't be a proper fix for this since Flipper shouldn't be enabled in release builds. With that said, i'm facing the same issue at the moment, so i'm looking for a better fix

@GoktuqCan
Copy link

Having the same issue as well. I'm upgrading from 0.62.2 to 0.63.2.

@emersonhsieh
Copy link
Author

@Taylor123 the fix for me was to remove instead of adding the -DFB_SONARKIT_ENABLED=1 flag for release/production builds. I originally added the line when upgrading to react native 0.62.2 due to facebook/react-native#28406 (comment).

@Taylor123
Copy link

@emersonhsieh Yea i saw my project had the same flag enabled!

@wmcbain
Copy link

wmcbain commented Aug 7, 2020

Removing the flag worked for me as well. Thanks @curiousdustin

@anshul-kai
Copy link

@curiousdustin Thanks for sharing this. I'm not smart enough to say if this is definitely the correct fix but it makes a lot of sense and seems pretty safe as Flipper is supposed to be enabled only in DEBUG mode and removing this flag would disable the code inside #if FB_SONARKIT_ENABLED.

@compojoom
Copy link

I updated from RN 0.62 to 0.64 and ran into the same issue. However I'm not sure this is correct. I don't know how this -DFB_SONARKIT_ENABLED=1 gets added, but I think it is during the pod install step.

I followed the instruction in the react upgrade helper and it says to add flipper with on #if FB_SNOARKIT_ENABLED, however if you look at the official flipper docks over here:
https://fbflipper.com/docs/getting-started/react-native-ios/

The have this code:

...
#if DEBUG
#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitLayoutPlugin/SKDescriptorMapper.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#endif
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [self initializeFlipper:application];
  ...
}

- (void) initializeFlipper:(UIApplication *)application {
  #if DEBUG
  #ifdef FB_SONARKIT_ENABLED
    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
  #endif
}

@end

So I'm starting to think that the upgrade instructions are wrong and one needs the ´#if DEBUG` flag as well.

@ghost
Copy link

ghost commented Mar 8, 2022

This solves the problem om my M1:
facebook/react-native#28419 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants