Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Expo CLI Support for New Architecture #713

Open
griffinshuth opened this issue Sep 24, 2024 · 21 comments
Open

Add Expo CLI Support for New Architecture #713

griffinshuth opened this issue Sep 24, 2024 · 21 comments

Comments

@griffinshuth
Copy link

griffinshuth commented Sep 24, 2024

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Collaborator

dtroupe-plaid commented Sep 30, 2024

  • Can you confirm you are using the new environment (Fabric) ?
  • Can you share your pod file or preferably a modified version of the FabricExample podfile that reproduces this issue?

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
Copy link
Author

griffinshuth commented Oct 1, 2024

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
Copy link
Collaborator

dtroupe-plaid commented Oct 1, 2024

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
Copy link
Author

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
Copy link

@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
Copy link
Collaborator

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.

@dtroupe-plaid dtroupe-plaid reopened this Oct 2, 2024
@dtroupe-plaid dtroupe-plaid changed the title wrong path when not using useFrameworks Add Expo CLI Support for New Architecture Oct 2, 2024
@amol-ghotankar
Copy link

amol-ghotankar commented Oct 16, 2024

Thanks for reference would be good to see Plaid updates to new architecture soon as this will really simplify integration, testing and updates of Plaid SDK in future in apps that are build with next generation technologies.

@dtroupe-plaid - Is there any ETA planned to support this as it will help us update the sdk in future?

@dtroupe-plaid
Copy link
Collaborator

Hi @amol-ghotankar - At this time I cannot provide an ETA for Expo support.

@xubmuajkub
Copy link

I also have this issue 'react_native_plaid_link_sdk-Swift.h' file not found on RN 0.76.1 with new architecture enabled by default.

Step to reproduce

  1. Create a new project with npx react-native@latest init NewProject
  2. Install Plaid package npm install react-native-plaid-link-sdk
  3. Update Podfile to have use_frameworks! :linkage => :static (we use this because of Firebase)
  4. Clean Xcode project and rebuild

My Podfile:

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

# This block of code removed since we use :static
#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 'NewProject' do
  use_frameworks! :linkage => :static
  
  config = use_native_modules!

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

  target 'NewProjectTests' 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

@jason-evoluter
Copy link

The app built successfully when making change to this file node_modules/react-native-plaid-link-sdk/ios/PLKFabricHelpers.h but have not tested yet

#import <React/RCTConversions.h>
#import <folly/dynamic.h>
#import <objc/runtime.h>

#if __has_include(<rnplaidlink/react_native_plaid_link_sdk-Swift.h>)
#import <rnplaidlink/react_native_plaid_link_sdk-Swift.h>
#else
#ifdef USE_FRAMEWORKS
#import <react_native_plaid_link_sdk/react_native_plaid_link_sdk-Swift.h>
#else
#ifdef RCT_NEW_ARCH_ENABLED
#import <react_native_plaid_link_sdk/react_native_plaid_link_sdk-Swift.h>
#else
#import <react_native_plaid_link_sdk-Swift.h>
#endif
#endif
#endif

@dtroupe-plaid
Copy link
Collaborator

@jason-evoluter thanks for providing that code. I will try to test this and if it works I'll push a new release ASAP.

@griffinshuth
Copy link
Author

yeah thats exactly what we had to do just wanted to see if you were able to verify on your testing and get a new release pushed out @dtroupe-plaid

@dtroupe-plaid
Copy link
Collaborator

@griffinshuth I was able to verify this fix works in 0.76.1 and I released v11.13.1 with this update. Please let me know if the issue persists.

@dtroupe-plaid
Copy link
Collaborator

Following up here - the fix above caused a similar issue that I was able to reproduce.

I believe the issue here is that #ifdef USE_FRAMEWORKS is not resolving to true. So in your app the code is trying to import <react_native_plaid_link_sdk-Swift.h> instead of <react_native_plaid_link_sdk/react_native_plaid_link_sdk-Swift.h> this isn't related to the use of the new architecture.

