Skip to content

Cannot ignore auto linking of un-supported library #414

Closed

Description

Environment

System:
OS: macOS 10.15.4
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 3.15 GB / 32.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.2.0 - ~/.volta/tools/image/node/14.2.0/6.14.4/bin/node
Yarn: 1.22.0 - ~/.volta/tools/image/yarn/1.22.0/bin/yarn
npm: 6.14.4 - ~/.volta/tools/image/node/14.2.0/6.14.4/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 27, 28, 29
Build Tools: 27.0.3, 28.0.3, 29.0.0
System Images: android-28 | Google Play Intel x86 Atom, android-R | Google APIs Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_212 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
react-native: Not Found

Issue

I'm first integrated react-native-vector-icons by some manuals steps, since the autolinking is not supported for the macOS platform yet, however, now I'm trying to integrate react-native-navigation and that does require that I do a pod install in the macos directory, but since RNVectorIcons is not supported the entire linking fails.

I tried adding a ignore entry in the react-native.config.js file:

/**
 * This cli config is needed for development purposes, e.g. for running
 * integration tests during local development or on CI services.
 */

const path = require(`path`);
const blacklist = require(`metro-config/src/defaults/blacklist`);

const rnmPath = path.resolve(__dirname, `node_modules/react-native-macos`);

module.exports = {
  resolver: {
    extraNodeModules: {
      'react-native': rnmPath,
    },
    platforms: [`macos`, `ios`, `android`],
    blacklistRE: blacklist([/node_modules\/react-native\/.*/]),
  },
  dependencies: {
    'react-native-vector-icons': {
      platforms: {
        macOS: null,
      },
    },
  },
};

Steps to Reproduce

  1. Modify react-native.config.js like I did above, that is, to ignore vector-icons package
  2. Add react-native-vector-icons via npm or yarn
  3. cd into macOS
  4. do pod install

Expected Behavior

The incompatible package is ignored and the other packages can be linked like normal

Actual Behavior

The pod installation fails and nothing gets installed

Activity

  1. tom-un commented on May 24, 2020

    @tom-un
    Collaborator

    I have actually hit this issue myself. A fix is to contribute to the react-native-vector-icons repo a change to add :osx to its podspec. But if there is a way to override the incompatible packages, I don't know. Eloy Durán (@alloy) : do you know if this is possible?

    Thanks!

  2. alloy commented on May 25, 2020

    @alloy
    Member

    If you don’t need react-native-vector-icons for your macOS target, try explicitly activating it in your Podfile only in your iOS target definition:

    target "my iOS target" do
      pod "react-native-vector-icons" # ...
    end
    
    target "my macOS target" do
      # ...
    end

    If you do need it for macOS, you will have to update its podspec to list :osx support, as @tom-un` said, there’s alas no way around that.

    PS: This PR will make it so dependencies that don’t support :osx don’t get activated in macOS targets when auto-linking react-native-community/cli#1126

  3. ospfranco commented on May 26, 2020

    @ospfranco
    Author

    Eloy Durán (@alloy) doesn't seem to be working, I added the following:

      target 'tempomat-iOS' do
        platform :ios, '9'
        pod 'RNVectorIcons', :podspec => '../node_modules/react-native-vector-icons'
        use_native_modules!
        # Pods specifically for iOS target
      end
    

    and upon pod install I get the following:

    Detected React Native module pods for RNKeychain and RNVectorIcons
    Detected React Native module pod for RNKeychain
    Analyzing dependencies
    [!] There are multiple dependencies with different sources for `RNVectorIcons` in `Podfile`:
    
    - RNVectorIcons (from `../node_modules/react-native-vector-icons`)
    - RNVectorIcons (from `../node_modules/react-native-vector-icons`)
    
  4. alloy commented on May 26, 2020

    @alloy
    Member

    Hmm, that’s not good. I’ll see if I can repro this (or if you can provide a complete Podfile that exhibits the problem, that’d be much appreciated).

  5. ospfranco commented on May 26, 2020

    @ospfranco
    Author

    https://github.com/ospfranco/rn-macos-menubar-template it's pretty much a blank repo, just go into the macos folder and do pod install and you should get the error

  6. alloy commented on May 28, 2020

    @alloy
    Member

    Thanks for the repro, turns out that the issue you’re seeing is because auto-linking code uses :path instead of :podspec, which is what the “different sources” part of the error message is getting at.

    Having said that, changing to :path brings us back to the original problem. One thing you could do, until a new version of the CLI is released, is to hot-patch your CLI installation with this change https://github.com/react-native-community/cli/pull/1126/files/9ef86dde56fa0446ffb53e1526fb9a8c1fc4a2a8#diff-d1800049b92343288bcbc1c484575058R63-R71

  7. ospfranco commented on May 29, 2020

    @ospfranco
    Author

    It's alright I can wait, I already have a workaround, thanks for the support!

  8. ospfranco commented on Oct 17, 2020

    @ospfranco
    Author

    Hey, I just updated to the latest version of react-native-macos, yet this is still happening, any timeline when this change is going to land?

    Thanks for the repro, turns out that the issue you’re seeing is because auto-linking code uses :path instead of :podspec, which is what the “different sources” part of the error message is getting at.

    Having said that, changing to :path brings us back to the original problem. One thing you could do, until a new version of the CLI is released, is to hot-patch your CLI installation with this change https://github.com/react-native-community/cli/pull/1126/files/9ef86dde56fa0446ffb53e1526fb9a8c1fc4a2a8#diff-d1800049b92343288bcbc1c484575058R63-R71

    That diff is quite large, what exactly am I supposed to copy? there is a change on NativeModules.rb file on line 65 that seems the important one to skip dependencies that are not supported

  9. ospfranco commented on Oct 17, 2020

    @ospfranco
    Author

    Ah, just realized the CLI is a transitive dependency of react-native, when I tried with react-native 0.63 the ignored packages worked correctly, but I'm guessing it won't work with react-native-macos 62... so I guess it is only a matter of waiting until rn-macos adds rn 0.63 as a depedency right?

  10. alloy commented on Oct 21, 2020

    @alloy
    Member

    Yeah, then you’d definitely get the right version. Having said that, you can often update the CLI separately, have you tried that?

  11. ospfranco commented on Oct 22, 2020

    @ospfranco
    Author

    I did not try it, should I just add @react-native-community/cli as a depency?

  12. alloy commented on Oct 22, 2020

    @alloy
    Member

    Yup 👍

  13. ospfranco commented on Feb 15, 2021

    @ospfranco
    Author

    This is working on the latest version

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