0

I have iOS application which use frameworks A and B. Each of which requires MyClaseName class.

After running application I have following warnings in log:

objc[2472]: Class MyClaseName is implemented in both /Users/myusername/Library/Developer/Xcode/DerivedData/workspace-amvqjwzykbswydebvpvdfbylgsck/Build/Products/Debug-iphonesimulator/A.framework/A and /Users/myusername/Library/Developer/Xcode/DerivedData/workspace-amvqjwzykbswydebvpvdfbylgsck/Build/Products/Debug-iphonesimulator/B.framework/B. One of the two will be used. Which one is undefined.

I have checked following similar SO question, but unfortunately this is not my case.

So, how can I fix this issue?

Community
  • 1
  • 1
David V
  • 2,134
  • 1
  • 16
  • 22
  • 2
    I think you may have to rename one of them. – Yuchen Feb 26 '15 at 15:03
  • You should rename them, is pretty important that when you create a class you use a sort of prefix. Usually I use my initial AF and name of the project or framework, for instance AFPhotogunViewController – Andrea Feb 26 '15 at 15:20
  • @Yuchen, this class instances need to be the one for whole project. In case of renaming I will have different instances. – David V Feb 27 '15 at 05:46
  • @IAmDav, this sounds very much like a **diamond inheritance** problem in `C++`. Not the same, but similar idea. Not sure whether there is really solution for your problem. Maybe you will still have to refactor your code structure. – Yuchen Feb 27 '15 at 18:16
  • hi @Yuchen, actually issue comes from iOS frameworks. my C++ classes loading twice. I think this Xcode need to introduce new option, to avoid this situation. – David V Mar 02 '15 at 06:19

1 Answers1

0

This is the reasoning behind prepending a specified prefix to all of the classes in your code.

A.framework's classes should be prefixed with AF, and B.framework should use BF, for example:

AFClassName *aInstance = [AFClassName new];
BFClassName *bInstance = [BFClassName new];

Without a prefix, both of these classes would effectively be called 'ClassName', and would lead to the kind of conflict you see.

dzl
  • 908
  • 11
  • 32
  • How do you suggest to do that? write a script for all files to rename them? I hope there are some linker option to make app understand that is is the same object/class? – David V Feb 27 '15 at 05:44