React-native: "Something went wrong while linking. Error: Cannot read property 'match' of undefined"

Created on 9 Nov 2017  Â·  19Comments  Â·  Source: facebook/react-native

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

$ react-native info:

Environment:
  OS: macOS Sierra 10.12.6
  Node: 8.9.1
  Yarn: 1.3.2
  npm: 5.5.1
  Watchman: 4.9.0
  Xcode: Xcode 9.1 Build version 9B55
  Android Studio: Not Found

Packages: (wanted => installed)
  react: 16.0.0 => 16.0.0
  react-native: 0.50.3 => 0.50.3

Target Platform: iOS 11.1

Steps to Reproduce

  1. yarn add [email protected]
  2. react-native link react-native-blur

Expected Behavior

Package linked without error

Actual Behavior

$ react-native link react-native-blur

rnpm-install info Linking react-native-blur android dependency 
rnpm-install info Android module react-native-blur has been successfully linked 
rnpm-install info Linking react-native-blur ios dependency 
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'match' of undefined 
Please file an issue here: https://github.com/facebook/react-native/issues 

Cannot read property 'match' of undefined

Note that I haven't seen a similar error, before RN 0.50 or react-native-blur <= 3.2.0

Issue also reported at https://github.com/react-native-community/react-native-blur/issues/246

Ran Commands Locked

Most helpful comment

If your iOS project is using CocoaPods (contains Podfile) and linked library has podspec file, then react-native link will link library using Podfile. To support non-trivial Podfiles add # Add new pods below this line comment to places where you expect pods to be added.

All 19 comments

same bug with "react-native": "^0.50.3" and react-native link ANYTHING => same bug

rnpm-install info Linking react-native-code-push android dependency 
rnpm-install info Android module react-native-code-push has been successfully linked 
rnpm-install info Linking react-native-code-push ios dependency 
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'match' of undefined 

I did the following and it worked:

step1: remove node_modules
step2: close xcode
step3: cd ios and run pod install (i have use firebase)
step4: react-native link ANYTHING => and OK

I hope it will help you

I get the same error with react-native-keychain when trying to link

rnpm-install info Linking react-native-keychain android dependency 
rnpm-install info Android module react-native-keychain has been successfully linked 
rnpm-install info Linking react-native-keychain ios dependency 
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'match' of undefined 
Please file an issue here: https://github.com/facebook/react-native/issues 

Cannot read property 'match' of undefined

And if I uninstall react-native-keychain, the same happens with react-native-vector-icons:

rnpm-install info Android module react-native-vector-icons is already linked 
rnpm-install info Linking react-native-vector-icons ios dependency 
rnpm-install ERR! Something went wrong while linking. Error: Cannot read property 'match' of undefined 
Please file an issue here: https://github.com/facebook/react-native/issues 

Cannot read property 'match' of undefined

This is my configuration:

Environment:
  OS: macOS Sierra 10.12.6
  Node: 6.10.0
  Yarn: Not Found
  npm: 5.0.3
  Watchman: 4.7.0
  Xcode: Xcode 9.1 Build version 9B55
  Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
  react: 16.0.0-alpha.12 => 16.0.0-alpha.12
  react-native: ^0.50.3 => 0.50.3

Some problem on React-native 0.50.3

At least in our case, this was related to a "problem" with Podfile. If you're using cocoapods, react-native link now (#15460) looks for the line target '<project-name>' do, in the Podfile, to figure out where to add cocoapods dependencies, but we had added additional targets to this list, so it no longer matched.

Note that I'm hitting this issue in 2 packages since upgrading RN to 0.50.3: react-native-code-push and react-native-blur. Without unlink/link however, the packages works fine after upgrades. I haven't looked yet at whether the packages break when installed new and linked, not having been previously installed.

If your iOS project is using CocoaPods (contains Podfile) and linked library has podspec file, then react-native link will link library using Podfile. To support non-trivial Podfiles add # Add new pods below this line comment to places where you expect pods to be added.

@LiuShuoyu in my project there is Pod file with following content:

target 'MyApp'
pod 'Fabric'
pod 'Crashlytics'

and after these lines I need add # Add new pods below this line?

@LiuShuoyu You're fucking brilliant!

Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version?

I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer.

How to Contribute • What to Expect from Maintainers

@LiuShuoyu oh my god, I gave you a thousand likes

@LiuShuoyu You are my daily hero!

You guys can try running react-native upgrade.
After running react-native upgrade, the issue is auto-resolved for me.

In response to @LiuShuoyu comment

I thought comments were meant to make source code more readable and are ignored by the interpreter. There should be another "comment" to warn people that the comment # Add new pods below this line actually means something. Unbelievable.

@LiuShuoyu Doesn't work one bit

In my case, I had changed name of 'app' through XCode but in Podfile it was still target 'app' do. Changing it to target 'codedamn' do worked for me (codedamn is the name I set through XCode)

I updated the react-native version to 0.56.0 and got Cannot read property 'match' of undefined for all node_modules.

Just chiming in to say that as of Nov 2018 @LiuShuoyu 's workaround still does the job. I came here via google search. I can't believe the addition of that comment fixes it.

On React Native 0.57 added this in the podfile worked for me... omg... so i shouldnt mess with the comment anymore?
# Add new pods below this line

Unbelievably this worked for me too. I added

# Add new pods below this line as the first line of my Podfile...

Unbelievable. There must be something in the react-native link command that searches for this specific comment, because the new library was appended immediately after the location of the line.

Have since moved the comment into my shared def that multiple targets all use.

RN 0.57

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anchetaWern picture anchetaWern  Â·  3Comments

madwed picture madwed  Â·  3Comments

DreySkee picture DreySkee  Â·  3Comments

ghost picture ghost  Â·  3Comments

axelg12 picture axelg12  Â·  3Comments