I will be releasing an update today that updates the imports to the following code:

#if __has_include(<rnplaidlink/react_native_plaid_link_sdk-Swift.h>)
// If the header file is available under the rnplaidlink module, include it.
// This is typically the case when the module is structured with this specific header path.
#import <rnplaidlink/react_native_plaid_link_sdk-Swift.h>

#else
// If the header is not found at the above path, check for other configurations.
#if defined(RCT_NEW_ARCH_ENABLED) && defined(USE_FRAMEWORKS)
// Include the header for projects with the new React Native architecture and `use_frameworks!` enabled.
// This path supports modular builds with frameworks.
#import <react_native_plaid_link_sdk/react_native_plaid_link_sdk-Swift.h>

#else
#ifdef USE_FRAMEWORKS
// Include the header for projects using frameworks (`use_frameworks!` in the Podfile).
#import <react_native_plaid_link_sdk/react_native_plaid_link_sdk-Swift.h>

#else
// Default to including the header directly for non-framework builds.
#import <react_native_plaid_link_sdk-Swift.h>
#endif
#endif
#endif

Notes for Developers: If you experience a compiler error above

  1. Ensure your pods are installed with the USE_FRAMEWORKS=1 environment variable:
    USE_FRAMEWORKS=1 bundle exec pod install
  2. Verify that your Podfile includes either:
    use_frameworks! :linkage => :dynamic
    or
    use_frameworks! :linkage => :static
  3. Refer to these GitHub issues for more details:

Troubleshooting:

  • If USE_FRAMEWORKS is not working, ensure it is correctly passed as a preprocessor macro in your Xcode build settings.
  • For new architecture projects, confirm RCT_NEW_ARCH_ENABLED is properly set in your environment.

Please follow up if you're encountering issues and thanks for your patience and assitance.

@ocho-cesar
Copy link

We get an error while running USE_FRAMEWORKS=1 npx pod-install

[!] Invalid `Podfile` file: Invalid linkage option :"1", valid options are [:static, :dynamic].

 #  from /Users/ocho/Developer/frontend-customer/ios/Podfile:37
 #  -------------------------------------------
 #    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']
 #
 #  -------------------------------------------
Couldn't install Pods. Updating the Pods project and trying again...
Command `pod install` failed.
└─ Cause: Invalid `Podfile` file: Invalid linkage option :"1", valid options are [:static, :dynamic].

 #  from /Users/ocho/Developer/frontend-customer/ios/Podfile:37
 #  -------------------------------------------
 #    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']

@dtroupe-plaid
Copy link
Collaborator

dtroupe-plaid commented Dec 16, 2024

@ocho-cesar The error occurs because USE_FRAMEWORKS=1 is not a valid value for the :linkage option in your Podfile. The only accepted values are :static or :dynamic. Please note this is unrelated to the Plaid Link SDK.

To fix this, adjust your command to:

USE_FRAMEWORKS=dynamic npx pod-install

or

use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS'] && ['static', 'dynamic'].include?(ENV['USE_FRAMEWORKS'])

@dtroupe-plaid
Copy link
Collaborator

This issue should be resolved with the changes introduced in #739 and the release of v12.0.1.

Additionally, we’ve provided a new example project, exampleReactNative76, which supports testing with React Native 0.76.6.

I’m closing this issue for now. However, if you’re still experiencing any problems with SDK version >= 12.0.1, please feel free to comment, and we’ll be happy to assist further.

@dtroupe-plaid dtroupe-plaid reopened this Jan 30, 2025
@i2equalsj2
Copy link

For anyone who is still having this issue or the an issue with React Native 0.77, just use version 10.13.1 of this package. It's compatible with RN 0.76 and 0.77 and it shouldn't matter if you're using Expo or not.

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

No branches or pull requests

7 participants