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

pbxProject hasFile returns false for existing file on Windows #116

Open
byCedric opened this issue Oct 9, 2020 · 0 comments
Open

pbxProject hasFile returns false for existing file on Windows #116

byCedric opened this issue Oct 9, 2020 · 0 comments

Comments

@byCedric
Copy link

byCedric commented Oct 9, 2020

We are running into an issue with this in our Expo CLI on Windows. After some investigation, it looks like there are some issues with Posix and Windows paths when detecting if files exists or not.

I created a repository with an example running on Ubuntu, MacOS and Windows that demonstrates this issue. The scenario it's testing is fairly simple:

const PBX_PROJECT_PATH = path.resolve('ios', 'testios2.xcodeproj', 'project.pbxproj');
const SPLASH_SCREEN_PATH = path.join('testios2', 'SplashScreen.storyboard');

// Create a new pbx project instance
const project = xcode.project(PBX_PROJECT_PATH);
// Now parse the project
project.parseSync();

// Determine if "SplashScreen.storyboard" exists
const file = project.hasFile(SPLASH_SCREEN_PATH);

You see that this is done successfully on both Linux and MacOS, but fails on Windows.

There is a workaround, you have to force the SPLASH_SCREEN_PATH to always be a posix formatted path. That works on Linux, MacOS, and Windows.

const SPLASH_SCREEN_PATH = path.join('testios2', 'SplashScreen.storyboard')
    // Force the path to always be a posix formatted path
    .replace(path.sep, path.posix.sep);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant