ios - Xcode 12 代码审查编辑器无法打开,因为它无法在源代码管理中找到文件

标签 ios swift xcode git

我有一个主“app”文件夹,它是 git 存储库的根目录。在这里,我有“ios-app”文件夹,其中我的 Xcode xcworkspace 位于“android-app”、“backend”等其他文件夹中。令人惊讶的是,Xcode 确实显示了文件的状态(即 M 表示已修改),而我能够使用 Fetch Changes 菜单选项,但我无法使用 Xcode 提交或在代码审查编辑器中查看文件。
打开代码预览时出错:

The source control operation failed because the file “...” could not be found.
Make sure a valid file exists in the repository and try again.
enter image description here
提交时出错:
The working copy “...” failed to commit files.
error: pathspec 'app/ios-app/DataModel/EventMutations.swift' did not match any file(s) known to git
enter image description here
控制台应用程序中没有什么有趣的,但以下细节可能是相关的:
[MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-17220/IDEKit/CommandsAndSelection/IDEMenuBuilder.m:203
Details:  Unknown submenu: "Xcode.IDEPegasusSourceEditor.MenuDefinition.SourceCodeAuxiliaryEditorMenuItem3" in menu: "Xcode.IDEPegasusSourceEditor.MenuDefinition.Editor"!
Object:   <IDEMenuBuilder>
Method:   +_menuItemForMenuItemElement:inMenuWithIdentifierUsedForDebugging:forViewController:fillingExtensionIdToMenuMap:
Thread:   <NSThread: 0x7fb3aa517540>{number = 1, name = main}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
有一次,我确实将我的文件夹从“iOS-app”重命名为“ios-app”,以排除这可能是 git 区分大小写的情况,我确实运行了 git config --global core.ignorecase true ,但这并不能解决问题。
我还尝试从 Xcode 的“欢迎使用 Xcode”页面中删除该项目并将它们添加回来,以防这影响了 gitpath 的确定方式。
Xcode 中的所有文件路径似乎都是正确的,并且“在文件夹中显示”选项始终有效。
我还可以在源代码管理导航中正确查看 git 项目:
enter image description here

最佳答案

TL;博士:仔细检查本地文件夹和文件的情况是否与远程文件夹和文件的情况相匹配。此外,请仔细检查您的本地项目的区分大小写是否已启用(本地覆盖全局 git 设置),否则, git status 将假装没有任何事情发生。
就我而言,我在本地更名为 iOS-appios-app ,但没有将其推送到远程分支,因此 Xcode 试图找到小写版本并且找不到!
似乎Xcode默认启用了区分大小写,而git可以配置。

  • 启用本地 git 项目的 git 区分大小写:
  • > git config core.ignorecase
    true
    > git config core.ignorecase false
    
  • 检查 git status 现在是否显示了区分大小写的问题:
  • > git status
    
    New files detected:
    
    ios-app/
    android-app/
    
  • 将文件夹重命名为小写并推送。如果你只是做 git mv iOS-app ios-app 现在 git 并没有让这变得容易, 它不会重命名 😡。您需要做的是重命名iOS-app到一些临时名称,然后返回 ios-app .
  • > git mv iOS-app iOS-app-foo
    > git mv iOS-app-foo ios-app
    
    > git add -A
    > git commit -m "Make sure that local and remote have the same case."
    > git push
    
    重新启动 Xcode,您应该一切顺利!

    关于ios - Xcode 12 代码审查编辑器无法打开,因为它无法在源代码管理中找到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64362909/

    相关文章:

    ios - 无法构建动态 NSURL 以将图像放入 UIImage

    ios - 如何将 indexpath.row 移动到新的 View Controller

    ios - 我可以将 UIPageControl 放在 UITableViewController 的表头中吗?

    ios - CGContextDrawImage 仅包含两个图像的交集

    xcode - 如何从 Phonegap/Cordova 项目中删除默认本地化?

    ios - NSURLSessionDownloadTasks 在设备自动锁定或后台事件 30 分钟后停止

    ios - RxSwift 计算变量由 2 个其他变量组合而成

    ios - addArrangedSubview 是重叠 View

    ios - PredictHQ API 上的 "Bad Request"响应 [ "error": invalid_client] "authentication" request

    ios - 保存并重新发送 Alamofire 请求