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

Question: Alternative way to resolve Invalid RNPermission X. Should be one of: () #434

Closed
divyanshu013 opened this issue Mar 31, 2020 · 11 comments
Labels
duplicate This issue or pull request already exists

Comments

@divyanshu013
Copy link

Question

Hi, I was earlier using v1.x of the library but had to migrate to v2.x recently since I was upgrading to react native 0.61.4

I followed the docs here and rewrote our permissions service for the updated API in v2.x.

After that I added the required permissions handlers from the docs.

Following this I ran into the the error "Invalid RNPermission X. Should be one of: ()", so I tried to resolve it by following the steps mentioned in the docs.

First I tried to use the use_modular_headers approach (the app was using use_frameworks in earlier react native version - 0.59). But when I tried to build the app from XCode, I ran into a Thread 1: signal SIGABRT issue:

Screen Shot 2020-03-31 at 11 04 23

I tried both approaches from the docs - using modular headers as well as the workaround with use frameworks. But both cause the same error for me.

Its probably some issue with one of my other native dependencies so I was wondering is there an alternative approach I can use to resolve the "Invalid RNPermission X. Should be one of: ()" error? Or perhaps if you would have any suggestion on trying to resolve the above Thread 1: signal SIGABRT issue.

Thanks, I don't have much experience with native code so please let me know if I can provide more info on the issue.

@zoontek
Copy link
Owner

zoontek commented Mar 31, 2020

@zoontek
Copy link
Owner

zoontek commented Mar 31, 2020

If you have issues with other libs, consider reversing the logic of the workaround, it's often easier:

$static_frameworks = [
  # list your permission handlers here
  'Permission-Camera',
  'Permission-Notifications'
]

pre_install do |installer|
  installer.pod_targets.each do |pod|
    if $static_frameworks.include?(pod.name)
      puts "Link #{pod.name} as static_library"
      def pod.build_type;
        # Uncomment one line depending on your CocoaPods version
        # Pod::BuildType.static_library # >= 1.9
        # Pod::Target::BuildType.static_library # < 1.9
      end
    end
  end
end

@divyanshu013
Copy link
Author

Thanks @zoontek. I'd tried the other workaround (step 4). I'll try your above suggestion and see if it works.

On a side note, can I continue using v1.2 with react native 0.61 (since it requires a lot of changes in our permissions service)?

@divyanshu013
Copy link
Author

I tried the alternative approach you suggested @zoontek but it's throwing some errors which look like:

Undefined symbol: _OBJC_CLASS_$_RNPermissionHandlerMicrophone and so on for other permissions

image

Here's my podfile just in case:

project 'applicant', 'Debug' => :debug

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '11.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
# TODO: React native upgrade 0.64.1: is this needed
use_frameworks!

$static_frameworks = [
  # list your permission handlers here
  'Permission-Calendars',
  'Permission-Camera',
  'Permission-Contacts',
  'Permission-LocationAlways',
  'Permission-LocationWhenInUse',
  'Permission-MediaLibrary',
  'Permission-Microphone',
  'Permission-Motion',
  'Permission-Notifications',
  'Permission-PhotoLibrary'
]

pre_install do |installer|
  installer.pod_targets.each do |pod|
    if $static_frameworks.include?(pod.name)
      puts "Link #{pod.name} as static_library"
      def pod.build_type;
        # Uncomment one line depending on your CocoaPods version
        # Pod::BuildType.static_library # >= 1.9
        Pod::Target::BuildType.static_library # < 1.9
      end
    end
  end
end

