How should I distribute an iOS SDK in the form of a static library?
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?
Openfeint provides its framework as a Static Framework. We can use the framework as a Framework from iOS SDK.
- "Add OpenFeint as a framework" in Readme for OpenFeint iOS SDK 2.10.1
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}"
精彩评论