11

I am using cocoa pods to integrate multiple third party files into my project.

I have to integrate below pod into my project

xcodeproj 'MyApp'
workspace 'MyApp'

source 'https://github.com/CocoaPods/Specs.git'

target :"MyApp", :exclusive => true do

  platform :ios, '7.0'

  pod 'AFNetworking', '2.0.2'

  pod 'TwilioSDK', '~>1.2.2'

  pod 'SocketRocket', '0.3.1-beta2'

  pod 'AppRTC'

end

When I run pod install. I get duplicates as shown below..

SRWebSocket.h as duplicates

When I build my app I am getting error

ld: warning: directory not found for option '-L/Users/anand/Documents/
  Project/myApp_Backups/myApp_June/myApp_WEBRTC/Pods/build/Debug-
  iphoneos'
duplicate symbol _MD5_Update in:
    /Users/anand/Documents/Project/myApp_Backups/myApp_June/
  myApp_WEBRTC/Pods/AppRTC/Lib/libWebRTC.a(nss_static.md5.o)
    /Users/anand/Documents/Project/myApp_Backups/myApp_June/
  myApp_WEBRTC/Pods/TwilioSDK/Libraries/libcrypto.a(md5_dgst.o)
duplicate symbol _SHA1_Update in:

duplicate symbol _OBJC_IVAR_$_SRIOConsumer._readToCurrentFrame in:
    /Users/anand/Library/Developer/Xcode/DerivedData/myApp-
  gxdbyoohznnpigavdqmaeilzlavd/Build/Products/Debug-iphoneos/libPods-
  myApp-SocketRocket.a(SRWebSocket.o)
    /Users/anand/Documents/Project/myApp_Backups/myApp_June/
  myApp_WEBRTC/Pods/AppRTC/Lib/libWebRTC.a(socketrocket.SRWebSocket.o)

ld: 71 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I thought to do below solutions:

1) Remove SRWebSocket.h file -- but it may get errors as it is in Pods.

2) Remove pod 'SocketRocket', '0.3.1-beta2' from pod file and run pod install -- but I used both SRWebSocket.h and SRWebSocket.m in my project before installing AppRTC into my project..!

Please suggest how can I solve this issue..

Thanks in Advance..!

MGY
  • 7,245
  • 5
  • 41
  • 74
Vidhyanand
  • 5,369
  • 4
  • 26
  • 59
  • Open your pod file and remove all pods (take copy of those pod file commands) and update the pod file from terminal, and check your project, now again try to paste previously taken commands and past it and save and then try to install pod file – Sri.. Jun 26 '15 at 04:12
  • 1
    After adding files form pods remove your old files and their references. – ganesh manoj Jun 26 '15 at 04:59
  • Both duplicates are there in pods project folder. Can I delete any one duplicate file in it? There are no old files to remove..! – Vidhyanand Jun 26 '15 at 05:12
  • 1
    Contact the maintainer of the AppRTC pod and tell him he needs to mark the SRWebRocket.h file as a private header, so it won't be exposed in your project. Or use SocketRocket as an actual dependency and not include it manually. – Jon Shier Jun 29 '15 at 05:36

7 Answers7

2

Solution

  • Backup your project
  • Close the Xcode
- install this gem on terminal:

https://github.com/kylef/cocoapods-deintegrate

  • run the command line below :

    pod deintegrate

  • remove the Podfile.lock file in your project directory

  • run install again :

    pod install

  • Open Xcode and Clean your project and Derived Data directory then run again

Hope this solution will fix your problem.

Best

MGY
  • 7,245
  • 5
  • 41
  • 74
2

I have fixed the above issue as below

At my Xcode project -- Build Settings -- Other linker Flags -- I removed -all_load then some of the duplicate errors are gone.

Still I get Socket Rocket duplicate warnings after the above solution.

I fixed this by going to Pods Project -- Selected Socket Rocket pods target -- Removed the SRWebSocket.m file from Compiling. It works fine and duplicates are removed.

Thanks for all answers..

Vidhyanand
  • 5,369
  • 4
  • 26
  • 59
2

You need to remove the socketrocket object code from libWebRTC.a

run lipo -info libWebRTC.a to see what architectures are in the library (current version is i386, armv7, and arm64)

Then run

lipo libWebRTC.a -thin i386 -output libWebRTC-i386.a

Do this for each architecture by replacing i386 with the relevant value. You then need to extract the object files from each archive.

mkdir libWebRTC-i386 && cd libWebRTC-i386 && ar -x ../libWebRTC-i386.a

Do this for each of the new single architecture libraries you've just created. In each of the new folders you will find .o files that contain "socketrocket" - delete these.

Then re-archive the object files for each architecture

libtool -static *.o -o ../libWebRTC-i386.a

Once you have done this re-combine them into a fat library

lipo -create libWebRTC-armv7.a libWebRTC-arm64.a libWebRTC-i386.a -output libWebRTC.a

And voila, it should now work. Really the libWebRTC.a binary needs re-building without the socket rocket object code, and socket rocket should be added as a dependency to the podspec.

0

In your build phases, check to see that you aren't compiling the same file more than once.

In your case, maybe there're two same m files in Compile Sources, just remove one and try to rebuild.

Allen
  • 6,745
  • 5
  • 41
  • 59
  • Here libWebRTC.a is getting conflicts with TwilioSDK and SocketRocket. See my question I have specified the conflicts information. How to resolve this issue..! – Vidhyanand Jun 29 '15 at 06:46
0

Follow the below steps to resolve your duplication symbol error.

1) Select your Xcode Project > Navigate to "Build Phases".

2) From there, search the file name for which you are getting duplication.

3) If possible, then there might be more than one ".m files" for your search keyword.

4) Remove all the files except one which you need to actually compile.

5) Same way follow the process for all the duplicate error

6) That's it! Your problem will be solved for sure.

Sohil R. Memon
  • 9,404
  • 1
  • 31
  • 57
  • I did not find any duplicate files at Compile sources..! I think duplicates are coming at .a files duplicate symbol _MD5_Update in: myApp_WEBRTC/Pods/AppRTC/Lib/libWebRTC.a(nss_static.md5.o) myApp_WEBRTC/Pods/TwilioSDK/Libraries/libcrypto.a(md5_dgst.o) duplicate symbol _SHA1_Update in: Here libWebRTC.a and /libcrypto.a are getting conflicts.! – Vidhyanand Jun 29 '15 at 06:43
  • Yeah! Delete any one of the file and try to compile – Sohil R. Memon Jun 29 '15 at 06:49
  • Thanks for answering.. I removed the duplicate file SRWebSocket.m at Pods Project then the duplicate issue is resolved..! – Vidhyanand Jul 06 '15 at 04:26
0

Create an issue for AppRTC repo to remove the header and set a dependency on SRWebSocket instead. As a temporary solution - link AppRTC to a local path with :path directive and remove this file from the local directory. Or you may link to a local podspec file with ignorance on SRWebSocket header in exclude_files config.

Sega-Zero
  • 3,034
  • 2
  • 22
  • 46
-4

Now it's very easy to remove duplicate pod files or any pod which is not in use for your project.

  1. open your pod file.
  2. comment all pod file which you want to remove.

    enter image description here

  3. use commend pod install

  4. you will your all comment pod will remove in terminal

Enjoy your day with a cup of tea or coffee while doing code.

Anup Gupta
  • 1,993
  • 2
  • 25
  • 40