【问题标题】:How to deal with Xcode Missing File warning in a Git repository?如何处理 Git 存储库中的 Xcode Missing File 警告?
【发布时间】:2016-12-26 01:05:17
【问题描述】:

我在我的 Xcode 项目中使用 GIT 进行源代码控制。更新 cocoapod 库后,我开始收到如下警告:

file:///Users/NinjaDev/Development/Xcode/NinjaApp/Pods/Alamofire/Source/Download.swift:警告:缺少文件:/Users/NinjaDev/Development/Xcode/NinjaApp/Pods/Alamofire/Source/工作副本中缺少 Download.swift

库已更改,因此 Download.swift 文件不再存在。我提交了该项目并进行了清理和重建,但仍然出现错误。我猜存储库不知道它已被删除,但我对 Git 的内部运作不是很熟悉......解决这个问题并防止它再次发生的正确方法是什么?

编辑:根据 Aspirin2D 的建议,这里是 git 状态。 git log 没有任何异常。

Git 状态

On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   Podfile.lock
    deleted:    Pods/Alamofire/Source/Download.swift
    deleted:    Pods/Alamofire/Source/Manager.swift
    deleted:    Pods/Alamofire/Source/Stream.swift
    deleted:    Pods/Alamofire/Source/Upload.swift
    modified:   Pods/Manifest.lock
    deleted:    Pods/Pods.xcodeproj/xcuserdata/.xcuserdatad/xcschemes/RAMAnimatedTabBarController.xcscheme
    deleted:    Pods/RAMAnimatedTabBarController/LICENSE
    deleted:    Pods/RAMAnimatedTabBarController/RAMAnimatedTabBarController/Animations/BounceAnimation/RAMBounceAnimation.swift
    deleted:    Pods/RAMAnimatedTabBarController/RAMAnimatedTabBarController/Animations/FrameAnimation/RAMFrameItemAnimation.swift
    deleted:    Pods/RAMAnimatedTabBarController/RAMAnimatedTabBarController/Animations/FumeAnimation/RAMFumeAnimation.swift
    deleted:    Pods/RAMAnimatedTabBarController/RAMAnimatedTabBarController/Animations/RotationAnimation/RAMRotationAnimation.swift
    deleted:    Pods/RAMAnimatedTabBarController/RAMAnimatedTabBarController/Animations/TransitionAniamtions/RAMTransitionItemAnimations.swift
    deleted:    Pods/RAMAnimatedTabBarController/RAMAnimatedTabBarController/RAMAnimatedTabBarController.swift
    deleted:    Pods/RAMAnimatedTabBarController/RAMAnimatedTabBarController/RAMBadge/RAMBadge.swift
    deleted:    Pods/RAMAnimatedTabBarController/RAMAnimatedTabBarController/RAMItemAnimationProtocol.swift
    deleted:    Pods/RAMAnimatedTabBarController/README.md
    deleted:    Pods/Target Support Files/RAMAnimatedTabBarController/Info.plist
    deleted:    Pods/Target Support Files/RAMAnimatedTabBarController/RAMAnimatedTabBarController-dummy.m
    deleted:    Pods/Target Support Files/RAMAnimatedTabBarController/RAMAnimatedTabBarController-prefix.pch
    deleted:    Pods/Target Support Files/RAMAnimatedTabBarController/RAMAnimatedTabBarController-umbrella.h
    deleted:    Pods/Target Support Files/RAMAnimatedTabBarController/RAMAnimatedTabBarController.modulemap
    deleted:    Pods/Target Support Files/RAMAnimatedTabBarController/RAMAnimatedTabBarController.xcconfig
    modified:   NinjaApp.xcworkspace/xcuserdata/NinjaDev.xcuserdatad/UserInterfaceState.xcuserstate

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    Pods/Alamofire/Source/SessionDelegate.swift
    Pods/Alamofire/Source/SessionManager.swift
    Pods/Alamofire/Source/TaskDelegate.swift
    Pods/Local Podspecs/UIColor_Hex_Swift.podspec.json
    NinjaApp.xcodeproj/xcuserdata/NinjaDev.xcuserdatad/xcschemes/NinjaData.xcscheme
    NinjaApp.xcodeproj/xcuserdata/NinjaDev.xcuserdatad/xcschemes/NinjaWebservices.xcscheme

no changes added to commit (use "git add" and/or "git commit -a")

编辑 2:我知道发生了什么。当我在 Xcode 中提交时,我删除的文件必须默认未选中。在解决问题的同时,我再次调出提交菜单,果然它只是一堆未经检查的文件。检查它们并再次提交修复了警告。 为什么 Xcode 默认不选中某些文件?

【问题讨论】:

  • 我不认为 xcode 的问题,因为我没有看到文件 project.pbxproj 更改

标签: swift xcode git cocoapods alamofire


【解决方案1】:

警告,可能不是由 git 引起的... 打开终端,;CD 到项目的文件夹;输入“git status”和“git log”,找出源文件发生了什么。并再次检查 Xcode 中的项目设置。告诉我更多细节。

【讨论】:

  • 感谢您的建议。 git 状态显示某些文件未提交......但我通过 Xcode 进行了提交/推送。也许是一个错误,或者我没有正确理解某些东西?
  • 我找到了解决方案,请查看编辑并发表评论。
  • 在我看来,总是使用带有命令行的 git,它清晰易懂
【解决方案2】:

我在使用源代码树时遇到了同样的问题。升级到 swift 3 后,来自不同框架的许多文件都被更改了,我收到了关于它们丢失的警告。在源代码树中,将文件从 unstaged 更改为 staged 会导致警告消失。

【讨论】:

    【解决方案3】:

    对于那些从搜索引擎到达这里的人:

    当这发生在我身上时(Xcode 8.2.1; swift 3),我还注意到有几个文件未被选中。我相信发生的事情是一个文件在 git 中暂存,但在提交之前重命名。

    要修复它,只需打开终端并输入

    git reset HEAD path/to/file.swift
    

    git status 的输出中也对此进行了说明。

    【讨论】:

      猜你喜欢
      • 2012-10-03
      • 1970-01-01
      • 2018-08-02
      • 1970-01-01
      • 2018-02-04
      • 1970-01-01
      • 2011-08-01
      • 1970-01-01
      • 2013-09-04
      相关资源
      最近更新 更多