Quantcast
Channel: Active questions tagged cocoapods - Stack Overflow
Viewing all articles
Browse latest Browse all 1029

How to create a react native library wrapper over an ios framework file which has a dependency on other pods?

$
0
0

I'm new to react native and am trying to build a react native library wrapper over an iOS framework. This framework depends on a third party cocoapod (BSImagePicker). I tried to add this pod as a dependency in the podspec file and directly in the podfile but both don't work with the app crashing withdyld[8161]: Library not loaded: "@rpath/BSImagePicker.framework/BSImagePicker"

My podspec file:

require 'json'package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))Pod::Spec.new do |s|  s.name           = 'ReactNativeReader'  s.version        = package['version']  s.summary        = package['description']  s.description    = package['description']  s.license        = package['license']  s.author         = package['author']  s.homepage       = package['homepage']  s.platforms      = { :ios => '13.4', :tvos => '13.4' }  s.swift_version  = '5.4'  s.source         = { git: 'https://github.com' }  s.static_framework = true  s.dependency 'ExpoModulesCore'  s.dependency 'BSImagePicker'  s.vendored_frameworks = 'TestFrameworks.framework'  # Swift/Objective-C compatibility  s.pod_target_xcconfig = {'DEFINES_MODULE' => 'YES','SWIFT_COMPILATION_MODE' => 'wholemodule'  }  s.source_files = "**/*.{h,m,swift}"end

Podfile:

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']platform :ios, podfile_properties['ios.deploymentTarget'] || '13.4'install! 'cocoapods',  :deterministic_uuids => falseprepare_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,...), which will be excluded. To fix this,# you can also exclude `react-native-flipper` in `react-native.config.js`## ```js# module.exports = {#   dependencies: {#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),#   }# }# ```flipper_config = FlipperConfiguration.disabledif ENV['NO_FLIPPER'] == '1' then  # Explicitly disabled through environment variables  flipper_config = FlipperConfiguration.disabledelsif podfile_properties.key?('ios.flipper') then  # Configure Flipper in Podfile.properties.json  if podfile_properties['ios.flipper'] == 'true' then    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"])  elsif podfile_properties['ios.flipper'] != 'false' then    flipper_config = FlipperConfiguration.enabled(["Debug", "Release"], { 'Flipper' => podfile_properties['ios.flipper'] })  endendtarget 'readerexample' do  use_expo_modules!  use_modular_headers!  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => true  pod 'BSImagePicker', :modular_headers => true  config = use_native_modules!  pod "GoogleMLKit/TextRecognition"  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}/..",    # Note that if you have use_frameworks! enabled, Flipper will not work if enabled    :flipper_configuration => flipper_config  )  post_install do |installer|    react_native_post_install(      installer,      config[:reactNativePath],      :mac_catalyst_enabled => false    )    # 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  endend

Would appreciate any help in knowing if I'm missing something!

I tried to add the cocoapod dependency through the podspec file and directly through the podfile and both end up with the app crashing on launch with these logs

dyld[8166]: Library not loaded: @rpath/BSImagePicker.framework/BSImagePickerReferenced from: <36C62FDE-E2A2-35CD-8D1D-8C8F828147AC> /private/var/containers/Bundle/Application/E0E3A1EE-4C7A-4D48-97F3-78F8DCF4EE75/reactnativegccardreaderexample.app/Frameworks/TestFrameworks.framework/TestFrameworksReason: tried: '/usr/lib/swift/BSImagePicker.framework/BSImagePicker' (errno=2, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/BSImagePicker.framework/BSImagePicker' (errno=2), '/private/var/containers/Bundle/Application/E0E3A1EE-4C7A-4D48-97F3-78F8DCF4EE75/reactnativegccardreaderexample.app/Frameworks/BSImagePicker.framework/BSImagePicker' (errno=2), '/private/var/containers/Bundle/Application/E0E3A1EE-4C7A-4D48-97F3-78F8DCF4EE75/reactnativegccardreaderexample.app/Frameworks/TestFrameworks.framework/Frameworks/BSImagePicker.framework/BSImagePicker' (errno=2), '/private/var/containers/Bundle/Application/Frameworks/BSImagePicker.framework/BSImagePicker'


Viewing all articles
Browse latest Browse all 1029

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>