archagon / tasty-imitation-keyboard

A custom keyboard for iOS8 that serves as a tasty imitation of the default Apple keyboard. Built using Swift and the latest Apple technologies!
BSD 3-Clause "New" or "Revised" License
1.2k stars 290 forks source link

iOS 10 iMessage crash #106

Open pirrate opened 8 years ago

pirrate commented 8 years ago

After updating to iOS 10 when i type letter "İ" (uppercase i but turkish) on iMessage it crashes and shuts down. I mean iMessage crashes not keyboard. The strange thing it doesnt crashed anywhere else and iMessage itself doesnt crash when i type any other uppercase or lowercase letter. Strange.. Any idea?

AaronFW commented 8 years ago

Can you push your current version to your Github so that I can look at it? I do not know that I will be able to identify the problem, but it will be a little easier to look at.

pirrate commented 8 years ago

@AaronFW İ have messed a lot of things so it is not ready to be pushed but you can download this version and test it here. Because i also took this one as it is already converted to swift 3.0. https://github.com/polishedcode/tasty-imitation-keyboard Just edit json file and add this letter somewhere "İ" and try to type it in iMessage. I have tested in Emulator and real device the problem is the same.

pirrate commented 8 years ago

Or if you have converted your code to Swift 3.0 you can try with your own too. Because i am sure result will be the same.

pirrate commented 8 years ago

Just one correction the same issue is on iMessage and Messages. So you test it with Messages app in Simulator.

AaronFW commented 8 years ago

My own code is built on a form vastly different than the original Tasty-Imitation-Keyboard, it did not have the problem.

I downloaded Archagon's Tasty-Imitation-Keyboard, and updated the Syntax to Swift 2.3. iMessage then did crash with that character, just like you said.

After enough tries, it gave me an error report saying "\ Terminating app due to uncaught exception 'NSRangeException', reason: '*\ -[NSBigMutableString getCharacters:range:]: Range {0, 5} out of bounds; string length 4'".

I am also trying to compare it to my own code to see what differs. However, it is 4am for me. I will continue looking at it later.

pirrate commented 8 years ago

Thanks for information. how you got this error? i dont receive any errors. also i mentioned that even when custom keyboard and i just copy/paste that "İ" from somewhere (i mean without typing) Messages crash again. Also i found out that if i put 2 \n before "İ" then no crash happens. I dont know what is the real reason :)

AaronFW commented 8 years ago

I got the error after entering the İ a few times in iMessage. I have attached a Screenshot of the error and the full text. Now, (providing that the error is not still open in the background) I usually get the error every time.

screen shot 2016-09-22 at 8 41 14 am

pirrate-error-text.txt

AaronFW commented 8 years ago

Also, regarding the İ; isn't the lowercase "i"? The keyboard types the lowercase as the following:

screen shot 2016-09-22 at 9 18 34 am

Or is it supposed to be that way?

pirrate commented 8 years ago

yes the lowercase is i just for some reason when swift converts İ to lowercase it converts it to the letter that you wrote. i use proxy.insertText(("\u{0130}").uppercased(with:Locale(identifier: "tr")))

pirrate commented 8 years ago

this really annoys me. Tried 100 methods to fix it but still no result.

AaronFW commented 8 years ago

I will write someone regarding the Unicode issue with lowercase.

I will continue to try to establish why the İ is not working in Archagon's version but works in mine. For reference, my code is available on through my Fork. It should also be current. The most important files are probably DefaultKeyboard.Swift and KeyboardModel.Swift. The code isn't the cleanest: I took PolishedCode's version and modified it to my needs. My project is a keyboard for the Kouri-Vini Language and PolishedCode had a lot of things I did not need and I have not yet removed it all.

pirrate commented 8 years ago

Strange, i have tested your code and it works fine. I am also looking now and trying to find difference.

pirrate commented 8 years ago

any progress?

pirrate commented 8 years ago

i have updated iPhone to ios 10.1 public beta. Now everything work fine :D

AaronFW commented 8 years ago

It is good to hear that it seems to work fine for iPhone 10.1 beta.

I have been working and I haven't been able to look at it since I wrote last.

However, during my lunch-break, I did write a Bug Report to Apple regarding the İ, so please keep this Issue Open until I can report back when I hear back from Apple.

pirrate commented 8 years ago

iOS 10.0.2 still has this issue

pirrate commented 8 years ago

@AaronFW i am curious why your version doesn`t have this issue? What is your swift version? 2.3? i looked at the codes there are nothing specially different on insert text parts. Still a big question for me. May be there are some option on build parameters?

AaronFW commented 8 years ago

My Kouri-Vini Keyboard does not produce the error, but I did made a Tasty-Imitation-Keyboard that does produce the error. They are both Swift 2.3. I still cannot identify what the problem is.

pirrate commented 8 years ago

Seriously, you version has some difference. I tried to convert tasty-imitation to 2.3 i gave me error for using "dynamicType" as it is deprecated. But in your source code you are using it. Are you sure it is SWIFT 2.3? :)

AaronFW commented 8 years ago

Well, I updated setupLayout() in KeyboardViewController to self.layout = self.dynamicType.layoutClass.init(model: self.keyboard, superview: self.forwardingView, layoutConstants: self.dynamicType.layoutConstants, globalColors: self.dynamicType.globalColors, darkMode: self.darkMode(), solidColorMode: self.solidColorMode())

Then since it wasn't important for the thing that you wanted resolved, I commented out the section in createSettings().

func createSettings() -> ExtraView? { // note that dark mode is not yet valid here, so we just put false for clarity // let settingsView = DefaultSettings(globalColors: self.dynamicType.globalColors, darkMode: false, solidColorMode: self.solidColorMode()) // settingsView.backButton?.addTarget(self, action: #selector(KeyboardViewController.toggleSettings), forControlEvents: UIControlEvents.TouchUpInside) return settingsView }

But yes, it is Swift 2.3. After that, it is fit for Swift 2.3.

pirrate commented 8 years ago

I have tested version of @klimslim and it doesn`t have issue. I can type İ with it without any problem. https://github.com/klimslim/tasty-imitation-keyboard

pirrate commented 8 years ago

@AaronFW after 2 days sleepless nights i fixed that shit. This is for sure iOS 10 bug. The problem was PrimaryLanguage option in NSExtension section of info.plist It was tr_TR before. I changed it "tr" now it works without any problem. screen shot 2016-09-25 at 11 55 21 am

AaronFW commented 8 years ago

Ah, good job. I am glad it is fixed. :)

AaronFW commented 8 years ago

@pirrate I finally heard back from someone from Apple regarding the "İ" being turned to lowercase incorrectly. The wrote the following:

Please send us the output of the following two commands run in Terminal.app (/Applications/Utilities/Terminal.app):

defaults read -g AppleLanguages defaults read -g AppleLocale

Because you also experience the problem, can you run those commands in Terminal and send me the results? I will pass them on to Apple in the Bug Reporter.