flipper icon indicating copy to clipboard operation
flipper copied to clipboard

iOS - react-native-flipper includes FlipperKit, even in Release configuration

Open TimBroddin opened this issue 6 years ago • 43 comments

🐛 Bug Report

If you're using react-native-flipper and do pod install, the included files assume you have FlipperKit installed.

However, if you have lines like these in your Podfile, FlipperKit will only be installed when your application is run in Debug configuration.

def add_flipper_pods!
  version = '~> 0.33.1'
  pod 'FlipperKit', version, :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => 'Debug'
  pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitUserDefaultsPlugin', version, :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitReactPlugin', version, :configuration => 'Debug'
end

Creating a release build will fail.

I upgraded from RN 0.61.5 to 0.62 and did the migration by hand, so I might've missed something that prevents this bug from happening on a fresh 0.62 install.

To Reproduce

  1. Install react-native
  2. npm i --save-dev react-native-flipper
  3. Do pod install
  4. Create a release build
  5. Get this error:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_FlipperClient", referenced from:
      objc-class-ref in libreact-native-flipper.a(FlipperReactNativeJavaScriptPluginManager.o)

When react-native-flipper is removed and pod install is ran again, a release build will compile again.

Environment

iOS

TimBroddin avatar Apr 04 '20 21:04 TimBroddin

cc. @priteshrnandgaonkar, @mweststrate

cekkaewnumchai avatar Apr 05 '20 20:04 cekkaewnumchai

Same here

Yallan avatar Apr 06 '20 17:04 Yallan

The same here. If I add Release configuration it works as well

def add_flipper_pods!
    version = '~> 0.33.1'
    pod 'FlipperKit', version, :configuration => ['Debug', 'Release']
    pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => ['Debug', 'Release']
    pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => ['Debug', 'Release']
    pod 'FlipperKit/FlipperKitUserDefaultsPlugin', version, :configuration => ['Debug', 'Release']
    pod 'FlipperKit/FlipperKitReactPlugin', version, :configuration => ['Debug', 'Release']
  end

tr3v3r avatar Apr 07 '20 13:04 tr3v3r

Facing the same issue

MikhailVolkov350504 avatar Apr 08 '20 09:04 MikhailVolkov350504

Apologies for not updating the issue! @priteshrnandgaonkar landed a fix yesterday: https://github.com/facebook/react-native/commit/e5497ca8f6e3b240948fdbeef0ac2a710f25bb56, so this should be fixed in the next release, but if you don't want to await that, I think it should be possible to manually copy these changes.

mweststrate avatar Apr 08 '20 10:04 mweststrate

Fixed for me by remove react-native-flipper (installed when i add flipper-plugin-rn-redux-inspector)

Yallan avatar Apr 08 '20 10:04 Yallan

