gpt4 book ai didi

ios - 在 Xcode 6 中部署静态库

转载 作者:行者123 更新时间:2023-11-29 01:55:41 27 4
gpt4 key购买 nike

我想部署一个我一直在 Xcode 6 中编写的静态库。我已经设法将该库编译成一个 .a 文件。现在我想在另一个项目中使用它。另请注意,包括库项目不是一个选项,因为该库应该以二进制形式分发。

我还设法将 .a 文件导入到一个新项目中,但我不确定找到头文件的最佳方法是什么。我应该将它们复制到系统文件夹吗?我应该只链接到框架的(下载的)文件夹吗?我应该直接在项目中导入标题吗?由于该框架用于分发,我认为理想情况下我会将它们复制到系统文件夹中。

最后,我读到如果我希望框架与 iOS 和模拟器都兼容,我需要构建两个不同的版本。这是真的?不能在同一个二进制中分发吗?

最佳答案

我为我的公司分发了这样一个库。我基本上将 .a 文件(用 lipo 构建)与标题一起放入一个文件夹中。然后,客户需要在构建阶段将 .a 文件添加到他们的项目中,将二进制文件与库链接。然后,他们应该使用“用户 header 搜索路径”的项目相对路径将路径添加到 header 文件。来 self 的自述文件:

Process to Add the SDK to Your Project

1) Copy the xxx folder to the app folder, which contains the ".xcodeproj" project file, then add the directory to your project, but don't add it to any targets (unselect the checkbox). 2) Add the appropriate library (iOS 6.0 or 7.0) folder, by going to your target's Build Phase tab, Link Binary with Libraries, tap on "+", then navigate to the appropriate folder and select libXXX.a

3) Add the following to the Project's Build Settings:

  • Search Paths -> Library Search Paths: $PROJECT_DIR/xxx/ios // I have multiple folders each with a lib
  • Search Paths -> User Header Search Paths: $PROJECT_DIR/xxx
  • Linking -> Other Link Flags: -ObjC NOTE: If you fail to do this, your app will crash on launch (if it uses categories)

我也使用 lipo 添加两个 Simulator .a 文件 - 即使这没有得到官方认可。正如其他人所说,Apple 对此表示不满,但并未为您的图书馆用户使用不同的 .a 文件提供简单的方法 - “官方”解决方案是让您编写自定义构建脚本。

关于ios - 在 Xcode 6 中部署静态库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30897042/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com