react-native iOS new scheme error: Undefined symbol: _OBJC_CLASS_$_FlipperClient
Asked Answered
N

8

15

I added a new build configuration, Dev.Debug to my react-native project in xcode, duplicating the existing Debug configuration, and also added a corresponding scheme for the new configuration.

Now when I attempt to run the project with the new scheme I get the error:

Undefined symbol: _OBJC_CLASS_$_FlipperClient

Running the scheme that I duplicated works fine - the app installs, launches, and functions normally.

Is there any more configuration required after adding a new debug scheme?

Necessitarianism answered 6/1, 2022 at 15:53 Comment(0)
N
8

I found that I needed to modify my podfile as follows:

...

target 'MyApp' do
  config = use_native_modules!
  
  # Add the project and build configurations
  project 'MyApp',
    'Dev.Debug' => :debug, # '{Build Configuration name}' => :{debug or release}
    'Debug' => :debug,
    'Dev.Release' => :release,
    'Release' => :release
...

use_flipper!({'Flipper' => '0.126.0', configurations: ['Debug', 'Dev.Debug']}) # Add the Build Configuration name (not scheme name)

...
Necessitarianism answered 6/1, 2022 at 15:53 Comment(1)
8 hours of searching and this is what solved it for me. Thanks! I ended up not declaring the flipper versions in the end, so it looked like this for me: use_flipper!({ configurations: ['Debug', 'Dev.Debug'] })Arty
P
6

In my case I updated to react native: 0.70.* and Flipper to version 174 and had this error. Downgrading Flipper to 163 fixed the issue for me.

More info here: https://github.com/facebook/flipper/issues/4278

Pizzeria answered 18/11, 2022 at 10:43 Comment(0)
G
2

In recent versions of React Native, AppDelegate.mm has replaced the legacy Flipper initialisation code with RCTAppSetupPrepareApp(application); and I had forgotten to do so. This caused the issue for me. Fixing it solved the issue. See https://react-native-community.github.io/upgrade-helper/ for the diffs.

Grodno answered 13/1, 2023 at 5:54 Comment(0)
A
1

i downgraded from:

-    "react-native-flipper": "^0.212.0",
+    "react-native-flipper": "^0.164.0",

now both debug and archive work for me

Arsenate answered 25/10, 2023 at 16:33 Comment(0)
C
1

For react-native 0.72, you should re-install your pods with

PRODUCTION=1 bundle exec pod install

To remove Flipper from the Release build. Flipper can't be built in Release mode, Flipper is going to be deprecated in 0.73 and it will be removed in 0.74.

Big thanks to cipolleschi

Chantay answered 5/2 at 1:44 Comment(0)
A
0

In my case, this was solved by installing the proper version of the react-native-flipper npm package.

I could see in the Podfile.lock and gradle.properties the binary Flipper version was 0.125.0 so I did a yarn add [email protected] instead of the default version, and now I can build again :)

Artur answered 26/9, 2023 at 14:19 Comment(1)
can simply disabling flipper work ? I got this error when I used react-native-svg a little older versionGerminal
F
0

Undefined symbol: OBJC_CLASS$_FlipperClient Linker command failed with exit code 1 (use -v to see invocation)

This is an error that caused some confusion and many answers that partially solve the issue but none of them address the issues in a coherent way.

WHAT CAUSES THE ERROR:

In release builds it is caused by trying to line to react-native-flipper library that is not provided for linking yet required in installer.generated_aggregate_target.xcconfigs

You can find these files in Targets Support Files > Pods-yourAppName in Xcode. You can find it under OTHER_LDFLAGS with value -l"react-native-flipper"

In my opinion this is an oversight on behalf of the react-native-flipper team.

Most likely in your build output log you will find something like this.:

Undefined symbols for architecture arm64: "OBJC_CLASS$_FlipperClient", referenced from: in libreact-native-flipper.a4 ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

If you inspect FlipperReactNativeJavaScriptPluginManager file you will see that it is trying to:

#import <FlipperKit/FlipperClient.h>

And since there is no library to be linked the linker fails and the whole build fails.

YOU MIGHT ALREADY TRIED THIS SOLUTIONS:

use_flipper!(['Debug'])

use_flipper!({'Flipper' => '0.126.0', configurations: ['Debug', 'Dev.Debug']})

:flipper_configuration => FlipperConfiguration.enabled(["Debug"]),
PRODUCTION=1 bundle exec pod install

They might have worked but they are very dependant on the version of react-native-flipper that you use.

use_flipper! - deprecated in newer versions, FlipperConfiguration.enabled(["Debug"]) - this will not work in older versions.

PRODUCTION=1 - env variable is not always available in your build,

As you can see here the PRODUCTION=1 is available only since this commit: https://github.com/facebook/flipper/commit/0c442bf4b186859a0262ef259ba70d4996da3f3f

YET FOR OLDER VERSIONS IT WILL CONTINUE INCLUDES

But still the pods require other pods: https://github.com/facebook/flipper/commit/44f5e35675f7198d720cc5075ec1f822e110d669#diff-ca0a0286a67452f62d0a79751348c6688482fbce1e93212428494f071904eda1

And going from FlipperKit.podspec https://github.com/facebook/flipper/blob/main/iOS/Podfile

Which will include Flipper.podspect https://github.com/facebook/flipper/blob/main/Flipper.podspec

And along the way one of them is going to add that pesky ld flag again.

HOW TO SOLVE THIS ISSUE: If you are running the newest version of react-native-flipper and have access to build env variables all you have to do is pass

PRODUCTION=1 bundle exec pod install

flag and following this commit it will work.

https://github.com/facebook/flipper/commit/0c442bf4b186859a0262ef259ba70d4996da3f3f

If you are not so lucky and have to run older version of react-native-flipper you have to delete the linker flag from your release pods

Targets Support Files > Pods-yourAppName You can do it manually just to try out if your build will produce an archive for TestFlight or release

Or add a post install function that will remove the undesired linker flag.

def flipper_remove(generated_aggregate_target, config_name, config_file)
    xcconfig_path = generated_aggregate_target.xcconfig_path(config_name)
    if File.exist?(xcconfig_path)
      puts "FLIPPER: Found xcconfig file: #{File.basename(xcconfig_path)}"
      xcconfig_content = File.read(xcconfig_path)
      modified_content = xcconfig_content.gsub('-l"react-native-flipper"', '')
      File.open(xcconfig_path, 'w') { |file| file.write(modified_content) }
    else
      puts "FLIPPER: xcconfig file does not exist: #{File.basename(xcconfig_path)}"
    end
end

post_install do |installer|
    installer.generated_aggregate_targets.each do |generated_aggregate_target|
        generated_aggregate_target.xcconfigs.each do |config_name, config_file|
            next unless config_name == 'Release'
            flipper_remove(generated_aggregate_target, config_name, config_file)
        end
    end
end
Feral answered 2/8 at 18:37 Comment(0)
T
-3

Change XCode Build Configuration from Release => Debug fix this error for me

Treytri answered 13/11, 2023 at 3:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.