Xcode / Swift'文件名使用两次'构建错误 [英] Xcode/Swift 'filename used twice' build error

查看:1298
本文介绍了Xcode / Swift'文件名使用两次'构建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Swift的新手,在我(可能)通过CocoaPods正确安装了第三方框架后,我正在努力解决错误。

I'm new to Swift and am struggling with an error after I have (possibly) correctly installed a 3rd party framework via CocoaPods.

错误如下。

<unknown>:0: error: filename "MainController.swift" used twice: '/Users/myname/Desktop/ProjectName/ProjectName/Controllers/MainController.swift' and '/Users/myname/Desktop/ProjectName/ProjectName/Controllers/MainController.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

据我可以从其他论坛收集而且看似显而易见的是我必须删除两次使用的文件之一。但是,我无法看到它们将被安装两次。如果我从/ Controllers文件夹中删除该文件,则错误变为找不到文件等。

As far as I can gather from other forums and seemingly obvious is that I have to remove one of the files being used twice. However I can't see where they would be installed twice. If I remove the file from the /Controllers folder the error becomes 'file not found' etc.

所以我的问题是,这些冲突文件的位置在哪里以及如何定位我安全地删除了其中一个?或者更多的是,只有一个文件,但它被使用了两次 - 在这种情况下我该如何阻止它?

So my question is, where would these conflicting files be located and how do I safely remove one of them? Or is it more that there is only one file but it is being used twice - in which case how do I stop that?

非常感谢。

好的我觉得评论不见了所以我在这里澄清是否可以触发答案因为昨天无法构建和运行。

Ok I feel that comments are getting lost so am clarifying here to see if can trigger an answer as not been able to build and run this since yesterday.

我现在只有Pods-> Pods / MainController文件夹中的swift文件。

I now have only the swift files in the Pods->Pods/MainController folder.

当我我找不到找到的文件。但是它要查找的文件位于App-> Controllers文件夹中,这是我从中删除的文件。如果我把文件放在那里我会得到'二次使用'错误。

When I build I get a file not found. However the file it is looking for is in App->Controllers folder which is where I deleted it from. If I put the file in there I get the 'used twice' error.

那么如何阻止它试图在控制器中找到该文件并在豆荚?

So how do I stop it trying to find the file in the Controllers and look for it in the Pods?

谢谢

推荐答案

尝试搜索,如果你添加了相同的ViewController - MainController.swift 两次。

Try to search, if you have added same ViewController - MainController.swift twice.

如果没有,则搜索类代码库中的MainController

关于Pods,最好使用所有Pod作为框架,

Regarding Pods, it is preferred to use all Pods as frameworks,

所以尝试使用'use_frameworks!'在你的 Podfile 中,然后从终端重新安装pod pod install

So try using 'use_frameworks!' in your Podfile, and then from terminal reinstall the pods "pod install".

这篇关于Xcode / Swift'文件名使用两次'构建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