@mweststrate After upgrade to react-native v. 0.62.2 and react-native-flipper v. 0.37 the issue still presents ;(

As a workaround I had to disable auto-link for react-native-flipper for iOS. And manually add pods installation for react-native-flipper with Debug configutation

react-native-config.js

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

pods

pod 'react-native-flipper', :path => '../node_modules/react-native-flipper/react-native-flipper.podspec', :configuration => 'Debug'

I hope it helps.

tr3v3r avatar Apr 13 '20 12:04 tr3v3r

I can confirm that the workaround by @tr3v3r works!

TimBroddin avatar Apr 13 '20 18:04 TimBroddin

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

SaveYourTime avatar Apr 15 '20 00:04 SaveYourTime

Closing this issue, feel free to reopen if the issue persists in v0.62.2 with the above mentioned changes.

priteshrnandgaonkar avatar Apr 16 '20 11:04 priteshrnandgaonkar

This is not fixed yet. Flipper is till included in release mode.

AppSphere avatar Apr 25 '20 13:04 AppSphere

This issue is closed, please open a new issue including your build configuration in the podspec file

On Sat, 25 Apr 2020, 14:02 Aashish Patil, [email protected] wrote:

This is not fixed yet. Flipper is till included in release mode.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/flipper/issues/976#issuecomment-619376533, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBGMKEIO3IE4UFRX3M3ROLNPLANCNFSM4L7H6PBA .

mweststrate avatar Apr 25 '20 15:04 mweststrate

After upgrade to react-native v. 0.63.0-rc.0 and react-native-flipper v. 0.39 the issue still presents

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

Podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'myApp' do
  platform :ios, '11.0'
  pod 'Firebase/Core', '~> 6.3.0'
  pod 'Firebase/Messaging', '~> 6.3.0'
  pod 'Crashlytics', '~> 3.14.0'
  pod 'RSKImageCropper','~> 2.0.0'
  pod 'QBImagePickerController' ,'~> 3.4.0'
  pod 'Stripe', '~> 14.0.0'
  pod 'GoogleIDFASupport', '~> 3.14.0'
  pod 'Fabric', '~> 1.10.2'

    # React Native Maps dependencies
    rn_maps_path = '../node_modules/react-native-maps'
    pod 'react-native-google-maps', :path => rn_maps_path
    pod 'GoogleMaps'
    pod 'Google-Maps-iOS-Utils'


    config = use_native_modules!
    use_react_native!(:path => config["reactNativePath"])


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

   # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'myApp-tvOS' do
  # Pods for myApp-tvOS

  target 'myApp-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

react_native_pods

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

def use_react_native! (options={})
  # The prefix to the react-native
  prefix = options[:path] ||= "../node_modules/react-native"

  # Include Fabric dependencies
  fabric_enabled = options[:fabric_enabled] ||= false

  # Include DevSupport dependency
  production = options[:production] ||= false

  # The Pods which should be included in all projects
  pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "#{prefix}/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "#{prefix}/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "#{prefix}/Libraries/TypeSafety"
  pod 'React', :path => "#{prefix}/"
  pod 'React-Core', :path => "#{prefix}/"
  pod 'React-CoreModules', :path => "#{prefix}/React/CoreModules"
  pod 'React-RCTActionSheet', :path => "#{prefix}/Libraries/ActionSheetIOS"
  pod 'React-RCTAnimation', :path => "#{prefix}/Libraries/NativeAnimation"
  pod 'React-RCTBlob', :path => "#{prefix}/Libraries/Blob"
  pod 'React-RCTImage', :path => "#{prefix}/Libraries/Image"
  pod 'React-RCTLinking', :path => "#{prefix}/Libraries/LinkingIOS"
  pod 'React-RCTNetwork', :path => "#{prefix}/Libraries/Network"
  pod 'React-RCTSettings', :path => "#{prefix}/Libraries/Settings"
  pod 'React-RCTText', :path => "#{prefix}/Libraries/Text"
  pod 'React-RCTVibration', :path => "#{prefix}/Libraries/Vibration"
  pod 'React-Core/RCTWebSocket', :path => "#{prefix}/"

  unless production
    pod 'React-Core/DevSupport', :path => "#{prefix}/"
  end

  pod 'React-cxxreact', :path => "#{prefix}/ReactCommon/cxxreact"
  pod 'React-jsi', :path => "#{prefix}/ReactCommon/jsi"
  pod 'React-jsiexecutor', :path => "#{prefix}/ReactCommon/jsiexecutor"
  pod 'React-jsinspector', :path => "#{prefix}/ReactCommon/jsinspector"
  pod 'React-callinvoker', :path => "#{prefix}/ReactCommon/callinvoker"
  pod 'ReactCommon/turbomodule/core', :path => "#{prefix}/ReactCommon"
  pod 'Yoga', :path => "#{prefix}/ReactCommon/yoga", :modular_headers => true

  pod 'DoubleConversion', :podspec => "#{prefix}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{prefix}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{prefix}/third-party-podspecs/Folly.podspec"

  if fabric_enabled
    pod 'React-Fabric', :path => "#{prefix}/ReactCommon"
    pod 'React-graphics', :path => "#{prefix}/ReactCommon/fabric/graphics"
    pod 'React-jsi/Fabric', :path => "#{prefix}/ReactCommon/jsi"
    pod 'React-RCTFabric', :path => "#{prefix}/React"
    pod 'Folly/Fabric', :podspec => "#{prefix}/third-party-podspecs/Folly.podspec"
  end
end

def use_flipper!(versions = {})
  versions['Flipper'] ||= '~> 0.33.1'
  versions['DoubleConversion'] ||= '1.1.7'
  versions['Flipper-Folly'] ||= '~> 2.1'
  versions['Flipper-Glog'] ||= '0.3.6'
  versions['Flipper-PeerTalk'] ||= '~> 0.0.4'
  versions['Flipper-RSocket'] ||= '~> 1.0'

  pod 'FlipperKit', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitUserDefaultsPlugin', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitReactPlugin', versions['Flipper'], :configuration => 'Debug'

  # List all transitive dependencies for FlipperKit pods
  # to avoid them being linked in Release builds
  pod 'Flipper', versions['Flipper'], :configuration => 'Debug'
  pod 'Flipper-DoubleConversion', versions['DoubleConversion'], :configuration => 'Debug'
  pod 'Flipper-Folly', versions['Flipper-Folly'], :configuration => 'Debug'
  pod 'Flipper-Glog', versions['Flipper-Glog'], :configuration => 'Debug'
  pod 'Flipper-PeerTalk', versions['Flipper-PeerTalk'], :configuration => 'Debug'
  pod 'Flipper-RSocket', versions['Flipper-RSocket'], :configuration => 'Debug'
  pod 'FlipperKit/Core', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/CppBridge', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FBCxxFollyDynamicConvert', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FBDefines', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FKPortForwarding', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
end

# 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
  end
end

Environment

System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Memory: 68.55 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.1 - /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: 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_242 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.0-rc.0 => 0.63.0-rc.0 
  npmGlobalPackages:
    *react-native*: Not Found

nvdnvd00 avatar Apr 27 '20 09:04 nvdnvd00

@nvdnvd00 have you tried https://github.com/facebook/flipper/issues/976#issuecomment-612874193

?

tr3v3r avatar May 09 '20 16:05 tr3v3r

yeah, it's working but i think we need a solution, not workaround

nvdnvd00 avatar May 09 '20 16:05 nvdnvd00

Downgraded from 0.62.2 to 0.61.5 and my build times have decreased 250%.

10 minutes locally down to 4 minutes.

30 minutes on Bitrise down to 12.5 minutes.

aelesia avatar May 20 '20 02:05 aelesia

@alloy any idea how this can happen? will auto linking the react-native-flipper package cause the Flipper SDK to be included, even though that should be included in DEV builds only? Can we somehow mark react-native-flipper itself as dev only?

mweststrate avatar May 22 '20 08:05 mweststrate

auto-link will indeed always activate pods it finds among react-native packages, regardless of configuration. However, it will also skip auto-linking of any pod that was explicitly activated by the user in their Podfile before the use_native_modules! call; so I think something like the following should work:

pod 'react-native-flipper', :path => '../node_modules/react-native-flipper', :configuration => 'Debug'
use_native_modules!
# ...

Can somebody please try and verify?


As for build times, such as those reported by @aelesia, there’s not much to be done there other than caching build artefacts, as there’s no way to tell Xcode to only build dependencies in specific configurations–we can only influence what will get linked.

alloy avatar May 22 '20 13:05 alloy

@alloy is linking also skipped if the requires are always conditional and the module is never used in prod builds? (e.g. all calls are wrapped like if (__DEV__) require('react-native-flipper').addPlugin({}) )

mweststrate avatar May 22 '20 13:05 mweststrate

@mweststrate Alas not, linking of native libraries does not depend on any runtime JS code.

alloy avatar May 22 '20 13:05 alloy