Category: CocoaPods

Why does the iOS App Store show more languages than my app supports?

By default, the languages of an app are listed in info.plist by setting the values for the properties list key CFBundleLocalizations. A definition as shown below should result in supported languages English and German.

	<key>CFBundleLocalizations</key>
	<array>
		<string>en</string>
		<string>de</string>
	</array>

But when looking at the AppStore, the languages shown there do not always correlated with this setting. The reason is that the languages shown on the AppStore are generated automatically based on the localized *.lproj folders found in your app.

Normally those folders should be in sync with your properties list setting. But when you use third party libraries (e.g. with CocoaPods) additional localizations might be loaded into your app. In this case, all *.lproj folders found in your app and in the pods are used for language determination.

How to correct the languages?

There is a plugin for that: cocoapods-prune-localizations, which can be simply added to your Podfile. When running pod install, this script will remove all localized files from pods or just keep the specified languages. To install the script, run:

gem install cocoapods-prune-localizations

Then add the following lines to your Podfile:

plugin 'cocoapods-prune-localizations'

Localizations will be inferred from your project.

or if you would prefer to specify the localizations:

plugin 'cocoapods-prune-localizations', {:localizations => ["en", "es"]}

This will keep the English and Spanish localizations in the Pods. Modify the localizations to your needs.

Photo by Etienne Girardet on Unsplash

 

 

CocoaPod Workflow – eine Zusammenfassung

Eine auswführliche Beschreibung, wie man von Grund auf einen CocoaPod erstellt, findet sich unter https://guides.cocoapods.org/making/making-a-cocoapod.html. Ist der CocoaPod erstellt, dann lassen sich Updates mit wenigen Befehlen einpflegen. Hier nun die wichtigsten Schritte:

Zum Testen des Quelltextes:

$ pod lib lint

Vor dem Veröffentlichen zunächst die Versionsnummer anpassen. Dazu die .podspec bearbeiten:

# Versionsnummer anpassen
spec.version      = "0.0.1"
# Tag anpassen
spec.source       = { ... :tag => "0.0.1" }

Hinweis: Wenn der Tag in spec.source als Variable angegeben wird, dann ist es nicht notwendig, diesen immer wieder anzupassen. Der Eintrag sollte dann so aussehen: :tag => "#{spec.version}"

Den Quelltext noch einmal prüfen:

$ pod lib lint

In Git einen Tag erstellen:

$ git add -A && git commit -m "Release 0.0.1."
$ git tag '0.0.1'
$ git push --tags

Die neue Version veröffentlichen:

$ pod trunk push NAME.podspec

Hinweis: Gelegentlich werden von Xcode Meldungen (Notes) ausgegeben, die keine kritischen Fehler anzeigen, sondern nur einen Hinweis darstellen. Das kann dazu führen, dass eine Veröffentlichung fehlschlägt. Dann lässt sich eine Veröffentlichung mit dem Parameter --allow-warnings durchführen.

$ pod trunk push NAME.podspec --allow-warnings

Sollte es zu einem Fehler kommen:

Authentication token is invalid or unverified.
Either verify it with the email that was sent or register a new session.

Dann muss eine neue Session erstellt werden, bevor der CocoaPod gepusht werden kann:

$ pod trunk register yourEmail@example.com 'Your Name'