apache / apache/cordova-node-xcode
pbxProject hasFile returns false for existing file on Windows
- 主要语言
- JavaScript
- 星标
- 217
- 派生
- 102
- 平均合并
- 2 天 3 小时
- 30 天内合并 PR
- 6
描述
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);
```
贡献指南
调研方向
从针对所引用的 project.pbxproj 的 project.hasFile 调用开始,并使用链接的跨平台示例在 Windows、Linux 和 macOS 上复现它。跟踪 Windows 格式的 SPLASH_SCREEN_PATH 是如何被检查的,并在 Windows 上检测到现有文件且不影响其他平台时,认为 issue 已完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- mobile-dev
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100