Troubleshooting Xcode 6 âfile already existsâ XIB build errors
May 15, 2015When implementing foreign language localization on an existing app project, we ran into a problem with our Continuous Integration build server, and I thought Iâd share what we found and the workaround required to solve it.
Localizing with Xcode 6
The project includes a few dozen XIB files that all contained strings that needed to be localized. Xcode 6 introduced some new features to streamline the process of extracting all the strings from a project. You can now export all strings in to one .xliff (XML Localisation Interchange File Format) file, give that to your translator, then import the file to apply the localized strings to your code and the individual XIB files. We did not receive all of the translations at once, and during the process of integrating and editing the localized strings, we started getting build failures on our server. It uses a vendor-supplied plug-in that automates the xcodebuild tool and numerous shell scripts to provide an .ipa file which can be uploaded to HockeyApp, our service for distributing tests builds amongst employees and to clients.
CompileXIB error in xcodebuild {.p1}
Inspecting the build logs we found the error was occurring on 2 to 4 XIB files that had been localized. This was the error message.
Base.lproj/BottomButtonBar.xib: error: The file 'es.lproj' couldn't be saved in the folder 'MyProject' because a file with the same name already exists. Failure Reason: A file with the name 'es.lproj' already exists. Recovery Suggestion: To save the file, either provide a different name, or move aside or delete the existing file, and try again. Underlying Errors: Description: The operation couldn't be completed. File exists Failure Reason: File exists
Our build server is configured to clean the project every time it performs a build so this error didnât make any sense. Hereâs the things that we tried:
- Create a new Git branch, thereby ensuring a fully clean build is performed. Got the same error but sometimes DIFFERENT XIB files.
- Revert to a previous commit (weâd had some obnoxious xcodeproj/project.pbxproj merge conflicts) and redo the merge. No change.
- Manually check the ObjectIDs for the UI widgets being translated. They all matched up.
The really frustrating thing was that building on a local workstation with the command line xcodebuild tool WORKED! We were getting stumped. Google searches were not providing any help, either.
Apple Developer Forum to the rescue {.p1}
I hit the Apple forum at first searching through unhelpful Xcode and xcodebuild messages. Then I finally came across this post (note: account required for access) by Mr. Olivier Destrebecq:
Note that after a few hours of trial and error, i figured out that if i set xcodebuild to only build one file at a time, then this error pretty much disappear
so pass -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=1 as an option xcodebuild seem to fix the issueI opened a bug with apple.
That build argument is not documented anywhere, as far as I can tell. I had already checked the man page and the Xcode Build Setting Reference and never ran across it. Maybe our build server is just a little too slow, but regardless, this fixed the build error. Your command line invocation of xcodebuild will end up looking something like this:
xcodebuild clean build -sdk iphoneos8.3 -workspace MyProject.xcworkspace -scheme MyProject-Adhoc -configuration AdHoc -derivedDataPath $BUILD_PATH -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=1
-IDEBuildOperationMaxNumberOfConcurrentCompileTasks=1 {.p1}
You may never run across âFailure Reason: A file with the name âes.lprojâ already exists.â
in your Project but if you ever do I hope this helps you out. Now to go order some upgrades for the serverâŠ
Looking for more like this?
Sign up for our monthly newsletter to receive helpful articles, case studies, and stories from our team.
![Between the brackets: MichiganLabsâ approach to software development](https://gratis-creeper.transforms.svdcdn.com/staging/blog/approach-to-software-development-thumbnail_2024-02-15-200634_fdwn.png?w=1200&h=1200&auto=compress%2Cformat&fit=crop&dm=1708027595&s=b1cfebad3bdfb518b25297b50603c688)
Between the brackets: MichiganLabsâ approach to software development
February 12, 2024 Read more![Cross tab navigation in Jetpack Compose](https://gratis-creeper.transforms.svdcdn.com/staging/blog/Jetpack-compose-thumbnail.png?w=1080&h=1080&auto=compress%2Cformat&fit=crop&dm=1714051834&s=7ebbaffd42987a5ad4b87e65b2fcefb2)
Cross tab navigation in Jetpack Compose
October 4, 2022Learn how to use Android's Jetpack Compose to navigate from a screen inside of one NavigationBarItem to another.
Read more![Three principles for creating user-friendly products](https://gratis-creeper.transforms.svdcdn.com/staging/blog/Three-principles.jpg?w=696&h=320&q=75&auto=format&fit=crop&dm=1708017686&s=4b6b726c71c183e97216b75f1ab9e0ec)
Three principles for creating user-friendly products
January 25, 2023Grayson discusses three guiding principles he utilizes when designing user experiences for products.
Read more