iOS:如何创建一个独立的框架
我正在创建一个小SDK,我想发布一个Foo.framework。 我所做的是以下几点:
1-创建一个项目框架。
2-添加我的代码。
3-添加一台agregator。
在Agregator Build Phases中,我添加了这个运行脚本
#!/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}"
然后我构建Agregator并获取Foo.framwork我的问题是,为了能够在另一个应用程序中使用该框架,我应该:
第1步 - 将框架拖放到我的项目中。
步骤2-并将其添加到嵌入式二进制文件中。
如果我不执行第2步,则会出现此错误
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 found
如果我只想通过将框架拖到我的项目中(换句话说,只将它添加到链接二进制库)来简化集成,我应该怎么做。 提前致谢。 对于面临这种问题的所有人来说,解决方案就在这里。 只需按照这些说明构建框架即可
https://github.com/jverkoey/iOS-Framework#walkthrough
链接地址: http://www.djcxy.com/p/76413.html上一篇: iOS: How to create an independent framework
下一篇: How do I create a working framework with dylib files in Xcode 4