homeeondemand / react-native-mapbox-navigation

A navigation UI ready to drop into your React Native application
MIT License
153 stars 118 forks source link

Undefined method `post_install` for Nil:NilClass #77

Open JackJBlundell opened 2 years ago

JackJBlundell commented 2 years ago

Hi, I'm experiencing an issue when trying to pod install on a project with the instructions given on the ReadMe. I keep facing an issue where the post_install triggers an error (RNBNAV.post_install). I thought it was due to my dependencies as I have had to be quite hacky with them, but after trying on a fresh project i experience the same issue.

Error:

Downloading dependencies
* Changed MapboxMobileEvents to dynamic framework
* Changed MapboxMobileEvents to dynamic framework
Generating Pods project
[!] An error occurred while processing the post-install hook of the Podfile.

undefined method `post_install' for nil:NilClass

/Users/jackblundell/Desktop/RouteBuddies/ios/Podfile:74:in `block (3 levels) in from_ruby'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-core-1.11.2/lib/cocoapods-core/podfile.rb:196:in `post_install!'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:945:in `run_podfile_post_install_hook'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:933:in `block in run_podfile_post_install_hooks'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:149:in `message'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:932:in `run_podfile_post_install_hooks'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:331:in `block (2 levels) in create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:330:in `block in create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:309:in `create_and_save_projects'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:301:in `generate_pods_project'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:180:in `integrate'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/installer.rb:167:in `install!'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/command/install.rb:52:in `run'
/Users/jackblundell/.rvm/gems/ruby-2.7.4/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.11.2_2/libexec/bin/pod:25:in `<main>'

Podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'
install! 'cocoapods', :disable_input_output_paths => true

target 'RouteBuddies' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  permissions_path = '../node_modules/react-native-permissions/ios'

  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-LocationAccuracy', :path => "#{permissions_path}/LocationAccuracy"
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"

  target 'RouteBuddiesTests' do
    inherit! :complete
    # Pods for testing

    $RNMapboxMapsImpl = 'mapbox'
    $RNMapboxMapsVersion = '~> 6.3'
    $ReactNativeMapboxGLIOSVersion = "~> 6.3"
    ENV['REACT_NATIVE_MAPBOX_GL_USE_FRAMEWORKS'] = 'true'

  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!({ 'Flipper-Folly' => '2.3.0' })

  if (defined?(TargetsToChangeToDynamic)).nil?
  TargetsToChangeToDynamic = ['MapboxMobileEvents']
  elsif TargetsToChangeToDynamic.include? 'MapboxMobileEvents' === false
    TargetsToChangeToDynamic.push('MapboxMobileEvents')
  end
  $dynamic_framework = ['MapboxMobileEvents']
  pod 'react-native-mapbox-gl', :path => '../node_modules/@react-native-mapbox-gl/maps'
  pod 'MapboxNavigation', '~> 1.3'
  pod 'MapBox', '~> 1.1.0'

  pre_install do |installer|
    $RNMapboxMaps.pre_install(installer)
  end
  pre_install do |installer|
    $RNMBNAV.pre_install(installer)
  end
  pre_install do |installer|

    $RNMBGL.pre_install(installer)
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
      if !$dynamic_framework.include?(pod.name)
        def pod.build_type;
          Pod::BuildType.static_library
        end
      end
    end
  end

  post_install do |installer|
    # This below is causing issue
    $RNMapboxMaps.post_install(installer)

    $RNMBNAV.post_install(installer)
    installer.pods_project.targets.each do |target|
     target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
     end
    end

  end
  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
end

My package.json file:

{
  "name": "routebuddies",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
    "prepare": "npm run build"
  },
  "dependencies": {
    "@homee/react-native-mapbox-navigation": "^1.1.0",
    "@react-native-community/datetimepicker": "^6.0.1",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-mapbox-gl/maps": "^8.6.0-beta.0",
    "@react-native-picker/picker": "^2.3.1",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/stack": "^6.1.1",
    "@types/firebase": "^3.2.1",
    "@types/mapbox": "^1.6.42",
    "@types/react-geocode": "^0.2.0",
    "@types/react-native-vector-icons": "^6.4.10",
    "@types/turf": "^3.5.32",
    "firebase": "^8.3.0",
    "mapbox": "^1.0.0-beta10",
    "moment": "^2.29.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-geocode": "^0.2.3",
    "react-native": "^0.63.4",
    "react-native-elements": "^3.4.2",
    "react-native-geolocation-service": "^5.3.0-beta.4",
    "react-native-gesture-handler": "^2.3.1",
    "react-native-image-picker": "^4.7.3",
    "react-native-permissions": "^3.3.1",
    "react-native-phone-call": "^1.0.9",
    "react-native-reanimated": "^2.4.1",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^3.13.1",
    "react-native-vector-icons": "^9.1.0",
    "rn-sliding-up-panel": "^2.4.5",
    "turf": "^3.0.14"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/jest": "^26.0.23",
    "@types/react-native": "^0.66.15",
    "@types/react-test-renderer": "^17.0.1",
    "@typescript-eslint/eslint-plugin": "^5.7.0",
    "@typescript-eslint/parser": "^5.7.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "17.0.2",
    "typescript": "^4.6.2"
  },
  "resolutions": {
    "@types/react": "^17"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  }
}

I hope somebody can help, this is an awesome library and using it on iOS is a big need for us :))

studiozocaro commented 1 year ago

same error. Solution: remove From podfile

pre_install do |installer| $RNMapboxMaps.pre_install(installer) ... other pre install hooks end post_install do |installer| $RNMapboxMaps.post_install(installer) ... other post install hooks end

Kikanye commented 7 months ago

@JackJBlundell Did you figure out how to fix this?

LIND96 commented 3 days ago

you can try this https://stackoverflow.com/questions/78628793/post-install-giving-error-after-running-pod-install-react-native-ios