Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

react-native-flipper 0.171 and up are causing linking errors on iOS Release build #4457

Open
renchap opened this issue Jan 18, 2023 · 28 comments Β· May be fixed by #4485
Open

react-native-flipper 0.171 and up are causing linking errors on iOS Release build #4457

renchap opened this issue Jan 18, 2023 · 28 comments Β· May be fixed by #4485

Comments

@renchap
Copy link

renchap commented Jan 18, 2023

πŸ› Bug Report

Starting with react-native-flipper 0.171, every app using this package will fail to link in Release mode on iOS, with the following error:

Undefined symbols for architecture arm64
❌   "_OBJC_CLASS_$_FlipperClient", referenced from:
⚠️       objc-class-ref in libreact-native-flipper.a(FlipperReactNativeJavaScriptPluginManager.o)
❌ ld: symbol(s) not found for architecture arm64

To Reproduce

  • npx react-native init TestRNProject
  • cd TestRNProject
  • yarn install react-native-flipper
  • cd ios && pod install
  • yarn ios --configuration Release

The build will fail with:

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

Source of the problem

This issue is caused by this commit: f65364c

It does not appear on react-native-flipper 0.164.0` and lower, and started with 0.171.1 (the next released version).

As @as4 commented on the commit, -DFB_SONARKIT_ENABLED is always set in Release mode by flipper.podspec, even if Flipper is not enabled by the app Podfile in this configuration, so react-native-flipper tries to link with FlipperClient, which is not compiled.

The solution could be to not have -DFB_SONARKIT_ENABLED defined if the RN app's Podfile disables Flipper, or to use another constant in react-native-client to check if Flipper is really enabled for this build.

Environment

I tested with with:

  • React Native 0.71.0
  • react-native-flipper 0.177.0
  • macOS 13.1
  • XCode 14.2
@sebastianMagnaldi
Copy link

Hey ! i'm having the exact same issue.

  • React native 0.69.4
  • MacOS 12.4
  • XCode 13
  • react-native-flipper 0.176.1

@adrianso
Copy link

I am having the same issue when trying to compile on x64.
The same app compiles with no linking issues on M1.

@fcaldarelli
Copy link

In my case the problem was different.

Using in Podfile the default flipper configuration:

    :flipper_configuration => FlipperConfiguration.enabled(["Debug"]),

I found that when launched pod install --verbose I saw that the branch version was different, in my case was 1.76.0.1.9. The 1.76.0.1.9 missed asm folder needed to link the code.

In the screen I put the right version.

Screenshot 2023-01-20 alle 10 46 28

To fix, call pod repo list and update the CDN (usually named as trunk) with

pod repo update trunk (if at your side is named trunk)

Launch again pod install --verbose and you will see the same and right version of the Pod.

@sebastianMagnaldi
Copy link

any news on this ?

@rossyman
Copy link

rossyman commented Jan 25, 2023

I believe this is as a result of FlipperKit not being linked during release builds: #976 (comment)

What solved this for me, was following the upgrade guide to 0.71.1 and utilising the NO_FLIPPER environment variable outlined in the community upgrade tool:

  • See their Podfile here (Lines 7 ~ 16 and Line 41)
  • Ensure you also set the recommended JS configuration outlined in the comment above flipper_config in the Podfile
  • Set environment variable NO_FLIPPER = 1 when running your release build

@renchap
Copy link
Author

renchap commented Jan 25, 2023

@rossyman Yes this is a workaround. But the code should check is Flipper will be linked, and make react-native-flipper a no-op when Flipper will not be linked to the build.

@Kudo Kudo linked a pull request Feb 2, 2023 that will close this issue
@erwanlpfr
Copy link

erwanlpfr commented Feb 3, 2023

Hello!

I am also using a M1 to build my app.
But this error appears only when I am building for a real device in debug mode.
So, for my CI it works but once I want to test on real device it fails.

react-native : 0.71.2
mac M1
XCode 14.2

Does it come from Flipper or from our React Native config?

Thanks!

@TheWirv
Copy link

TheWirv commented Feb 14, 2023

This is a duplicate to #4278 :( It would be great if this would get fixed at some point so that we can upgrade to the most recent versions.

@lucaswitch
Copy link

Downgrade flipper to version 0.164.0 on IOS, this solves the issue.

@archcorsair
Copy link

archcorsair commented Apr 11, 2023

I believe this is as a result of FlipperKit not being linked during release builds: #976 (comment)

What solved this for me, was following the upgrade guide to 0.71.1 and utilising the NO_FLIPPER environment variable outlined in the community upgrade tool:

  • See their Podfile here (Lines 7 ~ 16 and Line 41)
  • Ensure you also set the recommended JS configuration outlined in the comment above flipper_config in the Podfile
  • Set environment variable NO_FLIPPER = 1 when running your release build

@rossyman
I tried this exactly as recommended, did not work for me. 😞
Downgrading flipper to 0.163.0 or 0.164.0 did not work either

@fukemy
Copy link

fukemy commented May 25, 2023

any solution now??
Set environment variable NO_FLIPPER = 1 when running your release build

Where to set NO_FLIPPER = 1?

@ehynds
Copy link

ehynds commented May 25, 2023

Where to set NO_FLIPPER = 1?

From your ios directory, run NO_FLIPPER=1 pod install then try archiving

@httol
Copy link

httol commented Jun 2, 2023

Where to set NO_FLIPPER = 1?

From your ios directory, run NO_FLIPPER=1 pod install then try archiving

That mean every time after archiving, i need to excute pod install to restore the flipper. And archiving should do NO_FLIPPER=1 pod install, Right?

@MCervenka
Copy link

NO_FLIPPER=1 pod install leads to another error

@eumentis-pawan
Copy link

This worked from me:

PRODUCTION=1 pod install

@Danushka50
Copy link

Danushka50 commented Jul 26, 2023

This worked from me:

PRODUCTION=1 pod install

Works for me. I used,

PRODUCTION=1 arch -x86_64 pod install

But it removes Flipper and cannot build in to a device directly.

Log

`Ignoring digest-crc-0.6.4 because its extensions are not built. Try: gem pristine digest-crc --version 0.6.4
Ignoring unf_ext-0.0.8 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.8
react-native-flipper: Found PRODUCTION=1, react-native-flipper will be disabled for production builds
Auto-linking React Native modules for target '**': CodePush, RNCAsyncStorage, RNCMaskedView, RNCPicker, RNDateTimePicker, RNDeviceInfo, RNGestureHandler, RNImageCropPicker, RNKeychain, RNLocalize, RNPermissions, RNReanimated, RNSVG, RNScreens, RNSketchCanvas, RNVectorIcons, appcenter-core, appcenter-crashes, pushwoosh-react-native-plugin, react-native-app-auth, react-native-background-upload, react-native-blob-util, react-native-camera, react-native-config, react-native-flipper, react-native-geolocation-service, react-native-heic-converter, react-native-maps, react-native-netinfo, react-native-orientation-locker, react-native-pdf, react-native-safe-area-context, and react-native-webview
Framework build type is static library
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
Analyzing dependencies
[Codegen] Found FBReactNativeSpec
react-native-flipper: Found PRODUCTION=1, react-native-flipper will be disabled for production builds
Downloading dependencies
Installing react-native-flipper 0.190.0
Removing CocoaAsyncSocket
Removing Flipper
Removing Flipper-Boost-iOSX
Removing Flipper-DoubleConversion
Removing Flipper-Fmt
Removing Flipper-Folly
Removing Flipper-Glog
Removing Flipper-PeerTalk
Removing Flipper-RSocket
Removing FlipperKit
Removing OpenSSL-Universal
Removing SocketRocket
Removing YogaKit
Removing libevent
Generating Pods project
Setting REACT_NATIVE build settings
Setting CLANG_CXX_LANGUAGE_STANDARD to c++17 on /
///ios/*******.xcodeproj
Pod install took 52 [s] to run
Integrating client project
Pod installation complete! There are 75 dependencies from the Podfile and 86 total pods installed.

