惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
S
Secure Thoughts
S
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cyberwarzone
Cyberwarzone
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Privacy International News Feed
L
Lohrmann on Cybersecurity
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
Google DeepMind News
Google DeepMind News
C
Cybersecurity and Infrastructure Security Agency CISA
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Latest news
Latest news
H
Hacker News: Front Page
月光博客
月光博客
Forbes - Security
Forbes - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
WordPress大学
WordPress大学
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
宝玉的分享
宝玉的分享
D
Docker
U
Unit 42
Recorded Future
Recorded Future
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Recent Announcements
Recent Announcements
云风的 BLOG
云风的 BLOG
Application and Cybersecurity Blog
Application and Cybersecurity Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Heimdal Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
V
Vulnerabilities – Threatpost
Vercel News
Vercel News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
L
LangChain Blog
G
GRAHAM CLULEY
Apple Machine Learning Research
Apple Machine Learning Research
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Blog — PlanetScale
Blog — PlanetScale
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
Help Net Security
Help Net Security
Google Online Security Blog
Google Online Security Blog
S
SegmentFault 最新的问题

博客园 - super1250

技术支持网址 (URL) 填写的地址 通过Homebrew安装CocoaPods iOS游戏内购(记录官网链接) iOS的证书创建 Apple开发者账号注册 __swift_FORCE_LOAD_$_swiftCompatibility50 Validation failed (409) 在 Pod 库中同时使用 Swift 和 Objective-C 拒审原因2.3.4 git生成ssh秘钥 project.pbxproj文件配置详解 录音功能iosSDK iOS内购支付 上架总结 Guideline 3.2.1 清理Cocoapods缓存mac flutter插件 lanh libarclite_iphonesimulator.a模拟器跑不起的问题SDK does not contain 'libarclite' at the path
打包framwork
super1250 · 2024-11-22 · via 博客园 - super1250

https://www.jianshu.com/p/5262d7144651

同事那里搬过来的,防止丢失.

1、新建一个framework工程

2、添加代码

  • 非本地集成的第三方

    添加podfile文件后用Cocoapods集成

  • 本地代码

    把需要打包的项目文件直接拖进来 

设置公开和需要隐藏的代码(需要公开的放Public,隐藏的放Project)

 设置支持的版本

 4、设置Architectures arm64 x86_64

5、设置Mach-O Type static 静态库

framework可以是动态库也可以是静态库,对于系统的framework是动态库,而用户制作的framework只能是静态库

普通framework 的Js代码

#!/bin/sh
#要build的target名
TARGET_NAME=${PROJECT_NAME}
if [[ $1 ]]
then
TARGET_NAME=$1
fi
UNIVERSAL_OUTPUT_FOLDER="${SRCROOT}/${PROJECT_NAME}/"

#创建输出目录,并删除之前的framework文件
mkdir -p "${UNIVERSAL_OUTPUT_FOLDER}"
rm -rf "${UNIVERSAL_OUTPUT_FOLDER}/${TARGET_NAME}.framework"

#分别编译模拟器和真机的Framework
xcodebuild -target "${TARGET_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${TARGET_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build

#拷贝framework到univer目录
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework" "${UNIVERSAL_OUTPUT_FOLDER}"

lipo "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework/${TARGET_NAME}" -remove arm64 -output "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework/${TARGET_NAME}"


#合并framework,输出最终的framework到build目录
lipo -create -output "${UNIVERSAL_OUTPUT_FOLDER}/${TARGET_NAME}.framework/${TARGET_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework/${TARGET_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${TARGET_NAME}.framework/${TARGET_NAME}"

#删除编译之后生成的无关的配置文件
dir_path="${UNIVERSAL_OUTPUT_FOLDER}/${TARGET_NAME}.framework/"
for file in ls $dir_path
do
if [[ ${file} =~ ".xcconfig" ]]
then
rm -f "${dir_path}/${file}"
fi
done
#判断build文件夹是否存在,存在则删除
if [ -d "${SRCROOT}/build" ]
then
rm -rf "${SRCROOT}/build"
fi
rm -rf "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator" "${BUILD_DIR}/${CONFIGURATION}-iphoneos"
#打开合并后的文件夹
open "${UNIVERSAL_OUTPUT_FOLDER}"



# 普通framework 合并 真机模拟器的包
1、终端执行命令:lipo -create 第一个framework文件下二进制文件的绝对路径 第二个framework文件下二进制文件的绝对路径 -output 最终的二进制文件路径   如:lipo -create **/真机/WYBasisKit.framework/WYBasisKit **/模拟器/WYBasisKit.framework/WYBasisKit -output WYBasisKit
2、将合并的二进制文件拖进任何一个framework,替换掉原来的,然后把这个新的framework拖进项目就可以使用了

# XCFramework
xcodebuild -create-xcframework \
-framework /path/to/Release-iphoneos/WYBasisKit.framework \
-framework /path/to/Release-iphonesimulator/WYBasisKit.framework \
-output /path/to/output/WYBasisKit.xcframework






 xcframework的脚本



#!/bin/sh

# 要 build 的 target 名称
TARGET_NAME=${PROJECT_NAME}
if [[ $1 ]]; then
  TARGET_NAME=$1
fi

# 输出目录
XCFRAMEWORK_OUTPUT_FOLDER="${SRCROOT}/${PROJECT_NAME}/"
ARCHIVE_PATH="${SRCROOT}/${PROJECT_NAME}/Archives"

# 创建输出目录并清理之前的文件
mkdir -p "${XCFRAMEWORK_OUTPUT_FOLDER}"
rm -rf "${XCFRAMEWORK_OUTPUT_FOLDER}/${TARGET_NAME}.xcframework"
rm -rf "${ARCHIVE_PATH}"

# 构建 iOS 真机(iphoneos)Framework
xcodebuild archive \
  -scheme "${TARGET_NAME}" \
  -sdk iphoneos \
  -configuration ${CONFIGURATION} \
  -archivePath "${ARCHIVE_PATH}/${TARGET_NAME}-iphoneos.xcarchive" \
  SKIP_INSTALL=NO \
  BUILD_LIBRARY_FOR_DISTRIBUTION=YES

# 构建 iOS 模拟器(iphonesimulator)Framework
xcodebuild archive \
  -scheme "${TARGET_NAME}" \
  -sdk iphonesimulator \
  -configuration ${CONFIGURATION} \
  -archivePath "${ARCHIVE_PATH}/${TARGET_NAME}-iphonesimulator.xcarchive" \
  SKIP_INSTALL=NO \
  BUILD_LIBRARY_FOR_DISTRIBUTION=YES

# 创建 XCFramework
xcodebuild -create-xcframework \
  -framework "${ARCHIVE_PATH}/${TARGET_NAME}-iphoneos.xcarchive/Products/Library/Frameworks/${TARGET_NAME}.framework" \
  -framework "${ARCHIVE_PATH}/${TARGET_NAME}-iphonesimulator.xcarchive/Products/Library/Frameworks/${TARGET_NAME}.framework" \
  -output "${XCFRAMEWORK_OUTPUT_FOLDER}/${TARGET_NAME}.xcframework"

# 清理临时文件
rm -rf "${ARCHIVE_PATH}"

# 打开生成的 XCFramework 文件夹
open "${XCFRAMEWORK_OUTPUT_FOLDER}"