Duplicate Symbol linker error - ios

I have an existing app in which I added the json-framework. Now it won't compile due to a duplicate symbol linker error.
The error seems to be due to the installed Millenial Media ad network SDK which also links to the json-framework. It seems the json-framework must be already embedded in MMs .a static library file. If I dont add the SDK then I cant import the json-framework for use in my own code, but when I do the compiler raises this exception.
ld: duplicate symbol _OBJC_IVAR_$_SBJsonParser.maxDepth in /users/laptop/Developer/sandbox/testapp_sources_add_owntracking/testapp/AdNetworkLibs/MillenialMedia/libMMSDK.a(SBJsonParser.o) and /Users/laptop/Library/Developer/Xcode/DerivedData/testapp-bjxtaanqoewrondmjnucarxebkka/Build/Intermediates/testapp.build/Debug-iphonesimulator/testapp.build/Objects-normal/i386/SBJsonParser.o for architecture i386
collect2: ld returned 1 exit status

You can add the json framework header files without adding the json class implementation files. If these classes are in another library, then they will be linked with that library.

In your project, you have SBJsonParsor added twice.
This might have happend as some of the library (source) you are using (added to project) already have SBJsonParsor added without your active knowledge about the same.
You need to check your project hierarchy and remove one of the reference.

Related

CardboardSDK conflict (duplicate symbol) in google protobuf library

I've successfully integrated and configured my CardboardSDK project in a test project, now I want to integrate it in my main project which already uses GTL library for YouTube uploading and in this new project I'm getting 641 duplicate symbols for classes with strange names.
What I've tried:
I've addressed some conflicts with GoogleAdMob and GoogleConversion SDKs.
I've addressed conflicts for all the cases where I could find a relevant class name somewhere else in the project, like AFNetworking, OAuth etc.
But still there are 641 duplicate symbols.
duplicate symbol __ZN6google8protobuf8internal20InitLogSilencerCountEv in:
/Users/sabirali/Documents/4.2.1/libCardboardSDK.a(common.o)
duplicate symbol __ZN6google8protobuf8internal22DeleteLogSilencerCountEv in:
/Users/sabirali/Documents/4.2.1/libCardboardSDK.a(common.o)
...
...
duplicate symbol __ZN6google8protobuf2io18StringOutputStreamC1EPNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE in:
/Users/sabirali/Documents/4.2.1/libCardboardSDK.a(zero_copy_stream_impl_lite.o)
duplicate symbol __ZN6google8protobuf2io22LazyStringOutputStreamC2EPNS0_14ResultCallbackIPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEE in:
/Users/sabirali/Documents/4.2.1/libCardboardSDK.a(zero_copy_stream_impl_lite.o)
duplicate symbol __ZN6google8protobuf2io22LazyStringOutputStreamC1EPNS0_14ResultCallbackIPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEE in:
/Users/sabirali/Documents/4.2.1/libCardboardSDK.a(zero_copy_stream_impl_lite.o)
ld: 641 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Problem:
I'm unable to fully understand where these duplicate symbols are coming from, my calculated guess is its fro m GTL SDK by google but I do need that for YouTube uploading and can't remove it. e.g. Is this class name __ZN6google8protobuf8internal20InitLogSilencerCountEv randomly generated ?
How can I find out exactly which SDK / Framework in my project is indirectly using the same google library which Cardboard SDK is using ?
I would even like to explicitly silence the duplicate symbols, using some compiler flags, if possible ?
UPDATE:
I found out that the issue is not with the YouTube API, as Ive removed that API and all other google SDKs from my project and am still getting the conflict.
I've checked the object files inside the SDK and its not them, its protobuf library internally being used by some of the classed inside Cardboard SDK.
How can I find out which library is having protobuf as a dependancy ?

Duplicate symbol(s) for architecture(s) [arm7, arm64]

I have imported a new version of a framework in my SDK. Anyway, I am not able to build on iPhone 6 running iOS 9.0.1 because of the following error that's driving me crazy:
duplicate symbol _IPDJobStatus in:
/Users/akiki/Desktop/iOS 9 Test/MPSDK/iPD.framework/iPD(IPDDevice.o)
/Users/akiki/Desktop/iOS 9 Test/MPSDK/iPD.framework/iPD(IPDAdministration.o)
ld: 5 duplicate symbols for architecture arm7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is happening for the same symbol _IPDJobStatus being found twice in 5 files. The same is happening on iPhone 4S running iOS 9.1 with arm64 architecture. To import the framework, I deleted the old one from the project, imported the new one and check into the Link Binary with Library section wether the framework reference links to the correct updated file. Before asking I have tried to perform the following actions:
I searched for the duplicate symbol inside the project scope with no result.
I'm not importing a .m file by accident.
The Compile Sources of the Build Phases project settings doesn't include any duplicate file.
The framework headers references in Headers of the Build Phases project settings link to the proper files.
I tried to clean the project, empty the Derived Data folder, quit and relaunch Xcode.
I added the -ObjC linker flag (in this case the duplicate symbols goes from five to only one).
I switched the No Common Blocks compiler setting to NO, though it has the same error with or without it.
I created a new empty project and imported the framework there. In this case I was able to build, so the problem must resides in my SDK.
Could someone please give me some help?
You can check your project directory may be there available framework. If available then delete it.
I was able to solve the same problem with the following code.
Add this to the Library Search Paths in Build Settings and make sure you select recursive, delete other library paths which might be absolute paths.
$(PROJECT_DIR)
May be it will help you.
You can not make constant type variables of same name & type in two or more classes.
_IPDJobStatus is this constant type variable?
change it to some other name for different classes.
Here you can see the same issue
It means in you project multiple copy of same View Controller instance (i,e means duplicate).
Possible observation:
This IPDJobStatus variable contains in the class IPDDevice or IPDAdministration of the framework is duplicate. Please check this.
Note: You should not have/create a class which already have in any other framework either Xcode's default or 3rd party framework.
For example: UIkit framework have class name "UIApplication" (i.e UIApplication.h, and UIApplication.m). So, if you create you class name "UIApplication". this error will occur. Same case for also 3rd party framework.

