You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on May 20, 2025. It is now read-only.
"Something went wrong while linking. Error: Cannot read property 'match' of undefined" #1085
After upgrading from 5.1.3-beta, I did a unlink and link. Error on react-native link react-native-code-push, cli output pasted below.
Steps to Reproduce
yarn add react-native-code-push@5.2.0-beta
react-native unlink react-native-code-push
react-native link react-native-code-push
Expected Behavior
What you expected to happen?
Link without error
Actual Behavior
$ react-native link react-native-code-push
? What is your CodePush deployment key for Android (hit <ENTER> to ignore) ...
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
Please file an issue here: https://github.com/facebook/react-native/issues
Cannot read property 'match' of undefined
Environment
react-native-code-push version: 5.2.0-beta
iOS/Android/Windows version: iOS
Does this reproduce on a debug build or release build? Release
Does this reproduce on a simulator, or only on a physical device? Both
$ 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
CodePush isn't support unlink command - only link. Using this command may lead to possible errors as you mentioned here. If you want to remove react-native-code-push from application you need to do it manually.
So I am closing this, please let us know if any updates.
Also it's worth mentioning that the issue relates more to react-native link functionality itself rather then what code-push does. Meaning here that it reproduces with other plugins as well as you have already pointed above.
At least in our case, this was related to our Podfile. If you're using cocoapods, react-native link now (react/react-native#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.
Erlend Halvorsen (@erlendfh) in my Podfile, I only have a single target reference in form of target '<project-name>' do, so I don't believe this is the issue. Also, prior CodePush versions had no issue with cocoapods.
Ruslan Bikkinin (@ruslan-bikkinin) with that said re: prior CodePush versions had no similar issues, even when It's my standard practice to unlink and relink to ensure package is properly linked after update.
What's changed in CodePush since 5.1.3-beta that may have caused this breakage?
If unlink is not supported as you say, some education appreciated for me then. Do I just yarn add <package>@<version> to update the package, and no need to be concerned about the package linking? Or is there something else to do after the yarn add?
Gary Fung (@fungilation) I would still urge you to investigate the new cocoapods related changes in RN and not look for changes in CodePush to explain this behavior (assuming you've upgraded to RN 0.50). Run react-native link in debug mode and attach a debugger: node --inspect-brk /path/to/react-native link, or add some console.log statements to node_modules/react-native/local-cli/link/pods/[registerNativeModule.js|findLineToAddPod.js|findPodTargetLine.js]
Looking at the code, another option seems to be adding the line # Add new pods below this line at the right place in your Podfile.
Indeed, I haven't seen this before RN 0.50, and I see it in 2 packages: react-native-code-push and react-native-blur. I upgraded both now and without any relinking, my app works fine. So I'm leaving this alone for now, and the issue is like you said, RN's to fix.
Please see #1072 (comment). Is there any way I can completely unlink and uninstall react-native-code-push, so I can do a clean reinstall without bumping into Cannot read property 'match' of undefined? The fact that I can't push any new CodePush version that gets reflected in my app tells me CodePush is just not linked or working in my app.
Gary Fung (@fungilation) have you tried adding # Add new pods below this line to your pod file? I can't guarantee that Cannot read property 'match' of undefined is happening for the same reason in your code base as in ours, but it's the exact same error message I got when installing CodePush, and it was related to a problem with finding the right insertion point in the Podfile. If the problem is with your Podfile, no amount of adding and removing the code push dependency is going to resolve this.
Erlend Halvorsen (@erlendfh) thanks for your suggestion. But what is / how do you determine the "right insertion point" for the # Add new pods below this line line?
This is my /ios/Podfile:
# Uncomment the next line to define a global platform for your project# platform :ios, '9.0'target'[APP]'do# Uncomment the next line if you're using Swift or would like to use dynamic frameworks# Can't use with Firebase pod? https://github.com/invertase/react-native-firebase/issues/252#issuecomment-316340974# use_frameworks!pod'Firebase/Core'pod'RNFirebase',:path=>'../node_modules/react-native-firebase'# http://invertase.io/react-native-firebase/#/installation-ios# pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga" # RN 0.48 and belowpod'yoga',:path=>'../node_modules/react-native/ReactCommon/yoga'# RN 0.49+# https://facebook.github.io/react-native/docs/integration-with-existing-apps.htmlpod'React',:path=>'../node_modules/react-native',:subspecs=>['BatchedBridge',# Required For React Native 0.45.0+?'Core','DevSupport',# Include this to enable In-App Devmenu if RN >= 0.43 fixes https://github.com/facebook/react-native/issues/15775#issuecomment-327971300'RCTText','RCTNetwork','RCTWebSocket',# needed for debugging# Add any other subspecs you want to use in your project]# [OPTIONAL PODS] - comment out pods for firebase products you won't be using.# pod 'Firebase/AdMob'# pod 'Firebase/Crash'# pod 'Firebase/DynamicLinks'pod'Firebase/Auth'pod'Firebase/RemoteConfig'pod'Firebase/Database'pod'Firebase/Firestore'pod'Firebase/Storage'pod'Firebase/Messaging'# Need setup: http://invertase.io/react-native-firebase/#/installation-ios?id=_3-cloud-messaging-optionalpod'Firebase/Performance'# new CocoaPods 1.2.1# [!] Automatically assigning platform ios with version 8.3 on target [APP] because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.platform:ios,'8.3'end
Interesting! react-native link react-native-code-push now inserts a new line pod 'CodePush', :path => '../node_modules/react-native-code-push' below # Add new pods below this line. And link succeeded.
Reacted by FOTOGRAFISKA, anishone, Gustaf, wattsparas and Denis Evgrafov
Reacted by wattsparas and Max L
Reacted by Palfalvi Laszlo Lorand, anishone and wattsparas
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
Activity
ruslan-bikkinin commentedon Nov 22, 2017
Hi Gary Fung (@fungilation) and thanks for submitting the issue.
CodePush isn't support
unlinkcommand - onlylink. Using this command may lead to possible errors as you mentioned here. If you want to remove react-native-code-push from application you need to do it manually.So I am closing this, please let us know if any updates.
max-mironov commentedon Nov 22, 2017
Also it's worth mentioning that the issue relates more to react-native link functionality itself rather then what code-push does. Meaning here that it reproduces with other plugins as well as you have already pointed above.
erlendfh commentedon Nov 22, 2017
At least in our case, this was related to our Podfile. If you're using cocoapods,
react-native linknow (react/react-native#15460) looks for the linetarget '<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.fungilation commentedon Nov 22, 2017
Erlend Halvorsen (@erlendfh) in my Podfile, I only have a single target reference in form of
target '<project-name>' do, so I don't believe this is the issue. Also, prior CodePush versions had no issue with cocoapods.Ruslan Bikkinin (@ruslan-bikkinin) with that said re: prior CodePush versions had no similar issues, even when It's my standard practice to unlink and relink to ensure package is properly linked after update.
5.1.3-betathat may have caused this breakage?yarn add <package>@<version>to update the package, and no need to be concerned about the package linking? Or is there something else to do after the yarn add?ruslan-bikkinin commentedon Nov 23, 2017
Gary Fung (@fungilation) I tried to reproduce your issue even with
unlinkcommand execution and it worked well for me.Nothing special that could affect link command.
Yes you do. Usually you don't need to worry about linking codepush as it just inject codepush initialization in your code.
erlendfh commentedon Nov 23, 2017
Gary Fung (@fungilation) I would still urge you to investigate the new cocoapods related changes in RN and not look for changes in CodePush to explain this behavior (assuming you've upgraded to RN 0.50). Run
react-native linkin debug mode and attach a debugger:node --inspect-brk /path/to/react-native link, or add some console.log statements tonode_modules/react-native/local-cli/link/pods/[registerNativeModule.js|findLineToAddPod.js|findPodTargetLine.js]Looking at the code, another option seems to be adding the line
# Add new pods below this lineat the right place in your Podfile.fungilation commentedon Nov 23, 2017
Indeed, I haven't seen this before RN 0.50, and I see it in 2 packages:
react-native-code-pushandreact-native-blur. I upgraded both now and without any relinking, my app works fine. So I'm leaving this alone for now, and the issue is like you said, RN's to fix.fungilation commentedon Dec 11, 2017
Please see #1072 (comment). Is there any way I can completely unlink and uninstall react-native-code-push, so I can do a clean reinstall without bumping into
Cannot read property 'match' of undefined? The fact that I can't push any new CodePush version that gets reflected in my app tells me CodePush is just not linked or working in my app.erlendfh commentedon Dec 11, 2017
Gary Fung (@fungilation) have you tried adding
# Add new pods below this lineto your pod file? I can't guarantee thatCannot read property 'match' of undefinedis happening for the same reason in your code base as in ours, but it's the exact same error message I got when installing CodePush, and it was related to a problem with finding the right insertion point in the Podfile. If the problem is with your Podfile, no amount of adding and removing the code push dependency is going to resolve this.fungilation commentedon Dec 11, 2017
Erlend Halvorsen (@erlendfh) thanks for your suggestion. But what is / how do you determine the "right insertion point" for the
# Add new pods below this lineline?This is my
/ios/Podfile:erlendfh commentedon Dec 11, 2017
Gary Fung (@fungilation) I'd put it above
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'fungilation commentedon Dec 11, 2017
Interesting!
react-native link react-native-code-pushnow inserts a new linepod 'CodePush', :path => '../node_modules/react-native-code-push'below# Add new pods below this line. Andlinksucceeded.LiuShuoyu commentedon Dec 12, 2017
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