我应该如何以静态库的形式分发iOS SDK?

发布于 2024-11-13 06:33:24 字数 224 浏览 3 评论 0原文

我目前正在为 iOS 编译一个静态库,我们称之为 libMySDK.a。我复制最终用户需要的所有头文件,并将它们放入 libMySDK.a 的文件夹中。这个文件夹可以拖到一个新的 Xcode 项目中,如果我在新项目的构建设置中设置 -all_load 链接器标志(在“其他链接器标志”下),一切都会按预期工作。

我从未分发过静态库 - 如果您想使用 MySDK,您会期望收到一个包含一些头文件和 .a 文件的文件夹吗?

I'm currently compiling a static library for iOS, let's call it libMySDK.a. I copy any header files that the end user will need and put them into a folder with libMySDK.a. This folder can be dragged into a new Xcode project and everything works as expected if I set the -all_load linker flag in the build settings of the new project (under 'Other Linker Flags').

I have never distributed a static library - is a folder with a few header files and a .a file what you would expect to receive if you wanted to use MySDK?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

物价感观 2024-11-20 06:33:24

Openfeint 提供其框架作为静态框架。我们可以使用该框架作为 iOS SDK 中的框架。

请查看 github - Eskipol/OpenFeint-iOS-框架。打开 OpenFeint 项目并深入研究“OpenFeint-iOS”目标。它有“构建静态库”、“构建通用库”、“复制标头”和“复制资源”阶段。这些阶段有 shell 脚本来创建静态框架。它将帮助您分发静态库。

已编辑:

关键在于“构建通用库”阶段的 shell 脚本。正确创建框架目录(Versions/A/Headers 和 Resources),从编译的静态库创建通用二进制文件,复制标头和通用二进制文件,并正确创建符号链接。

# Create framework directory structure.
rm -rf "${FRAMEWORK}" &>/dev/null
mkdir -p "${UNIVERSAL_LIBRARY_DIR}"
mkdir -p "${FRAMEWORK}/Versions/A/Headers"
mkdir -p "${FRAMEWORK}/Versions/A/Resources"

# Generate universal binary from desktop, device, and simulator builds.
lipo "${SIMULATOR_LIBRARY_PATH}" "${DEVICE_LIBRARY_PATH}" -create -output "${UNIVERSAL_LIBRARY_PATH}"

# Move files to appropriate locations in framework paths.
cp "${UNIVERSAL_LIBRARY_PATH}" "${FRAMEWORK}/Versions/A"
cd "${FRAMEWORK}"
ln -sf "A" "Versions/Current"
ln -sf "Versions/Current/Headers" "Headers"
ln -sf "Versions/Current/Resources" "Resources"
ln -sf "Versions/Current/${PRODUCT_NAME}" "${PRODUCT_NAME}"

Openfeint provides its framework as a Static Framework. We can use the framework as a Framework from iOS SDK.

Please take a look at github - Eskipol/OpenFeint-iOS-Framework. Open OpenFeint project and dive into the "OpenFeint-iOS" target. It has 'Build static lib', 'Build universal lib', 'Copy Headers' and 'Copy Resources' phases. These phases have shell script to create a Static Framework. It would help you to distribute your static library.

EDITED:

The essential is in the shell script for 'Build universal lib' phase. Create framework directory properly (Versions/A/Headers and Resources), create universal binary from the compiled static libraries, copy headers and the universal binary, and create symbolic links properly.

# Create framework directory structure.
rm -rf "${FRAMEWORK}" &>/dev/null
mkdir -p "${UNIVERSAL_LIBRARY_DIR}"
mkdir -p "${FRAMEWORK}/Versions/A/Headers"
mkdir -p "${FRAMEWORK}/Versions/A/Resources"

# Generate universal binary from desktop, device, and simulator builds.
lipo "${SIMULATOR_LIBRARY_PATH}" "${DEVICE_LIBRARY_PATH}" -create -output "${UNIVERSAL_LIBRARY_PATH}"

# Move files to appropriate locations in framework paths.
cp "${UNIVERSAL_LIBRARY_PATH}" "${FRAMEWORK}/Versions/A"
cd "${FRAMEWORK}"
ln -sf "A" "Versions/Current"
ln -sf "Versions/Current/Headers" "Headers"
ln -sf "Versions/Current/Resources" "Resources"
ln -sf "Versions/Current/${PRODUCT_NAME}" "${PRODUCT_NAME}"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文