17

When building the project for distribution using the Archive build mode, the following error appears. When building in debug or release mode everything works fine. The mentioned directory is empty. The directory permissions are set to full access for the current user. Any ideas?

CopyStringsFile /Users/username/Library/Developer/Xcode/DerivedData/ProjectName-bikjmxotbfpkybhkqwlxysxcibrk/ArchiveIntermediates/ProjectName/InstallationBuildProductsLocation/Applications/ProjectName.app/es.lproj/Localizable.strings ProjectName/Resources/es.lproj/Localizable.strings
cd /Users/username/Coding/proj/game/ProjectName
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin"
builtin-copyStrings --validate --inputencoding utf-8 --outputencoding binary --outdir /Users/username/Library/Developer/Xcode/DerivedData/ProjectName-bikjmxotbfpkybhkqwlxysxcibrk/ArchiveIntermediates/ProjectName/InstallationBuildProductsLocation/Applications/ProjectName.app/es.lproj -- ProjectName/Resources/es.lproj/Localizable.strings

error: failed to remove /Users/username/Library/Developer/Xcode/DerivedData/ProjectName-bikjmxotbfpkybhkqwlxysxcibrk/ArchiveIntermediates/ProjectName/InstallationBuildProductsLocation/Applications/ProjectName.app/es.lproj/Localizable.strings: “Localizable.strings” couldn’t be removed.
pletoss
  • 323
  • 1
  • 2
  • 11
  • #NoelHunter is right, it was duplicate file in different group. – Adeel Pervaiz May 06 '13 at 10:57
  • As an FYI, I believe the reason this causes this particular error is because the build process is multithreaded, and the destination for the duplicate files is the same. So the first thread deletes the file and prepares to copy it, then the second thread tries to delete the same destination, which obviously fails. – Tim Keating Mar 08 '14 at 00:59

8 Answers8

11

This happened to me when I had duplicate references to a folder added to the project. Deleting the duplicate references fixed it.

NoelHunter
  • 996
  • 9
  • 17
8

Ok, i figured it out:

I don't exactly know why Xcode wanted to delete a file that wasn't existent at that location in the first place, but it think it had to do with the project file which was broken for no apparent reason.

The way i fixed it was to just delete all the Localizable.strings files from the project ( i had 6 for different languages each in its own .lproj directory ) and then add them again one by one. –

pletoss
  • 323
  • 1
  • 2
  • 11
6

I also face this type of problem. But what I did is just clean up project "Product -> Clean" and rebuild it fix this problem

user454083
  • 1,337
  • 3
  • 16
  • 31
  • Apple should add Xcode as an example to their crappy documentation on how not to create an application. Xcode is a piece of crap. Thanks for your answer. It did the trick. – Duck May 15 '16 at 13:45
2

I had the same problem and simply cleaning didn't fix it.

I have multiple Build Configurations set up in order to output different apps with different bundle identifiers and a custom script that copies some files. When creating new Build Configurations with new custom files, these files were automatically added to the "Copy Bundle Resources" Build Phase when my script was already taking care of them.

So what I needed to do was simply to remove them from the Copy Bundle Resources list in MyTarget > Build Phases.

now
  • 4,772
  • 2
  • 24
  • 26
2

Please check this before trying other mentioned steps :- In my case it was the disk space. I had to free up some space before running it again.

Zeeshan Ansari
  • 1,413
  • 12
  • 21
2

I had the same problem ... anyway, these 2 steps definitely solved it:

  1. Make sure the Localizable.strings files are encoded in UTF-16 instead of UTF-8. So if you need to convert them you can do it in XCode by choosing the files and changing the Text Encoding to UTF-16 in the File Inspector

  2. remove the references to the files from your project and re-add them. This should fix the CopyStringsFile error.

Mobiletainment
  • 22,201
  • 9
  • 82
  • 98
1

I had same problem: “Localizable.strings” couldn’t be removed. It occurred almost randomly -> when you try to build whole project (after switching git branches or cleaning project) -> Copying Localizable.strings files. I had 4 localisations in my app.

I have tried all mentioned solutions but none of them helped me: 1) project was set up correctly 2) UTF-8 is recommended by Apple itself (https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html).

Finally I found one more thing. It turned out that my generated (used fastlane poeditor_export plugin) Localizable.strings file had no last line (CR symbol). Added LF (new line feed) symbol to the end of file and build process stopped throwing error.

File was not compliment with POSIX standard (http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206).

Hope this will be helpful to someone ;)

BTW, same issue thread: Localizable.strings error - compiler says file is missing

Community
  • 1
  • 1
0

In my case my .string file was referenced at different location in Xcode sidebar but its actual disk location in computer was different. I moved the file to the referenced location (as same in Xcode) in my computer and it worked well.

Ankush
  • 2,405
  • 3
  • 22
  • 45