-
正常新建工程,xcode15,取消User Script Sandboxing
image.png -
新建一个target,选择framework。
image.png
2.1 关闭User Script Sandboxing
image.png
2.2 修改mach-o type
image.png
- 关闭工程,打开目录,进行pod init,修改podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
target 'XXKit' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
#在sdk中用到的第三方库
pod 'AFNetworking', '~> 4.0'
end
target 'XXKitDemo' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'AFNetworking', '~> 4.0'
end
post_install do |installer|
#xcode14.3以上需要部署ios11.0+起步,包括第三方
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
end
#Xcode15.0 版本报错 DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead 的解决办法
installer.aggregate_targets.each do |target|
target.xcconfigs.each do |variant, xcconfig|
xcconfig_path = target.client_root + target.xcconfig_relative_path(variant)
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
end
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.base_configuration_reference.is_a? Xcodeproj::Project::Object::PBXFileReference
xcconfig_path = config.base_configuration_reference.real_path
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
end
end
end
end
3.1 打开workspace,修改一下xxkit的schema,运行状态设置改为release
image.png
-
新建一个target ,Aggregate类型。修改一下Aggregate的schema,运行状态设置改为release
image.png
4.1 关闭User Script Sandboxing
image.png
4.2 添加自动合并framework的脚本,修改一下名称
# Type a script or drag a script file from your workspace to insert its path.
if [ "${ACTION}" = "build" ]
then
#修改一下你的真实的sdk名称
MY_SDK_NAME="XXKit"
INSTALL_DIR=${SRCROOT}/Products/${MY_SDK_NAME}.framework
DEVICE_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphoneos/${MY_SDK_NAME}.framework
SIMULATOR_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphonesimulator/${MY_SDK_NAME}.framework
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"
#ditto "${DEVICE_DIR}/Headers" "${INSTALL_DIR}/Headers"
lipo -create "${DEVICE_DIR}/${MY_SDK_NAME}" "${SIMULATOR_DIR}/${MY_SDK_NAME}" -output "${INSTALL_DIR}/${MY_SDK_NAME}"
#open "${DEVICE_DIR}"
open "${SRCROOT}/Products"
fi
image.png
- 到此完成了架构,正常开发sdk即可。公布头文件,在demo里使用测试就行。需要打包sdk的话,schema选到sdk,真机和模拟器都运行一下,再切换到aggregate的target运行一下,会自动打开framework的目录。
网友评论