react-native: searchPaths.filter is not a function, when unlinking

Description

i tried unlinking a library and i got an error

react-native unlink react-native-video
Scanning 870 folders for symlinks in /Users/pvinis/Source/mycujoo/mycujoo-mobile/node_modules (9ms)
rnpm-install info Unlinking react-native-video ios dependency
rnpm-install ERR! It seems something went wrong while unlinking. Error: searchPaths.filter is not a function

searchPaths.filter is not a function

Reproduction Steps and Sample Code

try to link and then unlink a library i guess.

Solution

no idea.

Additional Information

  • React Native version: 0.42.3
  • Platform: iOS
  • Development Operating System: MacOS
  • Dev tools: Xcode

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 20
  • Comments: 24 (2 by maintainers)

Commits related to this issue

Most upvoted comments

my quick fix: file: /node_modules/react-native/node_modules/xcode/lib/pbxProject.js line 1146: change the condition from if(searchPaths) to if (searchPaths && searchPaths !== '"$(inherited)"')

hey @qruzz . It’s been a while, but I think I remember what I was talking about:

Somewhere near the bottom of the file, you’ll have your build configurations. In here there are several build settings, including HEADER_SEARCH_PATHS, FRAMEWORK_SEARCH_PATHS, and LIBRARY_SEARCH_PATHS. react-native unlink seems to be expecting these to be lists in all cases, but many projects just have one value as in

HEADER_SEARCH_PATHS = "$(inherited)"

Instead, as a workaround, you should make them into a list:

HEADER_SEARCH_PATHS = (
	"$(inherited)",
);

I change the follow bit of code in the /node_modules/xcode/lib/pbxProject.js

if (searchPaths) {
            var matches = searchPaths.filter(function(p) {
                return p.indexOf(new_path) > -1;
            });
            matches.forEach(function(m) {
                var idx = searchPaths.indexOf(m);
                searchPaths.splice(idx, 1);
            });
        }

to

if (searchPaths) {
            if(typeof searchPaths === 'string'){
                searchPaths = [searchPaths]
            }
            var matches = searchPaths.filter(function(p) {
                return p.indexOf(new_path) > -1;
            });
            matches.forEach(function(m) {
                var idx = searchPaths.indexOf(m);
                searchPaths.splice(idx, 1);
            });
        }

and it seemed to have fixed the issue as well.

Confirmed on RN 0.51, when running $ react-native unlink react-native-sentry:

It seems something went wrong while unlinking. Error: searchPaths.filter is not a function

can confirm this still happens in react-native 0.53! its neither stale nor fixed. Please re-open

@minhtc solution worked, but the file was at /node_modules/xcode/lib/pbxProject.js react-native 0.47.1

still there in 0.51.0

After a bit of detective work (threw console.log statements throughout /node_modules/xcode/lib/pbxProject.js to see what part of the project file it was choking on) it seems like the installer was expecting my project to have a ‘Plugins’ group that I didn’t have, I created an empty one in the project. My top level project groups now look like this:

screen shot 2018-01-26 at 9 32 40 am

I also opened up ios/<ProjectName> and made sure that every variable that ended in *_SEARCH_PATHS was a list, it appears like xcode uses a string for single element lists, so I just wrapped parenthesis around those variables, after that I ran react-native unlink and react-native link again without issue.

Perhaps the xcode library needs to be patched and/or there needs to be some exception handling for missing groups / lists that only have a single entry that are being treated as strings?

Please re-open it. I also encounter this issue when I run $ react-native unlink react-native-sentry

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@minhtc I didn’t find this js file. Instead, I made all of the framework, header, and library search paths in ios/<projectName>.xcodeproj/project.pbxproj a list. Some of them were individual strings, but you can list them by surrounding the one string with (parentheses)