[!] Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).

[!] - Emulated x86_64 is slower than native arm64

[!] - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter)

[!] Run "env /usr/bin/arch -arm64 /bin/bash --login" then try again.

[!] Your project does not explicitly specify the CocoaPods master specs repo. Since CDN is now used as the default, you may safely remove it from your repos directory via 'pod repo remove master'. To suppress this warning please add 'warn_for_unused_master_specs_repo => false' to your Podfile.`

@Danushka50
Copy link

Danushka50 commented Jul 28, 2023

#4627 (comment)

I have fixed the error 'Undefined symbol: OBJC_CLASS$_FlipperClient ...' by adding 'Release' to FlipperConfiguration:
:flipper_configuration => flipper_config = FlipperConfiguration.enabled(["Release","Debug"], { 'Flipper' => '0.191.1' })

When it comes to product flavours:
flipper_config = FlipperConfiguration.enabled(["Beta.Debug", "Production.Debug", "Staging.Debug", "Beta.Release", "Production.Release", "Staging.Release"], { 'Flipper' => '0.191.1' })

This this will help and works fro me.

@ark-app-admin
Copy link

#4627 (comment)

I have fixed the error 'Undefined symbol: OBJC_CLASS$_FlipperClient ...' by adding 'Release' to FlipperConfiguration: :flipper_configuration => flipper_config = FlipperConfiguration.enabled(["Release","Debug"], { 'Flipper' => '0.191.1' })

When it comes to product flavours: flipper_config = FlipperConfiguration.enabled(["Beta.Debug", "Production.Debug", "Staging.Debug", "Beta.Release", "Production.Release", "Staging.Release"], { 'Flipper' => '0.191.1' })

This this will help and works fro me.

This isn't a solution, enabling Flipper in your release builds is frowned upon and unnecessary bloat.

@SerhiyZheliznjak
Copy link

SerhiyZheliznjak commented Sep 25, 2023

I think, I have figured out the setup to support latest installable flipper v0.203.0 + react-native-flipper

  1. Setup scripts for switching between dev and prod environment in a way that when you switch to dev it will install pods as usual, but when you switch to prod it will install pods with NO_FLIPPER=1, basically uninstalling flipper.

  2. Almost all files in path node_modules/react-native-flipper/ios (except node_modules/react-native-flipper/ios/FlipperModule.h) are wrapped with

 #if defined(DEBUG) || defined(FB_SONARKIT_ENABLED)

changing it to

 #if DEBUG || FB_SONARKIT_ENABLED

does the trick, I also wrapped the only file that didn't have this node_modules/react-native-flipper/ios/FlipperModule.h for just in case.

I'm not 100% sure on what's going on, but my guess is that during prod build, DEBUG variable gets defined to 0 or false so defined(DEBUG) is always truthy.

  1. My react-native.config.js looks like this:
module.exports = {
  assets: ['./assets/fonts'],
  ...(process.env.NO_FLIPPER
    ? { 'react-native-flipper': { platforms: { ios: null } } }
    : {}),
};

@truongqt
Copy link

truongqt commented Oct 3, 2023

This worked from me: install flipper to devDependencies, not dependencies.
yarn add -D react-native-flipper
And in podfile:
:flipper_configuration => FlipperConfiguration.enabled(["Debug"], { 'Flipper' => '0.163.0' }),

@natemartins
Copy link

After setting up different product flavors and relaunching the app, Flipper client shuts down the bridge thereby disconnecting Metro. This happens everytime I launch the app with Flipper client open or if I open flipper client after launching the app.

Any suggestions on how to use Flipper client for debugging while still maintaining the different product flavors?

NOTE: This is for the Android app. I have not tested this on the iOS but I'm guessing it'll be the same behaviour.

@hpelitebook745G2
Copy link

hpelitebook745G2 commented Oct 19, 2023

what I did was to run:

  1. cd ios
  2. pod deintegrate
  3. rm Podfile.lock
  4. pod install

i'm using Flipper v0.228.0

@dengcqw
Copy link

dengcqw commented Oct 24, 2023

use "export PRODUCTION='1'", before pod install. fix this. because react-native-flipper.podspec contains below code

      if ENV['PRODUCTION'] == '1'
        Pod::UI.puts "#{s.name}: Found PRODUCTION=1, #{s.name} will be disabled for production builds"
      else
        s.compiler_flags = compiler_flags
      end

@justaso
Copy link

justaso commented Nov 4, 2023

Couldn't get it to work using the latest react-native-flipper version, so what I did to enable local Realm debugging was along the lines of what @truongqt suggested above, with slight differences, i.e.:

  • add react-native-flipper as a dev dependency with version 0.163.0
  • Set this line in Podfile as such -> :flipper_configuration => FlipperConfiguration.enabled(["Debug"], { 'Flipper' => '0.163.0' }),
  • run npx pod-install in project root
  • run my project on iOS simulator

Hope this helps.

@jcontreras28
Copy link

jcontreras28 commented Nov 5, 2023

@justaso Did you do anything besides making flipper a dev dependency and adding that podfile line of :flipper_configuration => FlipperConfiguration.enabled(["Debug"], { 'Flipper' => '0.163.0' }), ? I am so completely stuck on this. I did those two things and I get flpper errors still.

CompileC /Users/janellecontreras/Library/Developer/Xcode/DerivedData/Drinklink-cfdtiroygagvlpgyqcuvcqhhxcyc/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FlipperKit.build/Objects-normal/arm64/UIView+SKInvalidation.o /Users/janellecontreras/DrinkLink/Drinklink/ios/Pods/FlipperKit/iOS/Plugins/FlipperKitPluginUtils/FlipperKitLayoutHelpers/FlipperKitLayoutHelpers/UIView+SKInvalidation.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'FlipperKit' from project 'Pods')

My podfile looks like:

`# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
"react-native/scripts/react_native_pods.rb",
{paths: [process.argv[1]]},
)', dir]).strip

