Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
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

Closed

Description

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

  1. yarn add react-native-code-push@5.2.0-beta
  2. react-native unlink react-native-code-push
  3. 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

Reference: react/react-native#16774 (same filed at RN repo, unresolved)

Activity

  1. ruslan-bikkinin commented on Nov 22, 2017

    @ruslan-bikkinin
    Contributor

    Hi Gary Fung (@fungilation) and thanks for submitting the issue.

    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.

  2. max-mironov commented on Nov 22, 2017

    @max-mironov
    Contributor

    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.

  3. erlendfh commented on Nov 22, 2017

    @erlendfh

    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.

  4. fungilation commented on Nov 22, 2017

    @fungilation
    Author

    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.

    1. What's changed in CodePush since 5.1.3-beta that may have caused this breakage?
    2. 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?
  5. ruslan-bikkinin commented on Nov 23, 2017

    @ruslan-bikkinin
    Contributor

    Gary Fung (@fungilation) I tried to reproduce your issue even with unlink command execution and it worked well for me.

    What's changed in CodePush since 5.1.3-beta that may have caused this breakage?

    Nothing special that could affect link command.

    Do I just yarn add @ to update the package, and no need to be concerned about the package linking?

    Yes you do. Usually you don't need to worry about linking codepush as it just inject codepush initialization in your code.

  6. erlendfh commented on Nov 23, 2017

    @erlendfh

    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.

  7. fungilation commented on Nov 23, 2017

    @fungilation
    Author

    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.

  8. fungilation commented on Dec 11, 2017

    @fungilation
    Author

    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.

  9. erlendfh commented on Dec 11, 2017

    @erlendfh

    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.

  10. fungilation commented on Dec 11, 2017

    @fungilation
    Author

    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 below
      pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'   # RN 0.49+
      # https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
      pod '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-optional
      pod '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
  11. erlendfh commented on Dec 11, 2017

    @erlendfh

    Gary Fung (@fungilation) I'd put it above pod 'RNFirebase', :path => '../node_modules/react-native-firebase'

  12. fungilation commented on Dec 11, 2017

    @fungilation
    Author

    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.

  13. LiuShuoyu commented on Dec 12, 2017

    @LiuShuoyu

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions