I am importing two different Objective-C frameworks FrameworkA
and FrameworkB
in a sample app MyApp
, and those two frameworks define the same Person
class.
If you run the MyApp
, it gives you the following warning on the console.
objc[27167]: Class Person is implemented in both
/private/var/containers/Bundle/Application/9762DB63-21E9-4592-B875-
6DF6F373FFD0/MyApp.app/Frameworks/FrameworkA.framework/FrameworkA
(0x100b18100) and
/private/var/containers/Bundle/Application/9762DB63-21E9-
4592-B875-6DF6F373FFD0/MyApp.app/Frameworks/FrameworkB.framework/FrameworkB
(0x100b30100).
One of the two will be used. Which one is undefined.
Why do you only get a warning instead of a linker error when (1) there are same class names in two different iOS frameworks? I know (2) having duplicate classes within one framework won't compile because of linker error due to namespace issue.
As far as I know, for both cases, linker links all source codes and libraries/frameworks to one executable. But why doesn't linker throw an error for case (1)?