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

Syntax Error in Setup? #854

Closed thebenfirsty closed 8 months ago

thebenfirsty commented 8 months ago

Before submitting a new issue

Bug summary

Hello,

This could be a stupid question, but I'm really unfamiliar with Podfiles and Ruby syntax, so I'm not at all sure what I'm doing.

I'm following the set up at this link: https://www.npmjs.com/package/react-native-permissions

And after I add the block of code that starts "def node_require(script)", I'm getting this error: [!] Invalid Podfile file: syntax error, unexpected constant, expecting `do' or '{' or '('

I couldn't find anything on Stack overflow and ChatGPT was no help either. I'd appreciate your help, thank you!

Library version

4.1.4

Environment info

System:
  OS: macOS 14.1.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 353.17 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.6.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 33.0.1
      - 34.0.0
    System Images:
      - android-34 | Google APIs ARM 64 v8a
      - android-UpsideDownCakePrivacySandbox | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.2
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.5
    wanted: 0.73.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

  1. Create new react native project
  2. Follow steps 1, 2 and 3 on this tutorial, https://www.npmjs.com/package/react-native-permissions

Reproducible sample code

+ def node_require(script)
+   # Resolve script with node to allow for hoisting
+   require Pod::Executable.execute_command('node', ['-p',
+     "require.resolve(
+       '#{script}',
+       {paths: [process.argv[1]]},
+     )", __dir__]).strip
+ end

+ node_require('react-native/scripts/react_native_pods.rb')
+ node_require('react-native-permissions/scripts/setup.rb')

platform :ios, min_ios_version_supported
prepare_react_native_project!

setup_permissions([
  # 'AppTrackingTransparency',
  # 'Bluetooth',
  # 'Calendars',
  # 'CalendarsWriteOnly',
  # 'Camera',
  # 'Contacts',
  # 'FaceID',
  # 'LocationAccuracy',
  # 'LocationAlways',
  # 'LocationWhenInUse',
  # 'MediaLibrary',
  'Microphone',
  # 'Motion',
  # 'Notifications',
  # 'PhotoLibrary',
  # 'PhotoLibraryAddOnly',
  # 'Reminders',
  # 'Siri',
  # 'SpeechRecognition',
  # 'StoreKit',
])

# 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,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# 
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# 
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

target 'SpanishAI' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    :flipper_configuration => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

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

  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
  end
end
zoontek commented 8 months ago

Open something on StackOverflow if you need help, issues are for reporting problems.

thebenfirsty commented 8 months ago

I figured it out. It was a stupid question, my bad

Akshaybagai52 commented 8 months ago

I figured it out. It was a stupid question, my bad

Hey can you tell me how you fix that I'm also getting same error and new to podfiles

zoontek commented 8 months ago

@Akshaybagai52 Probably that he copy / pasted the + characters from the git diff.

thebenfirsty commented 8 months ago

Correct. Not my finest hour.

On Thu, Mar 14, 2024 at 6:26 AM Mathieu Acthernoene < @.***> wrote:

@Akshaybagai52 https://github.com/Akshaybagai52 Probably that he copy / pasted the + characters from the git diff.

— Reply to this email directly, view it on GitHub https://github.com/zoontek/react-native-permissions/issues/854#issuecomment-1997118377, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDXBV4XWJGBNFKKUZFUVHD3YYF3ONAVCNFSM6AAAAABEJHM3VGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJXGEYTQMZXG4 . You are receiving this because you authored the thread.Message ID: @.***>