美文网首页OC进化iOS开发iOS学习开发
史上最简单的包冲突解决方法

史上最简单的包冲突解决方法

作者: 函冰 | 来源:发表于2017-11-01 14:44 被阅读20次
    在日常开发中,我们会导入各种各样的包,有时候会遇到两个包之间相互冲突。那么在我们不能换包的情况下,只能对包内冲突的文件进行更改。我遇到的就是在嵌入unity3D的时候和百度地图的包有冲突duplicate symbol _fopen_file_func。
    我叫杜甫,我很忙.png
    一般情况下,出冲突后会有这样的个错误。
    警告错误警告错误
    这就需要我们对应的解决了。
    1. cd进入到相互冲突的一个包内,查看这个包所支持的模式,以下这个例子只有两种,还有其他的如: armv7s i386 x86_64
    $ cd ~/LibraryConflictExample/XCodeProject/PPAppPlatformKit.framework/
    $ lipo -i PPAppPlatformKit   //如果是.a文件可以直接跳过上面的不过后面的额文件地址要是拽出来的路径/LibraryConflictExample/XCodeProject/PPAppPlatformKit.framework/ 这种
    Architectures in the fat file: PPAppPlatformKit are: armv7 arm64
    
    1. 创建相应的模式对应的包,并将对应的模式文件储存进去
    $ lipo PPAppPlatformKit -thin armv7 -output PPAppPlatformKit.armv7
    $ lipo PPAppPlatformKit -thin arm64 -output PPAppPlatformKit.arm64
    $ ls -l
    total 29496
    drwxr-xr-x@ 5 dennis  staff   170B  8 23 12:26 Headers/
    -rw-r--r--  1 dennis  staff   773B  8 23 12:26 Info.plist
    drwxr-xr-x@ 3 dennis  staff   102B  7 11 18:32 Modules/
    -rw-r--r--  1 dennis  staff   7.2M  8 23 12:26 PPAppPlatformKit
    -rw-r--r--  1 dennis  staff   3.7M  8 23 12:26 PPAppPlatformKit.arm64
    -rw-r--r--  1 dennis  staff   3.4M  8 23 12:26 PPAppPlatformKit.armv7
    drwxr-xr-x@ 6 dennis  staff   204B  8 23 12:26 _CodeSignature/
    -rw-r--r--@ 1 dennis  staff    12K  7 11 18:32 embedded.mobileprovision
    
    1. 接下来就是查找里面包含的文件,看是否有错误信息里面对应的文件
      ar -t 包名.x86_64
    
    2
    3
    4
    5
    6
    7
    8
    9
    $ ar -t PPAppPlatformKit.armv7
    ...
    ioapi.o
    ...
     
    $ ar -t PPAppPlatformKit.arm64
    ...
    ioapi.o
    ...
    
    1. 删除上面警告提示的所有错误文件 ar -d -sv 上一步生成的对应的包 删除的文件,如果你的这个包支持多少种模式,都要删除里面对应的文件比方支持armv7 就删除PPAppPlatformKit.armv7对应的文件,若支持armv7s i386 x86_64 等多种,就一个个的对应删除
    
    2
    3
    4
    5
    $ ar -d -sv PPAppPlatformKit.armv7 ioapi.o
    d - ioapi.o
     
    ar -d -sv PPAppPlatformKit.arm64 ioapi.o
    d - ioapi.o
    
    1. 在删除之后进行文件更新,里面该更改的更改为项目对应的名称
    $ mv PPAppPlatformKit PPAppPlatformKit.original // 기존 바이너리 백업
    $ lipo PPAppPlatformKit.armv7 PPAppPlatformKit.arm64 -create -output PPAppPlatformKit
    
    

    参考链接
    好了这样基本就解决了所遇到的包冲突问题。

    相关文章

      网友评论

        本文标题:史上最简单的包冲突解决方法

        本文链接:https://www.haomeiwen.com/subject/kxfgpxtx.html