apache / apache/cordova-node-xcode
pbxProject hasFile returns false for existing file on Windows
- Vorherrschende Sprache
- JavaScript
- Sterne
- 217
- Forks
- 102
- Ø Merge
- 2 T. 3 Std.
- Gemergte PRs (30 T.)
- 6
Beschreibung
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](https://github.com/bycedric/xcode-windows-hasfile-issue) with an example running on Ubuntu, MacOS and Windows that demonstrates this issue. The scenario it's testing is fairly simple:
```js
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](https://github.com/byCedric/xcode-windows-hasfile-issue/runs/1231850644?check_suite_focus=true#step:6:8) and [MacOS](https://github.com/byCedric/xcode-windows-hasfile-issue/runs/1231850677?check_suite_focus=true#step:6:8), but [fails on Windows](https://github.com/byCedric/xcode-windows-hasfile-issue/runs/1231850707?check_suite_focus=true#step:6:8).
There is a workaround, you have to force the `SPLASH_SCREEN_PATH` to always be a posix formatted path. That works on [Linux](https://github.com/byCedric/xcode-windows-hasfile-issue/runs/1231850644?check_suite_focus=true#step:5:8), [MacOS](https://github.com/byCedric/xcode-windows-hasfile-issue/runs/1231850677?check_suite_focus=true#step:5:8), _and_ [Windows](https://github.com/byCedric/xcode-windows-hasfile-issue/runs/1231850707?check_suite_focus=true#step:5:8).
```js
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);
```
Beitragsleitfaden
Rechercherichtung
Beginne mit dem Aufruf von project.hasFile für die referenzierte project.pbxproj und reproduziere ihn anhand des verknüpften plattformübergreifenden Beispiels unter Windows, Linux und macOS. Verfolge, wie der für Windows formatierte SPLASH_SCREEN_PATH geprüft wird, und betrachte das Issue als erledigt, wenn unter Windows eine vorhandene Datei erkannt wird, ohne die anderen Plattformen zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- mobile-dev
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100