Localizable strings of the pod conflict with that of the main app when the pod is not used as a dynamic framework
aleh opened this issue · 1 comments
Describe the bug
When the Frames pod is not used as a dynamic framework (that is when use_frameworks!
is absent in the app's Podfile
or static frameworks are requested viause_frameworks! :linkage => :static
), then its resources are not wrapped into a bundle and can override the corresponding resources of the app. Some names are generic enough (checkmark.png
) but the clash is particularly easy to run into with Localizable.strings
which is the usual name of the strings file in the app. (Actual case in our app.)
To Reproduce
- Install pods for "iOS Example Frame" example (commit
71b39a9
, cocoapods 1.11.2 let say) and open its workspace in Xcode (I used 12.5, but should not matter.) Set up provisioning, so it can run on the device, don't do any other configuration. - Add
Localizable.strings
into the project, click "Localize..." button, and make it available for at least English. - Add a single line there:
"Payment" = "Payment EN";
- Find
showAlert
method inMainViewController.swift
and replace the reference to"Payment"
string there withNSLocalizedString("Payment", comment: "")
. - Run the app and trigger this alert, for example, by tapping "Start 3DS" button.
- Observe the title of the alert translated, i.e. being "Payment EN" now.
- Open the app bundle (e.g. Project navigator > Products > iOS Example Frame.app > Show in Finder, then Show Package Contents on it) and observe that
en.lproj/Localizable.strings
contain the binary representation of the.strings
file we've just added and there is noLocalizable.strings
in the root of the bundle. - Now open the
Podfile
and comment outuse_frameworks!
, so the pod is used as a static library and resources are copied as is into the app's bundle. - Install pods and run the app again.
- Trigger the alert again.
- Observe that the title is now simply "Payment", i.e. the translation did not work now.
- Open the app bundle again and observe that both
Localizable.strings
anden.lproj/Localizable.strings
contain the strings of the pod, not the strings of the app, i.e. that the app's resource has been completely overridden.
Note that this also happens when the pod is used as a static framework, e.g. by specifying use_frameworks! :linkage => :static
in the Podfile
in step 8.
Expected behavior
It is expected that the resources of the pod never conflict with the resources in the main app. For example, they can be kept in a resource bundle created manually or via resource_bundles
directive of .podspec.
@aleh Thanks for raising this issue. I am able to reproduce this from my end. Also we are reviewing your PR and will soon plan to merge after we test it.