我们的目标C创建框架,它的工作完美。
通过按照以下简单步骤来创建框架
1)创建新的框架,
在Xcode选择
file =>New =>Project =>cocoatouchframework =>Next =>GiveframeworkName =>Create
2)添加h和.M项目中的文件,用于创建框架。
3)在构建阶段添加公共标题中的文件,该文件将显示在您的框架中。
4)点击项目名称DemoFramework然后选择+按钮,然后选择
Cross-platform =>Aggregate
5)添加运行脚本
6)将下面的代码添加到运行脚本中,以汇总(marge)iPhone和模拟器框架。
# ============Script Start==============
if [ "${ACTION}" = "build" ]
then
# Set the target folders and the final framework product.
INSTALL_DIR=${SYMROOT}/DemoFramework.framework
DEVICE_DIR=${SYMROOT}/Debug-iphoneos
SIMULATOR_DIR=${SYMROOT}/Debug-iphonesimulator
# Create and renews the final product folder.
mkdir -p "${INSTALL_DIR}"
rm -rf "${INSTALL_DIR}"
rm -rf "${INSTALL_DIR}/DemoFramework"
# Copy the header files to the final product folder.
ditto "${DEVICE_DIR}/DemoFramework.framework/Headers"
"${INSTALL_DIR}/Headers"
# Copy the info.plist file to the final product folder
ditto "${DEVICE_DIR}/DemoFramework.framework/info.plist"
"${INSTALL_DIR}"
# Copy the ResoureBundle.bundle file to the final product folder
ditto "${DEVICE_DIR}/DemoFramework.framework/ResourceBundle.bundle"
"${INSTALL_DIR}/ResourceBundle.bundle"
# Use the Lipo Tool to merge both binary files (i386 + armv6/armv7)
into one Universal final product.
lipo -create "${DEVICE_DIR}/DemoFramework.framework/DemoFramework"
"${SIMULATOR_DIR}/DemoFramework.framework/DemoFramework" -output
"${INSTALL_DIR}/DemoFramework"
fi
# ============Script End==============
7)现在建项目分三步
1)建立的iPhone设备。
您将看到iPhone设备创建框架,框架的位置是在显示如下项目得出的数据。
2)构建用于模拟器。
您将看到模拟器创建框架,框架的位置是在显示如下项目得出的数据。
3)这是最后一步创建框架,构建选项 选择Aggregate和构建应用程序见下面的屏幕截图。
最后,您的框架在任何应用程序中都使用此框架,框架位置在派生数据如下。
希望这简单的步骤,帮助别人创造客观的框架C.
这个。另外,不要被环视操作系统愚弄。操作系统被允许(并且确实)销售和使用共享的动态库框架,而非OS操作系统开发者则不能。如果你仔细想想,它在iOS上并不会给你带来太多的收益:你的应用运行在它自己的沙盒中,并且允许平台上的任意共享动态库可能会破坏这个机制(至少这会让事情变得复杂) 。我不会屏住呼吸等待这个。 – ipmcc 2011-03-22 13:03:28
谢谢Williham,但是我创建了一个扩展名为.x的框架,但是它是C代码。例如:pjzip。 – 2011-03-24 04:28:38
啊,但你可以伪造一个包含静态库的框架。单个实例不会在应用程序之间共享,因此每个应用程序都将拥有自己的副本。但是该框架比静态库+标头更容易管理。 – 2011-05-18 15:52:58