prscX / react-native-photo-editor

React Native: Native Photo Editor
Apache License 2.0
1.12k stars 243 forks source link

Installing with ExpoKit gives "null is not an object(evaluating RNPhotoEditor.Edit)" error #114

Open SamyOptimize opened 4 years ago

SamyOptimize commented 4 years ago

I've been trying to install this library for the past 2 days and trying most fixes and workarounds that i've found. But the more fixes and workarounds i try the more errors i run into.

I followed the instructions in the README file and did everything as stated but as soon as i try to use RNPhotoEditor.edit i get the error in the title. I found out that the RNPhotoEditor error is not the one from this library but from the the one used inside the library that's imported from const { RNPhotoEditor } = NativeModules; which returns RNPhotoEditor as null.

I'm using an ejected Expo project with ExpoKit and i'm not sure if that's the problem or not.

The error is also on android but i did most of my searches for IOS and xcode

React native version: 0.61 RNPhotoEditor version: 1.0.5 Cocapods version: 1.8.4 Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target '{PROJECT_NAME}' do

  use_native_modules!

    pod 'RNPhotoEditor', :path => '../node_modules/react-native-photo-editor/ios'

  use_frameworks!

    pod 'iOSPhotoEditor', :git => 'https://github.com/prscX/photo-editor', :branch => 'master'

  pod 'ExpoKit',
    :git => "http://github.com/expo/expo.git",
    :tag => "ios/2.14.3",
    :subspecs => [
      "Core"
    ],
    :inhibit_warnings => true

  # Install unimodules
  require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
  use_unimodules!(
    modules_paths: ['../node_modules'],
    exclude: [
      'expo-bluetooth',
      'expo-in-app-purchases',
      'expo-payments-stripe',
    ],
  )

 # Install React Native and its dependencies
 require_relative '../node_modules/react-native/scripts/autolink-ios.rb'
 use_react_native!

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name.include?('iOSPhotoEditor')
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '5'
        end
      end
    end
    installer.pods_project.main_group.tab_width = '2';
    installer.pods_project.main_group.indent_width = '2';

    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|

      if pod_name == 'ExpoKit'
        target_installation_result.native_target.build_configurations.each do |config|
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'EX_DETACHED=1'

          # Enable Google Maps support
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'HAVE_GOOGLE_MAPS=1'
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'HAVE_GOOGLE_MAPS_UTILS=1'

        end
      end

      target_installation_result.native_target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
      end

      # Can't specify this in the React podspec because we need to use those podspecs for detached
      # projects which don't reference ExponentCPP.
      if pod_name.start_with?('React')
        target_installation_result.native_target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
          config.build_settings['HEADER_SEARCH_PATHS'] ||= ['$(inherited)']
        end
      end

      # Build React Native with RCT_DEV enabled and RCT_ENABLE_INSPECTOR and
      # RCT_ENABLE_PACKAGER_CONNECTION disabled
      next unless pod_name.start_with?('React')
      target_installation_result.native_target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_DEV=1'
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_ENABLE_INSPECTOR=0'
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'ENABLE_PACKAGER_CONNECTION=0'
      end

    end
  end
end

The above podfile throws a

The 'Pods-PROJECTNAME' target has transitive dependencies that include statically linked binaries: (/Users/{USERNAME}/../../{PROJECT_NAME}/ios/Pods/Crashlytics/iOS/Crashlytics.framework, /Users/{USERNAME}/../../{PROJECT_NAME}/ios/Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework, /Users/{USERNAME}/../../{PROJECT_NAME}/ios/Pods/GoogleMaps/Maps/Frameworks/GoogleMaps.framework, and /Users/{USERNAME}/../../{PROJECT_NAME}/ios/Pods/GoogleMaps/Maps/Frameworks/GoogleMapsCore.framework)

So i tried the fix from beobungbu Which fixed the error from popping up when i use pod update but when I try to build the app from Xcode i get another error saying /Users/{USERNAME}/../../{PROJECT_NAME}/node_modules/unimodules-permissions-interface/ios/UMPermissionsInterface/UMPermissionsInterface.h:4:9: 'UMCore/UMModuleRegistry.h' file not found

I saw issue 6477 on expo which supposedly fixes the problem but i don't think it released yet.

so I tried hyukher's fix which got rid of the error but then I ran into more errors when i tried to build again.

Undefined symbols for architecture x86_64:
  "_OBJC_METACLASS_$_GMSSyncTileLayer", referenced from:
      _OBJC_METACLASS_$_GMUHeatmapTileLayer in GMUHeatmapTileLayer.o
  "_kGMSTileLayerNoTile", referenced from:
      -[GMUHeatmapTileLayer tileForX:y:zoom:] in GMUHeatmapTileLayer.o
  "_GMSProject", referenced from:
      -[GMUGridBasedClusterAlgorithm clustersAtZoom:] in GMUGridBasedClusterAlgorithm.o
      -[GMUClusterItemQuadItem initWithClusterItem:] in GMUNonHierarchicalDistanceBasedAlgorithm.o
      -[GMUNonHierarchicalDistanceBasedAlgorithm clustersAtZoom:] in GMUNonHierarchicalDistanceBasedAlgorithm.o
      -[GMUWeightedLatLng initWithCoordinate:intensity:] in GMUWeightedLatLng.o
  "_GMSUnproject", referenced from:
      -[GMUGridBasedClusterAlgorithm clustersAtZoom:] in GMUGridBasedClusterAlgorithm.o
  "_OBJC_CLASS_$_GMSMarker", referenced from:
      objc-class-ref in GMUDefaultClusterRenderer.o
      objc-class-ref in GMUGeometryRenderer.o
  "_OBJC_CLASS_$_GMSPolygon", referenced from:
      objc-class-ref in GMUGeometryRenderer.o
  "_OBJC_CLASS_$_GMSMutablePath", referenced from:
      objc-class-ref in GMUGeoJSONParser.o
      objc-class-ref in GMUKMLParser.o
  "_OBJC_CLASS_$_GMSSyncTileLayer", referenced from:
      _OBJC_CLASS_$_GMUHeatmapTileLayer in GMUHeatmapTileLayer.o
  "_OBJC_CLASS_$_GMSPolyline", referenced from:
      objc-class-ref in GMUGeometryRenderer.o
  "_OBJC_CLASS_$_GMSGroundOverlay", referenced from:
      objc-class-ref in GMUGeometryRenderer.o
  "_OBJC_CLASS_$_GMSCoordinateBounds", referenced from:
      objc-class-ref in GMUDefaultClusterRenderer.o
      objc-class-ref in GMUGeoJSONParser.o
      objc-class-ref in GMUGeometryRenderer.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

So i'm currently at a dead end and I was hoping i could get some help.

nou-g commented 4 years ago

+1