target 'applicant' do
  # React native upgrade 0.64.1: All these libraries below have been removed from the Xcode project file and now live in the Podfile.
  # Cocoapods handles the linking now. Here you can add more libraries with native modules.
  # Pods
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'React-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIOS'
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # 3rd party dependencies required by react-native
  # TODO: React native upgrade 0.61.4: Is this still needed
  # pod 'boost-for-react-native', :git => 'git@github.com:react-native-community/boost-for-react-native.git', :commit => '6bbccdd8146ffb75e1ae5e92472f7affb3375c1c'

  # 3rd party deps
  pod 'CodePush', :path => '../node_modules/react-native-code-push'
  pod 'react-native-calendar-events', :path => '../node_modules/react-native-calendar-events'
  pod 'react-native-camera', path: '../node_modules/react-native-camera'
  pod 'react-native-config', :path => '../node_modules/react-native-config'
  pod 'react-native-contacts', :path => '../node_modules/react-native-contacts'
  pod 'react-native-intercom', :path => '../node_modules/react-native-intercom'
  pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'
  pod 'react-native-slider', :path => '../node_modules/@react-native-community/slider'
  pod 'react-native-uptime', :path => '../node_modules/react-native-uptime'
  pod 'react-native-video', :path => '../node_modules/react-native-video'
  pod 'react-native-webview', :path => '../node_modules/react-native-webview'
  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage'
  pod 'RNLocalize', :path => '../node_modules/react-native-localize'
  pod 'RNSVG', :path => '../node_modules/react-native-svg'
  pod 'react-native-iterable', :path => '../node_modules/react-native-iterable'

   # Any new permissions we need should be added to this section
   permissions_path = '../node_modules/react-native-permissions/ios'

   pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars.podspec"
   pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
   pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts.podspec"
   pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
   pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec"
   pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec"
   pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
   pod 'Permission-Motion', :path => "#{permissions_path}/Motion.podspec"
   pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"
   pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"

  # Required by hypertrack-sdk-react-native
  # As per https://github.com/hypertrack/sdk-react-native#step-2-setup-native-dependencies
  pod 'HyperTrack', '4.0.0-rc.2'

  use_native_modules!
end

post_install do | installer |

  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-config'
      phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
      phase.shell_script = "cd ../../"\
                           " && RNC_ROOT=./node_modules/react-native-config/"\
                           " && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
                           " && export BUILD_DIR=$RNC_ROOT/ios/ReactNativeConfig"\
                           " && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"

      target.build_phases << phase
      target.build_phases.move(phase,0)
    end
    if target.name == 'RNSVG'
      # Workaround for duplicate symbols in RNSVG
      # https://github.com/react-native-community/react-native-svg/issues/579
      target.build_configurations.each do |config|
        config.build_settings['GCC_NO_COMMON_BLOCKS'] = 'NO'
      end
    elsif target.name == 'JustLog'
      # Latest version of JustLog only compiles with Swift version 4
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.0'
      end
    elsif ['GRDB.swift', 'CocoaLumberjack'].include? target.name
      # GRDB and CocoaLumberjack require Swift 4.2
      # https://github.com/hypertrack/sdk-react-native#ios
      # Note: this is redundant with the else statement below
      # but will become useful as we migrate the codebase to swift 5.0
      # https://app.asana.com/0/474532500889635/1132629696711419/f
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.2'
      end
    else
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.2'
      end
    end
  end
end

@zoontek
Copy link
Owner

zoontek commented Mar 31, 2020

@divyanshu013 Did you nuke DerivedData just in case after?

@divyanshu013
Copy link
Author

I ran npx react-native-clean-project --remove-iOS-build --remove-iOS-pods after making the change and then pod install.

@zoontek
Copy link
Owner

zoontek commented Mar 31, 2020

I'm not sure react-native-clean-project delete the DerivedData folder.

@divyanshu013
Copy link
Author

I'll try manually removing the directory and retry a bit later. On a side note, can I continue using v1.2 with react native 0.61 (since it requires a lot of changes in our permissions service)?

@zoontek
Copy link
Owner

zoontek commented Mar 31, 2020

You can. But absolutely no support will be provided for it, and you might encounter issues with App store submissions.

@zoontek zoontek added the duplicate This issue or pull request already exists label Apr 1, 2020
@xue-zhy
Copy link

xue-zhy commented Apr 3, 2020

> I'll try manually removing the directory and retry a bit later. On a side note, can I continue using v1.2 with react native 0.61 (since it requires a lot of changes in our permissions service)?
I have the same problem as you. How did you solve it.

@divyanshu013
Copy link
Author

I wasn't able to resolve the issue after much trying. For now reverted to older 1.2x release since we were using that earlier and also it requires a lot of changes across our permissions service.

I'll come back to this once we've our app working for react native 0.61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants