Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 11 - Xcode 9 beta 6 #32

Closed
adrienbrunwod opened this issue Aug 25, 2017 · 11 comments
Closed

iOS 11 - Xcode 9 beta 6 #32

adrienbrunwod opened this issue Aug 25, 2017 · 11 comments

Comments

@adrienbrunwod
Copy link

Using Xcode 9 beta 6 to build my project (toolchain Swift Development Snapshot 2017-08-21), it stopped working. Text from the storyboards is no longer localized.

@angelolloqui
Copy link
Owner

I have to download the beta 6 to try this out, but at least in beta 5 (the one I have right now) there is no issue. Have you found the cause?

@adrienbrunwod
Copy link
Author

Seems like the load method is never called and so neither is the awakeFromNibCustom. But if you have it working with the beta 5 it might be some configuration issue on my end.

@adrienbrunwod
Copy link
Author

@angelolloqui I can't figure out what changed. Any idea what configuration might have been impacted when trying the beta?

@EvanLu
Copy link

EvanLu commented Sep 4, 2017

I'm having similar issue but not always happened. Only happened in a specific flow.

This issue often happened after I opened a WebView with approximate 150MB memory usage in the App, then the Text of UILabel in Xib files would be no longer localized at every page. Not sure this scenario is related to the issue directly or not.

build with Xcode 9 beta 6,7,8 and now using beta 9 the issue is still exist. any idea~?

Thanks.

@EvanLu
Copy link

EvanLu commented Sep 5, 2017

Just noticed that this issue may be related to Hot-Patch disabled from Apple's notification recently.

Maybe there's a misjudgment by the runtime method "method_exchangeImplementations" which called by a View with running WebView?

@adrienbrunwod
Copy link
Author

Could this be an explanation ?
http://jordansmith.io/handling-the-deprecation-of-initialize/

@adrienbrunwod
Copy link
Author

extension UILabel {
open override func awakeFromNib() {
super.awakeFromNib()
if let text = self.text, text.count > 0 {
self.text = Bundle.main.localizedString(forKey: text, value: "", table: nil)
}
}
}

That seems to work

@angelolloqui
Copy link
Owner

The problem with override awakeFromNib in an extension is that it might run into undefined behavior in future versions since overriding into extensions is discouraged. If for example Apple (or a third party sdk) implements that method then yours will not be called (or will be called randomly in exchange of the other).
That is why I decided to go with swizzling, that as far as UIKit runs on objc-runtime should work ok.

Now, seeing that many of you have an issue, we will need to research, but I do not like the fact that it happens after some rare circumstances. It looks like Apple is actually reloading the whole class or doing swizzling themselves (in a wrong way since done properly it could cohexist).

If you want a temporal fix, do what @adrienbrunwod suggested, it should work, but a more consistent solution should be found

@angelolloqui
Copy link
Owner

I will try to create a branch tomorrow with the overriding in a category so you can at least import that branch while I find proper time to research (or someone else does)

@EvanLu
Copy link

EvanLu commented Sep 7, 2017

I've done a similar workaround in NSObject+AGi18n file.

Thank you @angelolloqui @adrienbrunwod and maybe the issue I encountered will be gone somehow at official iOS 11 :D

@angelolloqui
Copy link
Owner

I have added a 0.0.3 version (also to CocoaPods) with the overriding solution. Since it might be temporal, I have included a precompilation header called AGI18N_USE_SWIZZLINGthat when set to 1will use the swizzling again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants