plaid / react-native-plaid-link-sdk

Plaid Link for React Native
MIT License
171 stars 120 forks source link

Add Expo CLI Support for New Architecture #713

Open griffinshuth opened 1 week ago

griffinshuth commented 1 week ago

Screenshot 2024-09-20 at 10 47 52 AM

The problem

when i am trying to build the ios app when i am not using "USE_FRAMEWORKS" I get this error thats in the screenshot.

when i change the path to be it works but i would really like to not patch this library if not needed. <react_native_plaid_link_sdk/react_native_plaid_link_sdk-Swift.h>

dtroupe-plaid commented 1 week ago

Can you clarify what you're changing to get pod install to work? Can you also provide the version of the SDK this is occurring with?

Thanks

griffinshuth commented 1 week ago

i went into the ios file PLKFabricHelpers.h and on line 11 i switched it from #import <react_native_plaid_link_sdk-Swift.h>

and i made it like this

#import <react_native_plaid_link_sdk/react_native_plaid_link_sdk-Swift.h>

we are on version v11.13.0

after i made that change in the node_modlues i was able to run pod install and it worked

dtroupe-plaid commented 3 days ago

Sorry, looking at this again the problem seems to be related to the iOS versions your app is supporting. V11 only supports iOS >= 14.0. What is the minimum iOS version your app is supporting?

dtroupe-plaid commented 3 days ago

I used the following version to disable USE_FRAMEWORKS.

# 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, 14.0
prepare_react_native_project!

# 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

ENV['RCT_NEW_ARCH_ENABLED'] = '1'

target 'FabricExample' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'FabricExampleTests' 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,
      # :ccache_enabled => true
    )
  end
end

However, I was able to run pod install and the iOS example project.

griffinshuth commented 2 days ago

Here is a copy of the pod file. We are using Expo screenshot_2024-10-01_at_7 07 21___am_720

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']

use_autolinking_method_symbol = ('use' + '_native' + '_modules!').to_sym
origin_autolinking_method = self.method(use_autolinking_method_symbol)
self.define_singleton_method(use_autolinking_method_symbol) do |*args|
  if ENV['EXPO_UNSTABLE_CORE_AUTOLINKING'] == '1'
    Pod::UI.puts('Using expo-modules-autolinking as core autolinking source'.green)
    config_command = [
      'node',
      '--no-warnings',
      '--eval',
      'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
      'react-native-config',
      '--json',
      '--platform',
      'ios'
    ]
    origin_autolinking_method.call(config_command)
  else
    origin_autolinking_method.call()
  end
end

platform :ios, podfile_properties['ios.deploymentTarget'] || '15.1'
install! 'cocoapods',
  :deterministic_uuids => false

prepare_react_native_project!

target 'VaroCruise' do
 pod 'Plaid', '~> 5.6.0'
  use_expo_modules!
  config = use_native_modules!

  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
  use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    :privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false',
  )

  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      :ccache_enabled => podfile_properties['apple.ccacheEnabled'] == 'true',
    )

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
end`
dtroupe-plaid commented 2 days ago

Thanks for the reply. Expo is not supported by this SDK. I am going to close the issue, because I believe this is expected. Feel free to provide more context if you think this is a mistake, but this SDK is currently only designed to work with vanilla React Native apps.

griffinshuth commented 2 days ago

Screenshot 2024-10-01 at 2 38 17 PM

i just tried to do it in a brand new project with the new arch and it looks like if i have the use_frameworks! :linkage => :static and i try to build it i get that error

`# 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, 14.1 prepare_react_native_project!

Set frameworks to use static linkage

use_frameworks! :linkage => :static

target 'newArch' do config = use_native_modules!

use_react_native!( :path => config[:reactNativePath],

An absolute path to your application root.

:app_path => "#{Pod::Config.instance.installation_root}/.."

)

target 'newArchTests' 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,
  # :ccache_enabled => true
)

end end`

amol-ghotankar commented 1 day ago

@dtroupe-plaid is there no plan to support react native new architecture is Plaid? React Native community is highly recommending using of react native new architecture and now the default cli for react native apps are expo, so does Plaid plan to close this issue and not support for it forever?

dtroupe-plaid commented 1 day ago

is there no plan to support react native new architecture is Plaid?

We are supporting the new architecture. I believe the issue here is the use of the expo CLI.

so does Plaid plan to close this issue and not support for it forever?

I think we can add support for this in the future based on the information I found here. Additionally, I can make the requested change in this issue, but I am not sure that will fully resolve the issues you're facing due to the use of Expo.