Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 737 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Xcode/Swift 'filename used twice' build error

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

The error is as follows.

<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

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?

Many thanks.

---

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.

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

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?

Thanks

Reply

#2
I resolved this twice filename issue with change of Project settings

Here i have attached for project setting changes.

[Legacy build system][1].


[1]:


Hope it will help !!
Reply

#3
I just ran into this issue myself. It was the first time that I was adding a new target to a project.

When you're adding a new target you should click on an existing target and attempt to DUPLICATE it.

You shouldn't create the target from the same template. As that would add a new AppDelegate, ViewController, SceneDelegate, plist, Main.Storyboard and Assets. It would basically add everything that template gives and your project now has 2 of each of those fails. If you then go and add the target to the *existing* AppDelegate then you'll get the error mentioned. The fix is to:

1. Delete all duplicate files
2. As Franck said: Check the file is not included twice in the target's "Build Phases" "Compile Sources" settings. It can happen when you merge project.pbxproj.


If you duplicate, then all you get is a new target and a plist. Once you get those then for every existing file you need to go in its file inspector and add the new target to the list of its targets.
Reply

#4
To check if file is included in compile sources twice without scrolling through hundreds of flies do this:

- select file in Xcode
- go to file inspector on the right panel (top left icon)
- uncheck and check again target checkbox

[![enter image description here][1]][1]


[1]:
Reply

#5


In the case of code data model classes. Select code data model then select the Entity change the value of 'Codegen' to Manual/None.

It helps for me.
Reply

#6
I came across this issue by remove the used twice file from Compile Sources as below image. Selected the file, and click the -. Then clean and build.

[![enter image description here][1]][1]


[1]:
Reply

#7
This can be in your *project.pbxproj* when you make merge with *github* or similar tool.

This can be fix opening the *project.pbxproj* in your favorite text editor and **removing the duplicates declarations**.

Hope that fix your problem.
Reply

#8
I would add on to Josh O'Conners answer in that making the changes he recommended was the root of my problem. I did have to clean the build folder by hitting shift-option-command-k to complete the fix.
Reply

#9
If this is core data related and you are not having Xcode generate the entities for you at build time (you created them manually yourself), and you are experiencing this issue, chances are that you didn't check update the entity in the .xcdatamodelld file. What happens is that Xcode will create a duplicate class of your existing class, since you told Xcode to generate the entity at runtime.
<br><br>In the Data Model Inspector change "Module" to "Current Product Module", and "Codegen" to "Manual/None". <br>
[![enter image description here][1]][1]


[1]:
Reply

#10
Check the file is not included twice in the target's "Build Phases" "Compile Sources" settings.
It can happen when you merge project.pbxproj.
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through