1

My app is crashing when the keyboard is tapped, I select the textfield, the keyboard open properly, but once the keyboard is tapped (any key) the crash happen, giving the log below.

Im running the app on iPhone 8 with iOS 15 RC, from Xcode 13 RC. In any other device with iOS 14 (not matter the version) is working properly.

Debug Console error

2021-09-14 14:11:12.860707+0100 BonnetDriverDev[3595:649035] -[__NSArray0 stringByTrimmingCharactersInSet:]: unrecognized selector sent to instance 0x1f5c13500
2021-09-14 14:11:12.864293+0100 BonnetDriverDev[3595:649035] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArray0 stringByTrimmingCharactersInSet:]: unrecognized selector sent to instance 0x1f5c13500'
*** First throw call stack:
(0x180cddcac 0x197d0a748 0x180dad6d0 0x180c77edc 0x180c7714c 0x1830f752c 0x1834a2360 0x102f0e1c8 0x102f0fb1c 0x1830fad74 0x1835812a0 0x102f0e1c8 0x102f0fb1c 0x183019fc4 0x183019e28 0x183018c98 0x183496874 0x102f0e1c8 0x102f0fb1c 0x18351e144 0x183e49624 0x183e556b8 0x183e55180 0x183e48c3c 0x183e47db4 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e56594 0x183e47e20 0x183c81fac 0x183be8384 0x183c8afd4 0x183c8b0e4 0x183523ae0 0x1833dad2c 0x1823cc98c 0x180cfe220 0x180d0e248 0x180c515e8 0x180c56a18 0x180c69d8c 0x19ad2a9a0 0x18349e420 0x183231e18 0x100e585a4 0x101f0c190)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArray0 stringByTrimmingCharactersInSet:]: unrecognized selector sent to instance 0x1f5c13500'
terminating with uncaught exception of type NSException

Im not using the stringByTrimmingCharactersInSet function, so im guessing is a system call. The libraries that I'm using are cocoa pods.

You can find the entire crash log on this question on apple forums: https://developer.apple.com/forums/thread/689868

Debug navigator

The warning in the last task from the image says:

Thread 1: "-[__NSArray0 stringByTrimmingCharactersInSet:]: unrecognized selector sent to instance 0x1fa3a3500"

Debug Navigator

Code for initialisation and view controller

It's a big code but I reduce to this only to test the textfield.

Initialisation of controller from app delegate

import UIKit

@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {

public var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
    let vc = TestViewController(nibName: nil, bundle: nil)
  
    self.window = UIWindow(frame: UIScreen.main.bounds)
    self.window?.rootViewController = vc
    self.window?.makeKeyAndVisible()
    
    return true
}... }

View Controller content

import UIKit

    class TestViewController: UIViewController {
        
        private var textField: UITextField {
            var v = UITextField()
            v.translatesAutoresizingMaskIntoConstraints = false
            return v
        }
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            self.setup()
        }
        
        private func setup() {
            self.view.addSubview(textField)
            
            NSLayoutConstraint.activate([
                self.textField.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
                self.textField.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
                self.textField.heightAnchor.constraint(equalToConstant: 50),
                self.textField.widthAnchor.constraint(equalTo: self.view.widthAnchor, multiplier: 0.8)
            ])
        }
    }

Pods: Firebase Auth, RemoteConfig, Analytics, GoogleSignIn, Stripe, Intercom, lottie

AnaMM
  • 307
  • 4
  • 17
  • 1
    We don't have enough information to be able to tell what's going on. If you look at the call stack you can usually tell if the crash is coming from a system call or from your app. If it's in a system framework you should look back in the call stack for the last call from your code. That might give you some hint as to what's causing it. – Duncan C Sep 15 '21 at 15:29
  • @DuncanC I have added the debug navigator view, as you can see there's no much information, do you have any idea where I can start looking? Thanks – AnaMM Sep 15 '21 at 15:36
  • 1
    You need to post the code that you have. Saying "I use cocoapods" doesn't tell us which cocoapods and how you are using them. Show us the code thats crashing and tell us anything thats not obvious from the code (e.g. the textfield is an instance of a class from library X etc.) – Simon McLoughlin Sep 15 '21 at 16:06
  • @SimonMcLoughlin I have added the code you mention – AnaMM Sep 16 '21 at 12:16
  • @AnaMM You said you stripped down the code, is the code you've posted causing the crash? if you copy paste that into a brand new project it causes a crash? If it is, unless i'm missing something you need to file an issue with apple because textfields themselves are just broken in the new RC. If its not, post the actual code thats causing the crash, and let us know WHICH cocoapods you are using – Simon McLoughlin Sep 16 '21 at 13:09
  • @AnaMM it would also be useful to search the entire workspace (not the project, workspace) for `stringByTrimmingCharactersInSet` and see where its being used that might be causing an issue – Simon McLoughlin Sep 16 '21 at 13:10
  • @SimonMcLoughlin Yes, simplifying the code still cause the exact same error. When I search for stringByTrimmingCharactersInSet in the code I have only results of Firebase libraries, but there are not being call during the interaction with the keyboard. If I create a new project works, the only different is that in my old project I don't have a scene delegate. I have add the pods to the post – AnaMM Sep 16 '21 at 13:51
  • @AnaMM a quick search on github and most of the dependencies you've listed have that function in them, not just firebase. Firebase RemoteConfig also uses it in connection with some function to disabling iOS versions. Do you have anything like that? Google Sign in also uses it in connection with error handling, are you firing network requests as characters are typed? Have you set a breakpoint to try find the line of code causing the issue and run into an issue, or did you not try? https://developer.apple.com/forums/thread/96547 – Simon McLoughlin Sep 16 '21 at 15:46
  • I have exactly the same issue, but with Flutter, did you fix it? – James Chan Sep 23 '21 at 20:01

3 Answers3

0

Please check your info.plist

If you see this, chanage it to String

from

<key>CFBundleDisplayName</key>
<false/>

to

<key>CFBundleDisplayName</key>
<string>YourAppName</string>
James Chan
  • 97
  • 2
  • 12
0

Well at the end I find a solution, but Im quite sure that was too complicated.

My app was generated with Xcode 10, so I decided to create a new project with the Xcode 13 and move all the folders and configurations to this new project, that solved my error and any other problem that I was having.

If anybody had a better solution please shared.

AnaMM
  • 307
  • 4
  • 17
0

I had the same problem and found a solution. Go to the info.plist file and right click -> Open as Source File. Delete the below lines.

<key>CFBundleDisplayName</key>
<array> </array>
Jaden
  • 80
  • 5