编程技术记录

世界你好!

引用

libarchive源码 https://github.com/libarchive/libarchive/tree/v3.7.4

cmake工具手册
https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-visionos-or-watchos

基本操作

需要安装cmake(brew install cmake)

然后使用cmake为libarchive配置xcode工程

cd 源码目录
cmake -S. -B_builds -GXcode -DCMAKE_SYSTEM_NAME=iOS #结果输出到_builds文件夹

一般会遇到以下错误

CMake Error at cat/CMakeLists.txt:33 (INSTALL):
  INSTALL TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable
  target "bsdcat".

CMake Error at tar/CMakeLists.txt:46 (INSTALL):
  INSTALL TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable
  target "bsdtar".

CMake Error at cpio/CMakeLists.txt:42 (INSTALL):
  INSTALL TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable
  target "bsdcpio".

CMake Error at unzip/CMakeLists.txt:37 (INSTALL):
  INSTALL TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable
  target "bsdunzip".

以上错误的原因是iOS App并不支持MACOSX_BUNDLE,在CMakeLists.txt中注释对应的INSTALL动作就可以了

  例如对于bsdtar ,打开tar/CMakeLists.txt ,搜索以下两行,加上 # 注释
 # INSTALL(TARGETS bsdtar RUNTIME DESTINATION bin)
 # INSTALL_MAN(${bsdtar_MANS})

最后,删除输出文件夹(_builds文件夹),重新执行cmake命令

发表回复

© Beli. All Rights Reserved.