I use Firebase in an iOS application and have two separate Firebase projects, one for production and one for development. My two .plist files: GoogleService-Info.plist
and GoogleService-Info-Dev.plist
, which I was able to select based on the flag set in Targets → Build Settings → Other Swift Flags.
Inside AppDelegate didFinishLaunchingWithOptions
:
#if DEBUG let buildFor = "DEV" #else let buildFor = "PROD" #endif let firebasePlistFileName = buildFor == "DEV" ? "GoogleService-Info-Dev" : "GoogleService-Info" let firebaseOptions = FIROptions(contentsOfFile: NSBundle.mainBundle().pathForResource(firebasePlistFileName, ofType: "plist")) FIRApp.configureWithOptions(firebaseOptions)
This works until today, when I had a problem with another Cocoapod project. I think this started when I cleaned up the Xcode project or deleted the Derived Data folder:
dyld: Library not loaded: @rpath/OtherPod.framework/OtherPod Referenced from: /Users/me/Library/Developer/CoreSimulator/Devices/12345678-E1C4-480F-B1D9-C10823DEA810/data/Containers/Bundle/Application/AE7B6EB0-43AB-CCCC-BBBB-AAAA71BF/MyApp.app/MyApp Reason: image not found
In the end, I decided that by choosing my application in the Goals → General → Related Structures and Libraries section, add all the options inside the Workspace
folder (7 other swap projects) and install the ones I added as optional. Since then, I have encountered the error described in the title of this post:
2017-02-10 17:19:29.660 MyApp[12639:182433] +[NSData gtm_dataByGzippingData:error:]: unrecognized selector sent to class 0x10a0442e8 2017-02-10 17:19:29.680 MyApp[12639:182433] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSData gtm_dataByGzippingData:error:]: unrecognized selector sent to class 0x10a0442e8' *** First throw call stack: ( 0 CoreFoundation 0x0000000109d88d4b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00000001097f121e objc_exception_throw + 48 2 CoreFoundation 0x0000000109df8e44 +[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x0000000109d0e005 ___forwarding___ + 1013 4 CoreFoundation 0x0000000109d0db88 _CF_forwarding_prep_0 + 120 5 MyApp 0x0000000102d73c9d -[FIRNetwork postURL:payload:queue:usingBackgroundSession:completionHandler:] + 331 6 MyApp 0x0000000102d70e72 -[FIRClearcutLogger sendNextPendingRequestWithCompletionHandler:] + 570 7 MyApp 0x0000000102d70918 -[FIRClearcutLogger sendLogsWithCompletionHandler:] + 447 8 libdispatch.dylib 0x000000010a6ab978 _dispatch_call_block_and_release + 12 9 libdispatch.dylib 0x000000010a6d50cd _dispatch_client_callout + 8 10 libdispatch.dylib 0x000000010a6b2e17 _dispatch_queue_serial_drain + 236 11 libdispatch.dylib 0x000000010a6b3b4b _dispatch_queue_invoke + 1073 12 libdispatch.dylib 0x000000010a6b402b _dispatch_queue_override_invoke + 683 13 libdispatch.dylib 0x000000010a6b6385 _dispatch_root_queue_drain + 720 14 libdispatch.dylib 0x000000010a6b6059 _dispatch_worker_thread3 + 123 15 libsystem_pthread.dylib 0x000000010aa3a712 _pthread_wqthread + 1299 16 libsystem_pthread.dylib 0x000000010aa3a1ed start_wqthread + 13 ) libc++abi.dylib: terminating with uncaught exception of type NSException
I tried many different fixes, including adding to the binary link with libraries , adding Flags to another linker , and none of them worked.
What can be an unrecognized selector, and how can I change or delete it? Could this problem be due to the one I came across (library not loaded)?
For clarification, when an unrecognized selector sent to class
error occurs, the Xcode debug navigator focuses on Thread 7, with the line FIRApp.configureWithOptions(firebaseOptions)
.
Update
I found a temporary fix by returning to the previous git declaration (cloned my repository into a separate directory), and then replaced most of the project contents from this old commit with the current copy that created the error, including the application - Folder name in the root directory, App-Name.xcodeproj and App-Name.xcworkspace. I tested only on a simulator (iPhone 7 running iOS 10.2) and it worked. Then I successfully sent the assembly to iTunes Connect and was able to run this assembly on my device (iPhone 5c from 10.2.1), but after removing this and trying to build from Xcode, I again got the same error. However, the error was not executed while working on the simulator. This is in contrast to the original error scenario, as it happened both on the physical device and on the simulator.
It made me remember that the stack trace I originally posted was running the application on a simulator. Running it on the output device produces less, in particular, the content after *** First throw call stack:
was only (0x1d01cdf7 0x1c27f077 0x1d022467 0x1d020579 0x1cf453d8 0x31ff3f 0x31d653 0x31d05d 0x1c57d57 0x1c63e63 0x1c5b205 0x1c64391 0x1c65d9f 0x1c65ba7 0x1c877937 0x1c877490)
0x31d05d 0x1c57d57 0x1c63e63 0x1c5b205 0x1c64391 0x1c65d9f 0x1c65ba7 0x1c877937 0x1c877490) instead of the more descriptive output file names / functions .