Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

searchPaths.filter is not a function, when unlinking #13160

Closed
pvinis opened this issue Mar 27, 2017 · 24 comments
Closed

searchPaths.filter is not a function, when unlinking #13160

pvinis opened this issue Mar 27, 2017 · 24 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@pvinis
Copy link
Contributor

pvinis commented Mar 27, 2017

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
@minhtc
Copy link

minhtc commented Apr 3, 2017

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)"')

@Monte9
Copy link
Contributor

Monte9 commented Apr 12, 2017

@minhtc this worked for me. Thank you!

@mienaikoe
Copy link

@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)

@rocwong-cn
Copy link

+1

@qruzz
Copy link

qruzz commented Jul 8, 2017

@mienaikoe Could you expand on that?
I am looking at that file, but have no idea what I am looking for?

@mienaikoe
Copy link

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)",
);

@qruzz
Copy link

qruzz commented Jul 9, 2017

@mienaikoe Thank you very much for the reply !
Unfortunately, that did not solve the problem for me either ..
All my HEADER_SERCH_PATHS were lists already, but had to change all the LIBRARY_SEARCH_PATHS .. There were however no FRAMEWORK_SEARCH_PATHS in my project, but instead a LD_RUNPATH_SEARCH_PATHS instead, that I also changed into lists.

@kelset
Copy link
Contributor

kelset commented Jul 19, 2017

Keep happening to me as well (0.46.4), anyone found a proper fix for it?

@ugiacoman
Copy link

@kelset Were you able to find a solution? Happening to me as well.

@ugiacoman
Copy link

ugiacoman commented Aug 18, 2017

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

@kelset
Copy link
Contributor

kelset commented Aug 21, 2017

@ugiacoman sorry, not being able to fix it :/ Maybe with 0.48? I'll try to upgrade to latest once it comes out, let's see what happens then

@alexlevy0
Copy link

alexlevy0 commented Oct 5, 2017

Same issue with react-native 0.49.1

react-native unlink lottie-ios
Scanning folders for symlinks in /Users/[...]/node_modules (18ms)
rnpm-install info Unlinking lottie-ios 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

@JperF
Copy link

JperF commented Oct 9, 2017

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.

@stale
Copy link

stale bot commented Dec 8, 2017

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.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 8, 2017
@stale stale bot closed this as completed Dec 15, 2017
@Bernhard---H
Copy link

still there in 0.51.0

@fungilation
Copy link

fungilation commented Jan 5, 2018

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

@adamhaney
Copy link

I'm also seeing this in RN 0.51 is the typical process to re-open an issue or create a new one?

@fungilation
Copy link

@pvinis, re-open please? And this obviously isn't stale as it's still happening.

@wellyshen
Copy link

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

@adamhaney
Copy link

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/ 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?

@macrozone
Copy link

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

@pietro909
Copy link
Contributor

pietro909 commented Mar 23, 2018

Saw now that the alunny/node-xcode moved to apache/cordova-node-xcode, therefore is unmaintained. There they've already fixed it see here.

Need to update the dependency.

New findings: it turns out that the offending package is not even from react-native, thus I think this issue can be closed actually.
This is what I see with npm list xcode

myapp@0.0.1 /myapp/path
├─┬ react-native-code-push@5.2.2
│ └── xcode@0.9.2
├─┬ react-native-sentry@0.30.2
│ └── xcode@1.0.0
└── xcode@0.9.3

@fungilation
Copy link

This keeps happening and is not isolated to any particular library. I'm now on RN 0.54.4 and:

$ react-native unlink react-native-vector-icons
Scanning folders for symlinks in <app>/node_modules (18ms)
rnpm-install info Unlinking react-native-vector-icons ios dependency 
rnpm-install ERR! It seems something went wrong while unlinking. Error: searchPaths.filter is not a function

Re-open this.

@kylevdr
Copy link

kylevdr commented May 4, 2018

0.55.3 and it is still a problem, but as @pietro909 mentioned it appears to be a problem with a dependency, not React Native itself. The same basic fix from @minhtc still works with a few updates:

  • As @ugiacoman mentioned, the location of the file you need to change has been moved
  • There are multiple places the change needs to be applied
  • "$(inherited)" is not the only string that can appear

The current solution:

  1. Open /node_modules/xcode/lib/pbxProject.js
  2. Search for if (searchPaths)
  3. add && Array.isArray(searchPaths) to each match

@facebook facebook locked and limited conversation to collaborators May 15, 2018
peat-psuwit added a commit to peat-psuwit/react-native that referenced this issue Oct 13, 2018
(cordova-node-)xcode 1.0.0 includes a fix for facebook#13160 plus a few more
fixes. This should increase robustness in Xcode project handling
overall.

Fixes facebook#13160.
peat-psuwit added a commit to peat-psuwit/react-native that referenced this issue Oct 13, 2018
(cordova-node-)xcode 1.0.0 includes a fix for facebook#13160 plus a few more
fixes. This should increase robustness in Xcode project handling
overall.

Fixes facebook#13160.
facebook-github-bot pushed a commit that referenced this issue Oct 17, 2018
Summary:
(cordova-node-)xcode 1.0.0 includes a fix for #13160 plus a few more
fixes. This should increase robustness in Xcode project handling
overall.

Fixes #13160.

-------------------------

Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.

_Pull requests that expand test coverage are more likely to get reviewed. Add a test case whenever possible!_
Pull Request resolved: #21766

Reviewed By: codytwinton

Differential Revision: D10384245

Pulled By: hramos

fbshipit-source-id: 488156be67cfc2d99ca81d7cb82747bab35984a7
kelset pushed a commit that referenced this issue Oct 23, 2018
Summary:
(cordova-node-)xcode 1.0.0 includes a fix for #13160 plus a few more
fixes. This should increase robustness in Xcode project handling
overall.

Fixes #13160.

-------------------------

Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.

_Pull requests that expand test coverage are more likely to get reviewed. Add a test case whenever possible!_
Pull Request resolved: #21766

Reviewed By: codytwinton

Differential Revision: D10384245

Pulled By: hramos

fbshipit-source-id: 488156be67cfc2d99ca81d7cb82747bab35984a7
t-nanava pushed a commit to microsoft/react-native-macos that referenced this issue Jun 17, 2019
Summary:
(cordova-node-)xcode 1.0.0 includes a fix for facebook#13160 plus a few more
fixes. This should increase robustness in Xcode project handling
overall.

Fixes facebook#13160.

-------------------------

Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.

_Pull requests that expand test coverage are more likely to get reviewed. Add a test case whenever possible!_
Pull Request resolved: facebook#21766

Reviewed By: codytwinton

Differential Revision: D10384245

Pulled By: hramos

fbshipit-source-id: 488156be67cfc2d99ca81d7cb82747bab35984a7
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging a pull request may close this issue.