使 iPhone 模拟器在文件访问时区分大小写

发布于 2024-11-05 18:08:49 字数 137 浏览 3 评论 0原文

众所周知,在 iPhone 模拟器中访问文件时,字符的大小写并不重要。是否可以设置 iPhone 模拟器不忽略大小写?

否则,我可以将代码中的文件路径与磁盘中的文件路径进行比较。那么使用什么方法可以从代码中获取与文件路径相对应的真实文件路径呢?

It's known that when accessing files in iPhone simulator the case of chars doesn't matter. Is it possible to setup iPhone Simulator to not ignore cases?

Otherwise I can compare file path from my code with file path from disk. Then what method to use to get real file path with right cases corresponding to file path from code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼睛会笑 2024-11-12 18:08:49

我在构建阶段使用脚本解决了:

echo "list all files in [$FULL_PRODUCT_NAME]"
cd "$CODESIGNING_FOLDER_PATH"
find . -type f > "$CODESIGNING_FOLDER_PATH"/filelist.txt

并添加了一些代码来查找 filelist.txt 中的文件路径:

BOOL file_found = NO;
for (NSString* file_path in AllFilesList) // AllFilesList keeps list from allfiles.txt
{
    if ([file_path rangeOfString: relPath].location == 2) // 2 because all paths start with './'
    {
        file_found = YES;
        break;
    }
}
if (!file_found)
{
    NSLog (@"!!! ERROR !!! file not found: [%@]", relPath);
    for (NSString* file_path in AllFilesList)
    {
        if ([file_path rangeOfString: relPath options: NSCaseInsensitiveSearch].location == 2)
        {
            NSLog (@"   corresponding file may be: [%@]", relPath);
            break;
        }
    }
}

I solved with script on build phase:

echo "list all files in [$FULL_PRODUCT_NAME]"
cd "$CODESIGNING_FOLDER_PATH"
find . -type f > "$CODESIGNING_FOLDER_PATH"/filelist.txt

And added some code to find file path in filelist.txt:

BOOL file_found = NO;
for (NSString* file_path in AllFilesList) // AllFilesList keeps list from allfiles.txt
{
    if ([file_path rangeOfString: relPath].location == 2) // 2 because all paths start with './'
    {
        file_found = YES;
        break;
    }
}
if (!file_found)
{
    NSLog (@"!!! ERROR !!! file not found: [%@]", relPath);
    for (NSString* file_path in AllFilesList)
    {
        if ([file_path rangeOfString: relPath options: NSCaseInsensitiveSearch].location == 2)
        {
            NSLog (@"   corresponding file may be: [%@]", relPath);
            break;
        }
    }
}
春庭雪 2024-11-12 18:08:49

您向 Apple 报告了该错误吗? iPhone 模拟器应该像设备一样区分大小写。

Did you report the bug to Apple? iPhone simulator should be case sensitive the same way the devices are.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文