zoontek / react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.
MIT License
4.1k stars 836 forks source link

Does this library support development on M1 Macs? #646

Closed nishkohli96 closed 3 years ago

nishkohli96 commented 3 years ago

Bug summary

I'm trying to use this lib on my M1 Mac, here is the error I get when I run yarn ios.

Undefined symbols for architecture x86_64:

"_OBJC_CLASS_$_RNPermissionHandlerLocationAccuracy", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerAppTrackingTransparency", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerNotifications", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerStoreKit", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerSpeechRecognition", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerSiri", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerContacts", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerMediaLibrary", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerMicrophone", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerLocationWhenInUse", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerLocationAlways", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerFaceID", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerPhotoLibraryAddOnly", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerReminders", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerCamera", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerPhotoLibrary", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerMotion", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerCalendars", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)
  "_OBJC_CLASS_$_RNPermissionHandlerBluetoothPeripheral", referenced from:
      objc-class-ref in libRNPermissions.a(RNPermissions.o)

cd: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Library version

3.0.5

Environment info

System:
    OS: macOS 11.5.2
    CPU: (8) x64 Apple M1
    Memory: 26.90 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.5 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.14 - /usr/local/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 26, 27, 28, 29, 30
      Build Tools: 30.0.3
      System Images: android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_282 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.65.1 => 0.65.1 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Did exactly the steps mentioned in the documentation.

Ran app after running npx pod-install and eventually ran into the above error.

Reproducible sample code

Contents of podfile -

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

    pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"
    pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral"
    pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars"
    pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
    pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts"
    pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID"
    pod 'Permission-LocationAccuracy', :path => "#{permissions_path}/LocationAccuracy"
    pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways"
    pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
    pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary"
    pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
    pod 'Permission-Motion', :path => "#{permissions_path}/Motion"
    pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
    pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
    pod 'Permission-PhotoLibraryAddOnly', :path => "#{permissions_path}/PhotoLibraryAddOnly"
    pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders"
    pod 'Permission-Siri', :path => "#{permissions_path}/Siri"
    pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition"
    pod 'Permission-StoreKit', :path => "#{permissions_path}/StoreKit"
zoontek commented 3 years ago

I don't have a mac M1, but I don't see why it should cause any issue.

cd: symbol(s) not found for architecture x86_64

M1 is an ARM processor, maybe the command ran by yarn run-ios is wrong? Which version of react-native are you using? Does it works if you open Xcode, clean the project build and run it from it instead?

mikehardy commented 3 years ago

This is subtle. The library works with M1. I've been working hard to clean up all the m1 build stuff for upcoming react-native 0.66 and it's possible to get it all to work but it's not easy. If you're on m1 I strongly recommend checking the react-native-firebase tests directory and looking at our Podfile. I maintain that and it's the best known combo of hacks to make things work on m1 and Intel Mac for debug and release mode, I keep it updated as it's how I prove out the work we're doing for the next release. Checking it's recent history of commits may be useful as well. The arch settings in particular may help this error

nishkohli96 commented 3 years ago

All right, thanks for your support

mikehardy commented 3 years ago

Of note also (now that I am on a real computer and can toss links around) is this specific comment which shows what that magic xcode workaround call is in the react-native-firebase Podfile: https://github.com/facebook/react-native/issues/31480#issuecomment-910019812 and you may also like https://github.com/facebook/react-native/issues/31941

Dassine commented 2 years ago

@mikehardy did you have a chance to fix this?

mikehardy commented 2 years ago

@Dassine fix what exactly? M1s work fine as far as I know. You'll want a modern react-native (0.66 or higher) and you'll want this https://github.com/facebook/react-native/blob/ac206aa814c3c60eac86c2361c06f1aa41d8e85c/template/ios/Podfile#L34

But I don't currently have any M1 related issues.

Dassine commented 2 years ago

@mikehardy thank you for quick answer. I'm getting the Undefined symbols for architecture x86_64 and this using RN 0.66

Dassine commented 2 years ago

I already added __apply_Xcode_12_5_M1_post_install_workaround(installer)

Dassine commented 2 years ago

@mikehardy do you see something wrong in my 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'

abstract_target 'Roo' do
  config = use_native_modules!

    # React Native Maps dependencies
    rn_maps_path = '../node_modules/react-native-maps'
    pod 'react-native-google-maps', :path => rn_maps_path

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

  target 'RooMobile' do
    #Production-specific pods
        pod 'RNSVG', :path => '../node_modules/react-native-svg'

        permissions_path = '../node_modules/react-native-permissions/ios'   
        pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"

        pod 'RNDateTimePicker', :path => '../node_modules/@react-native-community/datetimepicker'

        pod 'react-native-date-picker', :path => '../node_modules/react-native-date-picker'

        target 'RooMobileTests' do
            inherit! :complete
            # Pods for testing
        end
    end

  target 'RooMobile-staging' do
    #Staging-specific pods
  end

  target 'RooMobile-dev' do
    #Development-specific pods
  end

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

  post_install do |installer|
    react_native_post_install(installer)
        __apply_Xcode_12_5_M1_post_install_workaround(installer)
    installer.pods_project.build_configurations.each do |config|
          config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end
end
Dassine commented 2 years ago

@mikehardy solved it. I needed to add

permissions_path = '../node_modules/react-native-permissions/ios'   
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"

under my other targets.