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

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

问题描述

我是 Swift 的新手,并且在我(可能)通过 CocoaPods 正确安装了 3rd 方框架后遇到了错误.

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.

那么如何阻止它尝试在控制器中查找文件并在 Pod 中查找它?

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.

如果没有,则在代码库中搜索class MainController.

If not, then search class MainController in codebase.

关于Pods,优先使用所有Pods作为框架,

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

因此,请尝试在您的 Podfile 中使用 'use_frameworks!',然后从终端重新安装 Podpod install".

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

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

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