Cocoapods and the localized string files

Cocoapods is an open-source dependency management tool built with Ruby for the iOS and the Mac OS X platforms. It aims to make the developer’s life easier by downloading/updating/managing/configuring the libraries needed for your project for you. As developer, if you want to add your library to the Cocoapods’ repository, or if you want to manage your local libraries by Cocoapods, you need to create a description file which explains how to manage them. This description file is called a Podspec. There are a tons of tutorial which explains how to write a Podspec file, so I’ll not focus this blog post on this problematic (for more information you can visit this link).

In this article I’m going to show you a proper way to work with the localized string files with Cocoapods in order to avoid any possible collisions with another libraries’ string files.

During the development of the YLMoment library, some people rallied me problems using the YLMoment library and their own localized string files or with another libraries. The issues came from the fact that the YLMoment’s string file names and those of another shared the same name (here Localizable.strings) and by the way one of the localized string file was ignored.

To avoid this problem, a good practice is to bundled your strings files and use the library’s name as bundle name. In this way you will avoid the collision between the localized strings into your application. Here an example to show you how achieve this with Cocoapods and the Podspec file:

# If your library needs to work on both iOS and Mac OS X platforms,
# you'll need to specify two distinct bundle as following:
# iOS
s.ios.resource_bundle = { 'YLMoment-iOS' => ['YLMoment/Localization/*.lproj'] }
# Mac OS X
s.osx.resource_bundle = { 'YLMoment-OSX' => ['YLMoment/Localization/*.lproj'] }
I hope it has been helpful, and if you have any question please leave a comment. 🙂
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)


Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  1. Siddarth · February 25, 2014

    How you able to generate different .strings files for different language?

  2. Siddarth · February 25, 2014

    Ok that was quite dumb of me. Got it.

  3. Pingback: Pod install warning : is a member of multiple groups - BlogoSfera