react-native-reanimated: Shared Element Transitions not working for iOS when adding use_frameworks inside Podfile.

Description

On adding the line use_frameworks! :linkage => :static inside Podfile shared transitions stop working in the iOS build.

My main project has a dependency on rnfirebase. As stated in its documentation here, it requires CocoaPods to use frameworks.

The shared transition animation stops working when adding the use_frameworks line and rebuilding the project. After opting out of the use frameworks usage and rebuilding the project fixes this issue, but rnfirebase stops working. Need help in getting both rnfirebase and shared elements transitions to work together.

In the minimal repo inside App.tsx I am calling ManyScreensExample to test the transition.

Steps to reproduce

In main branch inside podfile

  1. Added line use_frameworks! :linkage => :static
  2. Commented line :flipper_configuration => flipper_config,

A stable version can be found in the branch stable/shared

  1. Commented line use_frameworks! :linkage => :static
  2. Uncommented line :flipper_configuration => flipper_config,

Snack or a link to a repository

https://github.com/jerinjohnk/reanimatedTest/tree/main

Reanimated version

3.1.0

React Native version

0.71.7

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

iPhone 14 Pro

Acknowledgements

Yes

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 15 (1 by maintainers)

Most upvoted comments

For me it seems like Expo 50 broke the transition, it used to work fine on 49. And it still works on Android!

Any idea how to fix it when using Expo Dev Client?

Issue persists – please reopen

Try adding this to the Podfile

$static_framework = ['RNScreens']

pre_install do |installer|
   Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
   installer.pod_targets.each do |pod|
     if $static_framework.include?(pod.name)
       def pod.build_type;
         Pod::BuildType.static_library
       end
     end
   end
end

This issue is still persistent, this issue should be reopened

@TowhidKashem & @julian-gargicevich Sorry for the late reply. Here’s my podfile for which it had worked.

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

$RNFirebaseAnalyticsWithoutAdIdSupport=false
$RNAppsFlyerStrictMode=false

use_frameworks! :linkage => :static

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

target 'Demo' 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.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :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 => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

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

  $static_framework = ['RNScreens']

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
      if $static_framework.include?(pod.name)
        def pod.build_type;
          Pod::BuildType.static_library
        end
      end
    end
  end

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"
      end
    end
  end
end

Hope that helps.

@TowhidKashem put it in your target ‘AppFoo’. near post_install

It should work usually. We build RNScreens as static_library it is the default behavior when you don’t use use_frameworks. You can see related issues in these libraries react-native-screens, flipper, react-native-permissions

Try adding this to the Podfile

$static_framework = ['RNScreens']

pre_install do |installer|
   Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
   installer.pod_targets.each do |pod|
     if $static_framework.include?(pod.name)
       def pod.build_type;
         Pod::BuildType.static_library
       end
     end
   end
end

Thanks @zhenkaGo adding these lines did fix the issue. It won’t introduce any breaking change in reanimated or react-native-screens, right?