Reputation: 1208
Xcode 13.0, Swift 5.5, iOS 15.0.2
Please bare with my poor debugging skills.
As soon as I try to type something in a textfield in my app, it throws a NSInvalidArgumentException
and the log prints:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSSingleObjectArrayI stringByTrimmingCharactersInSet:]:
unrecognized selector sent to instance 0x281a074b0'
*** First throw call stack:
(0x18535dcac 0x19c3cc758 0x18542d6d0 0x1852f7edc 0x1852f714c 0x187777400 0x187b22ee8
0x10566e1c8 0x10566fb1c 0x18777ac48 0x187c02f50 0x10566e1c8 0x10566fb1c 0x187699e84
0x187699ce8 0x187698b58 0x187b173fc 0x10566e1c8 0x10566fb1c 0x187b9f0d4 0x1884cf17c
0x1884db210 0x1884dacd8 0x1884ce794 0x1884cd90c 0x1884dc0ec 0x1884dc0ec 0x1884dc0ec
0x1884dc0ec 0x1884dc0ec 0x1884dc0ec 0x1884dc0ec 0x1884dc0ec 0x1884dc0ec 0x1884dc0ec
0x1884dc0ec 0x1884dc0ec 0x1884dc0ec 0x1884dc0ec 0x1884dc0ec 0x1884dc0ec 0x1884dc0ec
0x1884cd978 0x18830689c 0x18826cc74 0x18830f8c4 0x18830f9d4 0x187ba4a70 0x187a5bfd4
0x18777d948 0x18830f60c 0x18779486c 0x1877c472c 0x187969160 0x187799380 0x18778e130
0x18779365c 0x18537e220 0x18538e248 0x1852d15e8 0x1852d6a18 0x1852e9d8c 0x19f3f69a0
0x187b1efa8 0x1878b322c 0x19b4f3e80 0x104486c24 0x104844190)
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
I set a symbolic breakpoint at -[__NSSingleObjectArrayI stringByTrimmingCharactersInSet:]
as described here (How can I debug 'unrecognized selector sent to instance' error). But this breakpoint isn't reached, as far as I can tell(?)
From the Xcode Debug navigator, the app crashes here: #68 0x0000000104486bd4 in static AppDelegate.$main() [inlined]
, as per line 9:
MyApp`main:
9. 0x104486bd4 <+28>: bl 0x10451bbd0 ; symbol stub for: static Swift.CommandLine.unsafeArgv.getter : Swift.UnsafeMutablePointer<Swift.Optional<Swift.UnsafeMutablePointer<Swift.Int8>>>
My AppDelegate:
import UIKit
import Firebase
import FirebaseUI
import FBSDKCoreKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var orientationLock = UIInterfaceOrientationMask.all
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return self.orientationLock
}
struct AppUtility {
static func lockOrientation(_ orientation: UIInterfaceOrientationMask) {
if let delegate = UIApplication.shared.delegate as? AppDelegate {
delegate.orientationLock = orientation
}
}
static func lockOrientation(_ orientation: UIInterfaceOrientationMask, andRotateTo rotateOrientation:UIInterfaceOrientation) {
self.lockOrientation(orientation)
UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
}
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//Initialize and configure Firebase
FirebaseApp.configure()
// Initialize Facebook SDK
ApplicationDelegate.shared.application(application,didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(_ app: UIApplication, open url: URL, options: UIApplication.OpenURLOptionsKey : Any]) -> Bool {
let sourceApplication = options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String?
// FirebaseUI URL handling
if FUIAuth.defaultAuthUI()?.handleOpen(url, sourceApplication: sourceApplication) ?? false {
return true
}
// other URL handling goes here.
return false
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
func applicationWillTerminate(_ application: UIApplication) {}
}
When placing the marker in the textField, before starting to type, the log prints Writing analzed variants.
I never saw this before but according to this (Xcode log "Writing analzed variants") it can be ignored.
I'm also seing this in the log upon launching the app, which I've never seen before. Don't know if it's of any help:
[] __nwlog_err_simulate_crash simulate crash already simulated "nw_hash_table_apply called with null table"
[] nw_hash_table_apply called with null table, dumping backtrace:
[arm64] libnetcore-2736.12.1
0 libnetwork.dylib 0x00000001867cb2f0 __nw_create_backtrace_string + 116
1 libnetwork.dylib 0x0000000185fa9820 nw_hash_table_apply + 2676
2 libnetwork.dylib 0x00000001864f4450 EE6D5599-5B6E-3AAC-ABC7-05F56B4EE2FB + 6030416
3 libnetwork.dylib 0x00000001864d0a9c EE6D5599-5B6E-3AAC-ABC7-05F56B4EE2FB + 5884572
4 CFNetwork 0x0000000185ce152c _CFURLStorageSessionCopyIdentifier + 14364
5 libnetwork.dylib 0x00000001860c3eb8 EE6D5599-5B6E-3AAC-ABC7-05F56B4EE2FB + 1638072
6 libdispatch.dylib 0x00000001032d494c _dispatch_call_block_and_release + 24
7 libdispatch.dylib 0x00000001032d61c8 _dispatch_client_callout + 16
8 libdispatch.dylib 0x00000001032df560 _dispatch_workloop_invoke + 2448
9 libdispatch.dylib 0x00000001032e9630 _dispatch_workloop_worker_thread + 852
10 libsystem_pthread.dylib 0x00000001dece2f38 _pthread_wqthread + 284
11 libsystem_pthread.dylib 0x00000001dece2aa4 start_wqthread + 8
UPDATE - TEXTFIELD CONFIG The issue is for all textfields in the app, even the email address textfield in FirebaseUI (which I don't configure manually at all). This makes me think it's not about the textfield config, but rather a keyboard issue? Can that make sense and how can I debug that?
Anyway, the textfields I create are created in storyboard. In each viewController I have a few delegate methods; textFieldDidBeginEditing(_:)
, textFieldShouldReturn(_:)
and textFieldDidEndEditing(_:)
. I can tell the textFieldDidBeginEditing is being called when the user taps the textfield. But then, as soon as the first keyboard letter is pressed, the exception is thrown.
The keyboard is default and the textField contentType is unspecified. Don't know if that is relevant or not.
UPDATE I have done nothing with my code, but after updating to iOS 15.2 the error is gone!? Any ideas?
Upvotes: 1
Views: 696