制作通用framework的几点注意

一、创建framework,调成静态的framework

.

二、匹配bitcode 

三、增加-ObjC

在BuildSettting ->Linking->Other Linker Flags

四、将真机和模拟器合并库

在File ->New ->Target ->中选择 Aggrate

给Aggrate target增加一段脚本

脚本可以通用

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}.framework

 

# Working dir will be deleted after the framework creation.

WRK_DIR=build

DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework

SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework

 

# -configuration ${CONFIGURATION}

# Clean and Building both architectures.

xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos clean build

xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator 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 "${INSTALL_DIR}"

 

五、生成framework前将target设为7.0,以匹配iOS7.0以上系统

生成ios bundle时 选择macos 里的Bundle  .然后在build settings里把它的类型调成ios的。

bundle中的bitcode 设为No,因为也和framework中的bitcode 已经设为了YES.

Bundle是不需要签名的,在code sign签名里请选择don't code sign 以及iOS developer. develop team请删除掉。genery里的bundle identifier 以及info.plist文件里的bundle identifier也不需要去管。

具体配置参考老的sdk

在创建Bundle时 info.plist 和build phase里还有需要注意的。

info.plist里不能包含excutable file.

build phase 里只需保留Target Dependencies 和Copy Bundle Resources这两项。

总的原则是新的bundle配置和之前老的Bundle配置一模一样即可。

如果配置有问题的话,在ipa包上传app store的时候会报如下错误。

在生成Framework或者bundle的时候都要记得clean一下,然后将手机设备都拔掉。选择通用设备进行编译。

!!!!!!!!!!!!!!!! 注意一定要检查 info.plist 文件 删除Excutable file.否则在提交iap包的时候会报错,。!!!!!!!!!!!!!!!! 

原文地址:https://www.cnblogs.com/shycie/p/5809070.html