iOS: How to create an independent framework
I am creating a little SDK, I want to release a Foo.framework. What I have done is the following:
1- Create a project framework.
2- Add my code.
3- Add an agregator.
In the Agregator Build Phases I added the this run script
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
//make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
//Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos  BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
//Step 2. Copy the framework structure (from iphoneos build) to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
//Step 3. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
//Step 4. Convenience step to copy the framework to the project's directory
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"
//Step 5. Convenience step to open the project's directory in Finder
open "${PROJECT_DIR}"Then I build the Agregator and get the Foo.framwork My problem is, to be able to use the framework in another application I should:
step 1 - drag and drop the framework to my project.
step 2- And add it to the embedded binaries.
If I don't do the step 2 I get this error
dyld: Library not loaded: @rpath/Foo.framework/Foo
Referenced from: /private/var/mobile/Containers/Bundle/Application/00A2E4FD-23F4-43E8-AA85-505785A4FF16/foo.app/foo
Reason: image not foundFor All People facing this kind of issue the solution is here. Just follow those instruction to build a Framework
https://github.com/jverkoey/iOS-Framework#walkthrough
链接地址: http://www.djcxy.com/p/76414.html上一篇: 在Cocoa Touch Framework中包装静态库
下一篇: iOS:如何创建一个独立的框架
