发布于 2015-12-31 04:55:39 | 721 次阅读 | 评论: 0 | 来源: PHPERZ
Xcode 编程开发软件
Xcode是苹果公司向开发人员提供的集成开发环境(非开源),用于开发Mac OS X,iOS的应用程序。其运行于苹果公司的Mac操作系统下。
打包bundle文件
1、新建OS X->Framework & Library->Bundle新建
2、在Build Settings->(null)-Deployment->iOS Deployment Target->选择自己需要支持的最低系统。
3、build后会生成一个bundle包,但在包中的图片由以前的png格式全部变成tiff格式。为了防止这种格式转变。需要在Build Settings->Architectures->Base SDK->选择iOS的SDK要支持的版本。这时TARGETS中Build Setting->User-Defined中会出现一个新的Key:COMBINE_HIDPI_DEBUG_INFO,把它设置为NO。
4、这样创建的图片资源不能使用[UIImage imageNamed:@“png”]来获取了。需要使用路径方式来读取图片。
这里我使用了一个函数来获取路径。
NSString *getKaYiKaImageBundlePath(NSString *filename);
NSString *getKaYiKaImageBundlePath(NSString *filename) {
NSBundle *libBundle = [NSBundle bundleWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"KaYiKa.bundle"]];
if (libBundle && filename) {
NSString *path = [[libBundle resourcePath] stringByAppendingPathComponent:filename];
path = [path stringByAppendingString:@".png"];
return path;
}
return nil;
}
使用时直接用
[UIImage imageWithContentsOfFile:getKaYiKaImageBundlePath(@"tool_return_day")]获取图片。
直接导出方法:
1.添加 target --> other -->aggregate
2.在新建的Target里边添加一个脚本:Build Phases -->new Run Script Phase
3.填入下面脚本到 Run Script
# begin =============================================
# Sets the target folders and the final framework product.
# 如果工程名称和Framework的Target名称不一样的话,要自定义FMKNAME
# 例如: FMK_NAME = "MyFramework"
FMK_NAME=${PROJECT_NAME}
# Install dir will be the final output to the framework.
# The following line create it in the root folder of the current project.
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.bundle
# Working dir will be deleted after the framework creation.
WRK_DIR=build
DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.bundle
SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.bundle
# -configuration ${CONFIGURATION}
# Clean and Building both architectures.
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos -arch armv7 -arch armv7s -arch arm64 clean build
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator -arch x86_64 clean build
# Cleaning the oldest.
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"
# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"
rm -r "${WRK_DIR}"
open "${SRCROOT}/Products/"
# end ===============================================