Search code examples
iosxcodecocoapodsunrecognized-selector

Error: Unrecognised selector, Warning: Class implemented in both


I'm running into a unrecognised selector error as my App is resolving the wrong library when calling a method in runtime.


What:

  • I'm using Reachability and a private framework, we'll say FooLib

  • I get the following runtime warning - before the method is called

    Class Reachability is implemented in both .../Frameworks/Reachability.framework/Reachability(0x106590d18) and .../Frameworks/FooLib.framework/FooLib(0x10628d6b8) One of the two will be used. Which one is undefined.`

  • FooLib has no dependencies to Reachability, nor does its sub dependencies, nor does it mention the word Reachability ever.

  • The memory pointer in the stack trace clearly resolving to FooLib when calling a Reachability function

    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[Reachability reachabilityForLocalWiFi]: unrecognized selector sent to class 0x10628d6b8'


Podfile

  • Podfile configuration in both my App, and my FooLib have:

    use_frameworks!


Attempts:

  • Clean (Cmd Shift K)
  • Clean (Cmd Opt Shift K)
  • Deleted DerivedData folder
  • From this post, Removed SystemConfig, Clean, Add SystemConfig, Build

Does anyone have an idea whats going on? Any insight would be much appreciated.


Solution

  • Ok, this is just a guess, I'll remove the answer if it turns out to be complete bullshit...

    Apple deprecated - and maybe just have removed - the method reachabilityForLocalWiFi. So it could be that your pods just import old header files, which satisfy the compiler, but at runtime, the function does not exist anymore, hence the unrecognized selector exception.

    You could just try the suggestions from the linked Apple Readme.md

    Nevertheless, it would be interesting to find out if this really is the reason, and why the podfiles "misbehave" in that way.