platform :ios, min_ios_version_supported
prepare_react_native_project!

If you are using a react-native-flipper your iOS build will fail when NO_FLIPPER=1 is set.

because react-native-flipper depends on (FlipperKit,...) that will be excluded

To fix this you can also exclude react-native-flipper using a react-native.config.js

```js

module.exports = {

dependencies: {

...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),

```

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

use_frameworks! :linkage => :static

target 'MyCoolApp' do
config = use_native_modules!

Flags change depending on the env values.

flags = get_default_flags()

use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => FlipperConfiguration.enabled(["Debug"], { 'Flipper' => '0.163.0' }),
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

target 'MyCoolAppTests' do
inherit! :complete
# Pods for testing
end

post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end`

And my package.json looks like:
{ "name": "MyCoolApp", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@react-native-community/datetimepicker": "^7.6.1", "@react-native-firebase/app": "18.6.0", "@react-native-firebase/auth": "18.6.0", "@react-native-firebase/firestore": "18.6.0", "@react-native-firebase/functions": "18.6.0", "@react-navigation/bottom-tabs": "^6.3.3", "@react-navigation/native": "^6.0.12", "@react-navigation/native-stack": "^6.8.0", "moment": "^2.29.4", "react": "18.2.0", "react-native": "0.72.6", "react-native-dropdown-select-list": "^2.0.5", "react-native-get-random-values": "^1.9.0", "react-native-image-picker": "^7.0.2", "react-native-modal-datetime-picker": "^17.1.0", "react-native-paper": "^5.6.0", "react-native-phone-number-input": "^2.1.0", "react-native-photo-manipulator": "^1.2.7", "react-native-safe-area-context": "4.5.0", "react-native-screens": "~3.20.0", "react-native-vector-icons": "^10.0.1", "react-phone-number-input": "^3.3.7", "styled-components": "^5.3.5" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/eslint-config": "^0.72.2", "@react-native/metro-config": "^0.72.11", "@tsconfig/react-native": "^3.0.0", "@types/react": "^18.0.24", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.2.1", "eslint": "^8.19.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.76.8", "prettier": "^2.4.1", "react-native-flipper": "^0.163.0", "react-test-renderer": "18.2.0", "typescript": "4.8.4" }, "engines": { "node": ">=16" } }

Im desperate here. About to ditch firebase and start over using AWS. Although I don't know what issues I would run into there.

@justaso
Copy link

justaso commented Nov 5, 2023

@jcontreras28 not really, these I think are the steps that helped me see my project's Realm DB within Flipper desktop app on MacOS. To be honest, it doesn't always work either, sometimes I need to disable/enable the Realm plugin in Flipper many times before the DB appears, not sure if it's an issue with Flipper or I am doing something wrong.

@losimen
Copy link

losimen commented Mar 18, 2024

In our case app broken after release of new IOS 17.4. We tried fix it for several days, and I decided to try update all packages with command: yarn upgrade --latest and it helped!

@Lizcq11
Copy link

Lizcq11 commented Jul 3, 2024

Downgrade flipper to version 0.164.0 on IOS, this solves the issue.

This is what actually worked for me, now I'm able to archive my app again.

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

Successfully merging a pull request may close this issue.