ibtoold has race condition creating bundle/[countrycode].lproj dirs
| Originator: | mtauraso | ||
| Number: | rdar://19709175 | Date Originated: | 2/3/2015 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.1.1 |
| Classification: | Reproducible: | Sometimes |
Summary:
When running xcodebuild on a multi-core machine, xcodebuild will spawn multiple instances of ibtool. When initially creating the localized string dirs in a bundle, there is sometimes a race (1-2% of the time on a large project with many bundles, much lower on a small test project).
ibtool launches ibtoold through launchd. If you dtrace ibtoold, you can see it check for existence of these dirs, and then do mkdir. If two ibtoold processes see that the directory does not exist, and then both attempt creation, one mkdir will fail. This will cause the entire compilation run to fail.
We've worked around this by writing a wrapper to ibtool and pre-creating these directories (ignoring error). We patch /Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/IBCompilerPlugin.xcplugin/Contents/Resources/IBCompiler.xcspec to make Xcode run our wrapper before calling ibtool.
Steps to Reproduce:
Building a large project with multiple translations repeatedly with xcodebuild will cause this errors like this to appear in some runs:
/* com.apple.ibtool.errors */
/blarg.xib: error: The file “fr-CA.lproj†couldn’t be saved in the folder “Bundle†because a file with the same name already exists.
Failure Reason: A file with the name “fr-CA.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
Re-running the build universally causes this error to disappear. The directories already exist, so there is no pre-creation race
Expected Results:
Building a project with xcodebuild does not throw spurious errors.
Actual Results:
Version:
Xcode 6.1.1(6A2008a) on OS X 10.10.1 14B25
Notes:
Configuration:
Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
I haven't observed it in 6.3.1 over several thousand runs. If it does exist the probability has reduced greatly for my use case.
If you're still experiencing it, there is a workaround here: https://github.com/mtauraso/ibtool_hack
This issue is still present in Xcode 6.3.1 (6D1002).