0

I have been facing this lingering issue. When I try to Build the project by selecting iOS device in my Xcode it builds the code with out any error but when I trying the same with iOS simulator it shows me the following error. Is there any way to avoid this library file when I build in Simulator? I have tried the following Link as well but i couldn't figure the exact solution.

Thanks In Advance.

6 duplicate symbols for architecture i386

ld: warning: ignoring file /Users/iOS-MobileTeam/Downloads/iOS/LibraryFiles/libANMobilePaymentLib.a, missing required architecture i386 in file /Users/iOS-MobileTeam/Downloads/iOS/LibraryFiles/libANMobilePaymentLib.a (2 slices)
    duplicate symbol _des_set_key in:
        /Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-524F6BE9122BCA82.o)
        /Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-D9CE0CBEE0B3BA81.o)
    duplicate symbol _des_encrypt in:
        /Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-524F6BE9122BCA82.o)
        /Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-D9CE0CBEE0B3BA81.o)
    duplicate symbol _des_decrypt in:
        /Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-524F6BE9122BCA82.o)
        /Users/iOS-MobileTeam/Downloads/iOS/LineaSDK/libdtdev.a(des-D9CE0CBEE0B3BA81.o)
    ld: 3 duplicate symbols for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    Ignoring file /Users/iOS-MobileTeam/Downloads/iOS/LibraryFiles/libANMobilePaymentLib.a, missing required architecture i386 in file /Users/iOS-MobileTeam/Downloads/iOS/LibraryFiles/libANMobilePaymentLib.a (2 slices)
Community
  • 1
  • 1
Peer Mohamed Thabib
  • 636
  • 2
  • 9
  • 29

3 Answers3

2

The static library is broken as it contains two separate object files containing the same symbols (functions).

It must be rebuilt, or if you don't have the source you could unpack it, remove the offending file, and then re-pack it (untested):

$ mv libdtdev.a libdtdev-old.a
$ mkdir xxx
$ cd xxx
$ ar x ../libdtdev-old.a
$ rm des-D9CE0CBEE0B3BA81.o
$ ar cr ../libdtdev.a *.o
$ cd ..
$ rm -rf xxx

However if the static library contains multiple architectures, this becomes much more complicated.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
  • #trojanfoe Could you please elaborate me on this? I have the static library file. I don't know how to unpack it. I need your help. – Peer Mohamed Thabib Nov 20 '14 at 08:29
  • Do I need to execute those comments in terminal to unpack it? – Peer Mohamed Thabib Nov 20 '14 at 08:33
  • Yes that's right. If that file is duplicated when it's likely that there are other duplicate object files as well. Have a look at the files that are unpacked from the archive see if they look like dupes. – trojanfoe Nov 20 '14 at 08:36
  • When I execute the first command I am getting the following error: do I need to select the exact path where the library exist? mv libdtdev.a libdtdev-old.a mv: rename libdtdev.a to libdtdev-old.a: No such file or directory – Peer Mohamed Thabib Nov 20 '14 at 08:40
  • You know what? I cannot be bothered to help you further as you do not even possess simple command line skills or the basic understanding of a *user*, let alone a *developer*. This site is filled with clueless people who do not deserve my time. Get someone else to help you. – trojanfoe Nov 20 '14 at 08:41
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/65267/discussion-between-peer-mohamed-thabib-and-trojanfoe). – Peer Mohamed Thabib Nov 20 '14 at 08:42
  • "Let us continue this discussion in chat" You've got to be f'ing kidding! – trojanfoe Nov 20 '14 at 08:43
0

The issue is that your libANMobilePaymentLib.a static archive was not built properly. If that is a 3rd party library, you should ask the author to provide an updated version which addresses this issue, and trojanfoe's instructions on unpacking and repacking the archive without one of the des implementations is probably your best bet for a temporary workaround.

If you built the library yourself or want to pass on information to the author, the issue is that the library's i386 slice contains duplicates of the des_set_key, des_encrypt, and des_decrypt symbols. I suspect that this was caused by accidentally including des.c twice when building libANMobilePaymentLib.a. Another possibility is that the author of libANMobilePaymentLib.a intended those functions to be static and not exported.

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
-1

Finally I found the fix for the above issue. all credit goes to @Khanh

How to ignore some static library for iOS simulator

The above link helped me to fix the issue.

Steps to Fix The Issue:

  1. Go to Project Build Settings and search for other linker flags. 2.Expand The other linker flags section. There will be two modes Debug and Release
  2. Place the cursor over Debug Mode a + symbol will appear.
  3. Click the plus Symbol.
  4. A new option will be added like Any Architecture | Any SDK.
  5. Change that Any SDK to Any iOS Simulator SDK
  6. Set -objC Value for Any iOS Simulator SDK

enter image description here

Community
  • 1
  • 1
Peer Mohamed Thabib
  • 636
  • 2
  • 9
  • 29
  • 1
    That's not really a solution to the problem here. That is a solution to a different problem which causes your problem to not manifest. The issue in this case is that you are now no longer using -all_load which is then causing the linker to omit portions of your static archive (including the duplicate symbols) because it determined that they were not being utilized. If those symbols had actually been used/needed by your framework, you would once again get the error you are reporting. – Jeremy Huddleston Sequoia Nov 20 '14 at 17:37