Use the AR command to delete the. o file that was repeatedly compiled by the iOS static library

Source: Internet
Author: User

About Xcode introducing third-party static class libraries duplicate symbol _objc_xxx repeating compilation errors

Look at this http://www.cnblogs.com/cocoajin/p/3917709.html.

Two ways were mentioned before;

One is to modify the Xcode compilation option; one is to remove a party while packaging;

There is a third way today;

Remove the specified duplicate compiled. o file directly in one of the packages using the AR command;

The following scenario demonstrates

Static library libtaobao.a with CEO.M file and CEO method

Static library libbaidu.a compiled with CEO.M files and has CEO method

Then when the above two static libraries appear in the same project, and the other link flag is-all_load, there will be a duplicate compilation error!

From what we can see is ceo.o this file is compiled repeatedly, then from the above two libraries any one of them can be removed

This time to solve the idea:

1. Use Lipo to split. A separately

2. Use the AR command to delete one of the. a conflicts. O

3. Merging with Lipo

The following demo,

Cocoapro:lib-taobao cocoajin$lsLibTaobao.acocoaPro:lib-taobao cocoajin$ Lipo-InfoLIBTAOBAO.A ArchitecturesinchThe Fatfile: libtaobao.a are:armv7 arm64 cocoapro:lib-taobao cocoajin$ Lipo Libtaobao.a-thin ARMV7-Output Tbv7.acocoaPro:lib-taobao cocoajin$ Lipo Libtaobao.a-thin arm64-Output Tb64.acocoaPro:lib-taobao cocoajin$lslibtaobao.a tb64.a tbv7.acocoaPro:lib-taobao cocoajin$ Lipo-Infotb*inputfileTB64.A is not a fatfileinputfileTBV7.A is not a fatfileNon-fatfile: tb64.a is Architecture:arm64non-fatfile: tbv7.a is Architecture:armv7cocoaPro:lib-taobao cocoajin$ar-d tbv7.a CEO.ococoaPro:lib-taobao cocoajin$ar-d tb64.a CEO.ococoaPro:lib-taobao cocoajin$ lipo-create tbv7.a tb64.a-Output LibTaobao.acocoaPro:lib-taobao cocoajin$ Lipo-InfoLIBTAOBAO.A ArchitecturesinchThe Fatfile: libtaobao.a are:armv7 arm64 cocoapro:lib-taobao cocoajin$
View Code

After finally replacing the library that removed CEO.O, the project compiles through and runs normally!

Use the AR command to delete the. o file that the iOS static library repeatedly compiles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.