一、场景
最近在集成数据库sqlite开发,在集成的过程中,需要加入库文件支持libsqlite3, 在添加这个库的时候也遇到过一个坑:
在usr/lib 目录下:
千万不要被上面那个3.0.dylib 的快捷方式给欺骗了,切记切记,不然链接的时候各种报错。
在集成完之后,直接真机调试功能正常。忽然有一天,用了一下archive 打包ipa ,出现如下问题:
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2122:in `GetMachOImagesFromOToolInfoForFile'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2208:in `MakeFileSystemNode'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2236:in `block in MakeFileSystemNode'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2235:in `each'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2235:in `MakeFileSystemNode'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2236:in `block in MakeFileSystemNode'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2235:in `each'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2235:in `MakeFileSystemNode'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1871:in `initialize'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2957:in `new'
/Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2957:in `ProcessIPA'
/Applications/Xcode.app/Conte
2022-04-01 02:18:18 +0000 nts/Developer/usr/bin/ipatool:3928:in `
Removing temporary directory /var/folders/f6/cf9jzw8s6lb440mfc4k6dpwc0000gn/T/ipatool20220401-53994-3xigot...
$ rm -r /var/folders/f6/cf9jzw8s6lb440mfc4k6dpwc0000gn/T/ipatool20220401-53994-3xigot
2022-04-01 02:18:18 +0000 /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool exited with 1
2022-04-01 02:18:18 +0000 ipatool JSON: {
二、问题分析
日志中并未看到明显的提示错误原因,只知道ipatool 在执行的时候失败了。于是就又在网上查找解决方案,搜索到的有的说是ios13之后不支持 32位打包之类的,需要删除某些模拟器等等,但是我这边看到的日志没有提到和那个相关的于是放弃这个思路。
不过总是觉得肯定和引入的这个sqlite库有关系,忽然有一天,不知怎地,突发奇想,改了一下xcode中对这个库的embed 方式,之前添加的时候是默认,也没在意是哪个,于是随手已改,改成了Do not Embed 状态,然后尝试了一把,居然可以了。
于是又来学习了下ios 编译链接库的知识,之前其实看过一篇介绍:
iOS静态库与动态库的区别与打包 - 简书
xcode 上面选择编译库有三种方式: Do not embeded 不嵌入, embed 嵌入, embed & sign 嵌入并且签名。
.framework 既可能是静态库,也可能是动态库。
判断方法,使用file 命令:
file GTSDK.framework/GTSDK
current ar archive 静态库
GTSDK.framework/GTSDK: Mach-O universal binary with 4 architectures: [arm_v7:current ar archive] [i386] [x86_64] [arm64]
GTSDK.framework/GTSDK (for architecture armv7): current ar archive
GTSDK.framework/GTSDK (for architecture i386): current ar archive
GTSDK.framework/GTSDK (for architecture x86_64): current ar archive
GTSDK.framework/GTSDK (for architecture arm64): current ar archive
Mach-O dynamically 动态库
file HikVideoPlayer.framework/HikVideoPlayer
HikVideoPlayer.framework/HikVideoPlayer: Mach-O universal binary with 2 architectures: [arm_v7:Mach-O dynamically linked shared library arm_v7] [arm64]
HikVideoPlayer.framework/HikVideoPlayer (for architecture armv7): Mach-O dynamically linked shared library arm_v7
HikVideoPlayer.framework/HikVideoPlayer (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64
sign 签名只用于动态库
codesign -dv HikVideoPlayer.framework/
HikVideoPlayer.framework/: code object is not signed at all
所以对于这个动态库,需要配置 embed & sign 模式
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)