如何处理Git存储库中的Xcode Missing File警告?

时间:2016-08-19 00:25:18

标签: swift xcode git cocoapods alamofire

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

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

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

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

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会默认取消选中某些文件?

3 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:2)

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

答案 2 :(得分:0)

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

当我遇到这种情况时(Xcode 8.2.1; swift 3),我也发现有几个文件未经检查。我相信发生的事情是一个文件在git中暂存,但在提交之前重命名。

要解决此问题,只需打开终端并输入

即可
git reset HEAD path/to/file.swift

此注释也在git status的输出中进行。