antiraum / THPinViewController

iOS 7 Style PIN Screen for iPhone and iPad

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Localizaton files and cocoapods

nakp opened this issue · comments

After trying this with cocoapods, I realized that the localization tables are not included, I think it's because the spec.resources are missing, now cancel and delete button are not localizable

missing

Sorry for the late reply and thanks for surfacing the issue. I've updated the podspec and pushed the version 1.2.3.

This is still happening for me on 1.2.3 while using Xcode 6.1 and cocoapods 0.34.4 while running on an iPad Air running iOS 8.1 and on the iPad Air simulator running iOS 8.1. The .strings files do show up in my Pods project.

I've tried clearing derived data, restarting Xcode, and deleting the app off my device. I'm just using the snippet in the readme file. Anything else I'm missing or is this indeed still a problem with the pod itself?

The strings files were included in the 1.2.3 podspec and should be placed inside a THPinViewcontroller.bundle. However, now the translations couldn't be used any more with NSLocalizedStringFromTable. I just pushed version 1.2.4 which switches to NSLocalizedStringFromTableInBundle.

What I often need to do to get Xcode see the changes made by a "pod install" run, is to clean the build folder (⎇⇧⌘K).

1.2.4 fixed the issue for me. Thanks.

With more recent versions of CocoaPods that use frameworks, it appears that this is an issue again because THPinViewController.bundle is not being referenced correctly as it lives inside THPinViewController.framework.

I believe the fix is to replace [NSBundle mainBundle] with [NSBundle bundleForClass:[self class]].

See the below patch with proposed fix:

diff --git a/THPinViewController/THPinView.m b/THPinViewController/THPinView.m
--- a/THPinViewController/THPinView.m
+++ b/THPinViewController/THPinView.m
@@ -200,7 +200,7 @@
 
 - (void)updateBottomButton
 {
-    NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"THPinViewController"
+    NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"THPinViewController"
                                                                                 ofType:@"bundle"]];
     if (self.input.length == 0) {
         self.bottomButton.hidden = self.disableCancel;
diff --git a/THPinViewController/THPinViewController.m b/THPinViewController/THPinViewController.m
--- a/THPinViewController/THPinViewController.m
+++ b/THPinViewController/THPinViewController.m
@@ -27,7 +27,7 @@
         _delegate = delegate;
         _backgroundColor = [UIColor whiteColor];
         _translucentBackground = NO;
-        NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"THPinViewController"
+        NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"THPinViewController"
                                                                                     ofType:@"bundle"]];
         _promptTitle = NSLocalizedStringFromTableInBundle(@"prompt_title", @"THPinViewController", bundle, nil);
     }