I'm reviewing the source code of a react native project, but I'm having issues building it.

After running the following

  1. npm install at the root of the project
  2. pod install at the ios folder

I got the following message in the terminal:

sh: -c: line 0: syntax error near unexpected token `('

sh: -c: line 0: `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' /Users/myUser/dev/ReactExplorerApp(Android)/ios/Pods/RCT-Folly/folly/portability/Time.h'

And when I build the application with XCode, I get the following error message at the Time.h (...Pods/RCT-Folly/folly/portability/Time.h):

Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

The app uses "react-native": "0.66.1". I'm using cocoapods version 1.11.2, node version 14.17.2 and XCode version 13.1

Podfile content:

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

platform :ios, '11.0'

target 'ExplorerApp' do
  config = use_native_modules!
  pod 'GoogleSignIn'
  pod 'RNI18n', :path => '../node_modules/react-native-i18n'
  pod 'react-native-version-check', :path => '../node_modules/react-native-version-check'
  pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs: [
    'FaceDetectorMLKit',
    'BarcodeDetectorMLKit'
  ]

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


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

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_native_modules!
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

I tried many solutions for similar issues, but didn't work. I tried disabling Flipper by commenting it out in the podfile and I also tried changing the target to iOS 12. I also tried installing the pods after removing the podfile.lock and running pod install --repo-update and I also ran pod cache clean --all

I also tried the solution here https://github.com/facebook/react-native/issues/31480 for "react-native": "0.64.1" // or higher but it didn't work for me and I'm not clear on what they refer with "remove the relevant lines from the podfile.lock" if there are still errors.

Edit: [Solution] I got rid of this error by actually running git clone [repo url] in my terminal instead of using Azure DevOps's Clone button that interfaces with VSCode.

5

There are 5 best solutions below

0
On

Had the same issue with MBP M1 2020 and react-native. Solution was to remove the space in my parent directory name. I did not have to do anything else.

0
On

In my case it happened to me that I had a folder with spaces. Something like "react_example 2". Remove that space and execute the following statement:

pod deintegrate
rm Podfile.lock
pod install
0
On

I ran into the same issue with the same errors. The OS target version fix had already been applied by adding the script provided by RN to the Podfile like this:

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

Perhaps this was automated in your RN version or template.

I then found that the error

sh: -c: line 0: syntax error near unexpected token `('

actually came from that workaround script (in node_modules/react-native/scripts/react_native_pods.rb), i.e. its sed -i -e … line, and I eventually figured that the script does not work and throws this error if your absolute path contains characters interpreted by the Shell (due to the path not being quoted properly in the script).

In my case the absolute path contained parentheses, seems yours also did at the time: …/ReactExplorerApp(Android)/….

Solutions I can think of:

  1. Adjust your path to not contain parantheses (simplest solution)
  2. run sed manually, like suggested by @avinash-kannan
  3. fix the shell line in node_modules/react-native/scripts/react_native_pods.rb by adding single quotes around #{time_header} (not recommended as it might get overridden by yarn or npm)
2
On

Navigate to this file => ios/Pods/RCT-Folly/folly/portability/Time.h

Comment this line => typedef uint8_t clockid_t;

Change => _IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0 to _IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_12_0

Updated Answer on June 2022

This can be achieved automatically by adding below line in your pod file under post_install

`sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
0
On

I had the same issue with React native 0.70

System MacBook Pro (13-inch, M1, 2020) Apple M1

I followi the setup https://reactnative.dev/docs/environment-setup

brew install node
-brew install watchman
sudo arch -x86_64 gem install ffi

Solved -- What was causing the issue was my project parent dir has a "space" in it, after creating a new directory in the root (with no spaces) and "npx react-native init app" the app finally builds