Class Is Implemented in Both, One of the Two Will Be Used. Which One Is Undefined

Class is implemented in both, One of the two will be used. Which one is undefined

I don't know the reason, but if you open your app's Pods-[AppName].debug.xcconfig file that cocoapods creates you'll find OTHER_LDFLAGS and you'll see it links to the same frameworks you link in your framework. So if you remove -framework [Duplicated framework] the warning disappears.

Seems to be a cocoapods error

Class Foo is implemented in both MyApp and MyAppTestCase. One of the two will be used. Which one is undefined


Class Foo is implemented in both MyApp and MyAppTestCase. One of the two will be used. Which one is undefined.


I wonder why is that?

because both images (the app and the unit test bundle) define the implementation of the class. the class is dynamically loaded into the objc runtime. the objc runtime uses a flat namespace. how this works:

  • the binary is loaded, starting with its dependencies
  • as each binary is loaded, the objc classes register with the objc runtime
  • if a class with a specific name is loaded twice, the behaviour is undefined. one implementation of a class (with identical names) can be loaded into the objc runtime.

the typical problem here is that you will be returned one implementation - your app will likely crash when the type conflicts (when the class does not come from the same source file).

you typically avoid this by either renaming a class, or export the class in one image. renaming the class obviously does not apply to your case. you have one file Foo.m which is being compiled, exported, and loaded by two images when it should be in one.

this should be interpreted by you as a duplicate symbol linker error. even though the implementation is the same source file (and the implementation is the same) - this a problem that you must fix.

How can I solve this?

if Foo.m is a class of the app, you have to remove (do not compile and link) Foo.m from the unit test. if it's part of the unit test, then do not compile and link it into the unit test target.

then, follow the instructions in the post for linking/loading your unit test to the app. it's in this general area of the post: where "WhereIsMyMac" is the name of the application you're unit testing. This will let the testing target link against the application (so you don't get linker errors when compiling). the important part is that your test files are compiled in the unit test target (only), and your app's classes are compiled and linked into the app. you can't just add them - they link and load dynamically.

Maybe I missed something when setting the unit test target?

From the article you linked:

Note: The testing target is a separate target. This means that you need to be careful of target membership. All application source files should be added to the application target only. Test code files should be added to the testing target only.

the part that you got wrong is probably the link and load phases of the unit test bundle.

Class is implemented in both. One of the two will be used

I wrote that error message!•

Either change the class name or don't link against said library.

How is your project configured? Is there anywhere where you explicitly link against SR? Or is it a product of linking against two static libraries that both already include SR?

If the former, then stop linking against SR directly and just inherit the version that came with the library already using it (warning: make sure it has the right version).

If the latter, then you are going to have to modify one of the libraries.

• Actually, I modified the error. It used to imply that one or the other would be used. But that wasn't really what was going on and the behavior was different across different platforms. Thus, it was changed so that it was far more precise in identifying that the behavior was undefined.

Class X is implemented in both framework and application one of the two will be used, which one is undefined

My solution was to take the source code from the cocoa pod and create a Cocoa Touch Framework for it. Then I linked the framework to my api and to my test app.
This isn't great but it is all I could do quickly. I believe Cocoapods is working on supporting frameworks so this solution may get outdated soon enough.

My company also uses gradle for dependencies (java) and build scripting. So I created a groovy/gradle build task that builds my framework and my supporting frameworks (cocoapod frameworks) and creates a universal framework from them. Then it zips all of the frameworks. This means I can distribute one zip with all of the requirements. This obviously isn't the nicest way to distribute (we'll be moving to distributing through Cocoapods with dependencies on our closed source frameworks), but it is fast to setup.

Class _PointQueue is implemented in both when I click on textfield... How can I resolve this issue?

Apple developer Quinn “The Eskimo!” @ Developer Technical Support @ Apple answered this question here:

This is not an error per se. Rather, it’s the Objective-C runtime telling you that:

  • Two frameworks within your process implement the same class (well, in this case classes, namely _PathPoint and _PointQueue).
  • The runtime will use one of them, choosing it in an unspecified way.

This can be bad but in this case it’s not. Both of the implementations are coming from the system (well, the simulated system) and thus you’d expect them to be in sync and thus it doesn’t matter which one the runtime uses.

So, in this specific case, these log messages are just log noise.

Xcode error: Class name is implemented in both path and path . One of the two will be used. Which one is undefined?

In the Podfile, change use_frameworks! to use_frameworks! :linkage => :static

FirebaseAnalytics is a static framework and linking it into the app's dynamic framework causes it to be linked into the app twice.



Related Topics



Leave a reply



Submit