I have an error when initializing a project for React Native. Macbook M1, I've already tried installing through brew and clearing the cache. But I don't understand what the error is, why json file doesn't read or it's not that error.

I've already reinstalled macOS, rm -rf ~/.cocoapods/repos/trunk/ and other things, reinstalled - nothing helps!

✖ Installing CocoaPods dependencies (this may take a few minutes)
error Framework build type is static library
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
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
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

Error

JSON::ParserError - Failed to parse JSON at file: '/Users/mykytakhaliavkin/.cocoapods/repos/trunk/Specs/a/e/a/Flipper/0.232.0/Flipper.podspec.json'.

unexpected token at ''
/Users/mykytakhaliavkin/RN6/vendor/bundle/ruby/2.6.0/gems/cocoapods-core-1.13.0/lib/cocoapods-core/specification/json.rb:66:in `rescue in from_json'
5

There are 5 answers

0
Michil Khabarov On

You need change network. Connect to VPN after run

pod install
0
Marko Rillo On

I had similar issue and Error was raised as JSON::ParserError - Failed to parse JSON at file: '/.cocoapods/repos/trunk/Specs/0/3/5/Firebase/10.16.0/Firebase.podspec.json'

I checked that the JSON was empty at 0 bytes.

The solution was to download the original json file from https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/3/5/Firebase/10.16.0/Firebase.podspec.json to replace the file in my mac.

Thereafter pod install worked out.

Hence, in your case you might also try to replace Flipper.podspec.json file with the original file from the repository and try again with pod install. See if it helps?

1
mihai1990 On

I'm experiencing the same issue, it seems to be an issue other people are experiencing as well - https://github.com/CocoaPods/CocoaPods/issues/12115

The only 2 temporary solutions I found are:

  1. Copy manually the podspec files that are empty (e.g. https://cdn.cocoapods.org/Specs/a/e/a/Flipper/0.232.0/Flipper.podspec.json) to the corresponding location (e.g. ~/.cocoapods/repos/trunk/Specs/a/e/a/Flipper/0.232.0/Flipper.podspec.json) over the empty one.

or

  1. Change the line in Podfile specifying the source from source 'https://cdn.cocoapods.org/' to source 'https://github.com/CocoaPods/Specs.git' (or add it at the top if missing). This way pod install takes longer, but at least it works.
0
Kasun Thilina On

I had the same issue with latest cocoapods(1.14.2) and was able to resolve it by changing my IP to USA ip via VPN. For mac users try "Urban VPN Desktop".

0
AllWorld On

I found the solution, it was problem with ruby version.
See: Solve Mac ruby issues in React native installations