idenfy / ReactNativeSDK

Idenfy React Native SDK
MIT License
8 stars 6 forks source link

Expo iOS app crashes when Idenfy library is installed #3

Closed palicko closed 2 years ago

palicko commented 2 years ago

Hi, is this library working well with Expo 46 (bare workflow)?

As soon as the app is built with this Idenfy RNSDK library, app instantly crashes on startup.

On iOS, we do configuration from the docs, e.g. setup camera permissions and customize Podfile.

Podfile:

install! 'cocoapods',
         :generate_multiple_pod_projects => true,
         :incremental_installation => true,
         :deterministic_uuids => false
source 'https://cdn.cocoapods.org/'
platform :ios, '12.4'
inhibit_all_warnings!

# Import the auto-linking packages
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")

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

abstract_target 'common' do
  pod 'expo-dev-menu', path: '../node_modules/expo-dev-menu', :testspecs => ['Tests', 'UITests']
  # pod 'expo-dev-menu', path: '../node_modules/expo-dev-menu', :configurations => :debug

  use_expo_modules!(
    tests: [
      'expo-dev-menu-interface',
      'expo-dev-launcher',
    ],
  )

  # Required by Idenfy
  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']

  # Flags change depending on the env values.
  flags = get_default_flags()

  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => flags[:hermes_enabled] || podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # :flipper_configuration => FlipperConfiguration.enabled,
    :flipper_configuration => false, # disabled because of Idenfy and !use_frameworks
    # An absolute path to your application root.
    :app_path => "#{Dir.pwd}/.."
  )

  post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == "ZIPFoundation" || target.name == "lottie-ios"
          target.build_configurations.each do |config|
            config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        end
      end
    end

    # `installer.pods_project` might be nil for `incremental_installation: true` and no new project generated
    react_native_post_install(installer) if installer.pods_project
    __apply_Xcode_12_5_M1_post_install_workaround(installer) if installer.pods_project

    # 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

  target 'MyProject' do
  end

  target 'MyProject-staging' do
  end

  target 'MyProject-dev' do
  end
end

With Expo, we are using incremental_installation: true, so installer.pods_project is nil, therefore that BUILD_LIBRARY_FOR_DISTRIBUTION is not set. And build crashes with

Cause: An error occurred while processing the post-install hook of the Podfile.
undefined method `targets' for nil:NilClass

So we commented that post snippet out to make the build pass correctly. Could this missing BUILD_LIBRARY_FOR_DISTRIBUTION be the reason why the app is crashing?

I've also tried to disable Hermes.

palicko commented 2 years ago

Managed to solve this, problem was incompatibility with react-native-reanimated, Hermes and use_frameworks!. I've also needed to disable incremental_installation.