How do I solve class name conflicts when creating an iOS framework?

I am writing an iOS framework Foo that depends on a static third-party library Lib and have problems getting the linking right.
If Foo was a static library, I would not link it against Lib, and only link the master project against both of them. But this approach does not seem to work with a framework: the linker complains about missing symbols from Lib.
So I took the other approach and linked Foo against Lib. Now the linker is happy, but there’s an obvious catch: if the master project uses Lib for its own reasons and links both against Foo and Lib, I get duplicate symbols:
Class <Something> is implemented in both <Here> and <There>.
One of the two will be used. Which one is undefined.
I know I can stop linking the app against Lib and all will be fine, but I’d like to get things right. How?
I was able to get this working for a framework, though the docs say it should work for a static library as well.
What I did is link the master project against both Foo and Lib as you say. Now Foo has "missing symbol" errors. Select the Foo target and go to Other Linker Flags. Add -weak_framework Lib and presto! the linker will stop complaining. The duplicate symbol runtime errors go away.
According to the docs:
The -weak_framework option tells the linker to weakly link all symbols in the named framework. If you need to link to a library instead of a framework, you can use the -weak_library linker command instead

Xcode gives Apple Mach-O linker error

I just compiled a project and Xcode returns these two errors which don't seem to be my code's fault. How do I fix them?
Undefined symbols for architecture i386:
"_vImageBoxConvolve_ARGB8888", referenced from:
-[UIImage(Blur) boxblurImageWithBlur:] in UIImage+Blur.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Teaching a man (or women) how to fish:
Usually Mach-O Linker Error means you have not included a header file for a function you are using in your code.
Easiest way is to copy that function or method call and paste into Xcode quick search using shift+command+O. This will search all frameworks (and header files), find that function or method call and show you its location (the header in this case):
In this case, this call belongs to the Accelerate framework so on top of your file, enter:
#import <Accelerate/Accelerate.h>
When doing quick search, you might have to get rid of leading underscore. In other words, search for vImageBoxConvolve_ARGB8888
Hope this helps
Google is your friend: someone else fixed this by adding the Accelerate framework to their project (and this does look like a framework error).
https://github.com/rnystrom/RNBlurModalView/issues/5
Make sure you also have the QuartzCore framework included as well, as that is also required by that library.
Apparently vImageBoxConvolve_ARGB8888() is not defined. See if the Accelerate framework is properly included in the project.

Ho can I use adMob library for iOS without using -all_load linker flag

I'm adding adMob provide by google to my iOS app and I'm stuck on this part of the installation:
Add -all_load under Other Linker Flags in the project build info
If I add that flag, then another third party library breaks giving me the error message:
ld: duplicate symbol _vw_chartype_table_p in /Users/josh/ Projects/app/libs/libvt_universal.a(vw_ctype-3279EF26D0C25F3A.o) and / Users/josh/Projects/app/libs/ libvt_universal.a(vw_ctype-34AB9EC0B46D954C.o) for architecture i386
Is there any way to use the adMob library without using -all_load? For example, I've tried -force_load $(SOURCE_ROOT)/adMob/libGoogleAdMobAds.a
but
ld: file not found: /Users/USERNAME/Desktop/latest/bbbb/APPNAME/adMob/libGoogleAdMobAds.a
The reason Google suggests using -all_load is that they are using categories in their code, and Objective-C libraries with categories are not properly loaded by the llvm linker (well that was the case in 4.3 xcode, not sure about 4.4 with the newer clang).
So, I guess if you are brave you can try to just remove the all_load flag. It should build fine. If the bug is NOT fixed, what will happen is when you run your code, it will crash, since none of the categories the library uses will have been loaded. This might be a good thing to do in any case, as your project should build, and if it does not you can fix those problems first.
What I do suggest you do is use -force_load, which has llvm load the categories in the adMob library (among other things). To use it you MUST have a fully qualified path (ie starts at '/') to the library. Obviously if you use Terminal and run:
ls -l /Users/USERNAME/Desktop/latest/bbbb/APPNAME/adMob/libGoogleAdMobAds.a
its going to fail. So enter the proper path - hard coded - for now to just see if you can get the project to first build, then run. If it does you can later figure out what is the appropriate $(VAR) to use to find it inside your project.

Resources