注意事项
- 是否仅构建活动架构,设置为No,即不仅只编译当前所选架构。
-
Build Active Architecture Only
-
- 设置 Framework 为静态库类型
-
Mach-O Type
-
设置 Framework 为分发而构建,对于Swift,支持Swift标准库的演变和模块接口文件的生成,即提供给他人使用时,Xcode中Swift版本向下兼容,转换 xcframework 需要设置为YES。
-
Build Libraries for Distribution
-
-
是否启用死代码剥离,即编译选项优化,对于制作Framework,
应该设置为No, 不启用代码剥离。-
Dead Code Stripping
-
-
移除模拟器中生成的arm64架构,非必须操作,模拟器 arm64 与真机arm64 类型不一样,
arm64-apple-ios-simulator
、arm64-apple-ios
-
Excluded Architecture
-
-
校验
podspec
文件
-
cd 至
ScanHelper.podspec
文件根目录- 本地校验
ScanHelper.podspec
文件内容规范性
pod lib lint --verbose --allow-warnings --skip-import-validation
- 联网校验远程组件仓库tag版本与本地待发布版本tag一致性
pod spec lint --verbose --allow-warnings --skip-import-validation
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
- 若工程中依赖
私有静态库
,则需要 追加--skip-import-validation
指令
--skip-import-validation
- 注册账户,可以追加一些描述信息
pod trunk register
+邮箱
+用户名
+可选指令
Trunk
帐户没有密码,只有每台计算机的token
令牌pod trunk register it@xxxx.com 'Charlie' --description='macbook pro'
- 点击上述
邮件
中链接,随后执行如下指令进行校验
pod trunk me
- 发布
/
更新组件,至远程仓库(cocoapods.org
)
pod trunk push ScanHelper.podspec --verbose --allow-warnings --skip-import-validation
推送成功,上述邮件随后会下发通知
- 从远程仓库(
cocoapods.org
)删除已发布组件
pod trunk delete ScanHelper 0.0.1
[!] CocoaPods could not find compatible versions for pod "ScanHelper"
- 新版本发布后,且收到邮件提醒,但
install
没有下载成功,
尝试键入如下指令修复问题
pod cache clean ScanHelper pod install --repo-update
- 本地校验
.podspec
文件,常用键值对及相关规则
Pod::Spec.new do |spec|
spec.name = "ScanHelper"
spec.version = "0.0.6"
spec.license = "MIT"
spec.summary = "A lightweight scanning component based on system API in Swift5"
spec.description = <<-DESC
No memory leaks, Support scaling, Support light sense to automatically turn on the flash, Support auto zoom, Support custom UI.
DESC
spec.author = { "Charlie" => "a51095@hotmail.com" }
spec.homepage = "https://github.com/a51095/ScanHelper"
spec.source = { :git => "https://github.com/a51095/ScanHelper.git", :tag => spec.version }
spec.requires_arc = true
spec.swift_version = "5.0"
spec.platform = :ios, "11.0"
spec.ios.deployment_target = "11.0"
spec.static_framework = true
spec.ios.vendored_frameworks = 'lib/ScanHelperSDK.framework'
spec.source_files = "lib/ScanHelperSDK.framework/**/*"
spec.public_header_files = 'lib/ScanHelperSDK.framework/Headers/ScanHelperSDK-Swift.h'
# ======================================================
# spec.ios.exclude_files = 'lib/xxxx.dec' (忽略的文件)
# spec.source_files = 'lib/ScanHelperSDK.framework/**/*'(资源文件)
# spec.public_header_files = 'lib/ScanHelperSDK.framework/Headers/ScanHelperSDK-Swift.h'(Objective-C暴露头文件)
# ======================================================
#💡💡💡😈💡💡💡
# * 匹配所有类型文件
# *.{h,m} 匹配所有以 .h 和 .m 结尾的文件
# ** 匹配所有子目录
#💡💡💡😈💡💡💡
end
常用指令
- 验证某个 framework, 属于动态库还是静态库
- 提示
current ar archive random library
静态库 - 提示
dynamically linked shared library
动态库
- 提示
cd xxxx.framework
file xxxx
- 查看某个 framework, 所支持框架
- 提示
armv7 arm64 armv7s arm64e
- 提示
i386 x86_64
- 提示
lipo -info 路径/xxxx.framework/xxxx
- 打包 xcframework
xcodebuild -create-xcframework -framework a.framework -framework b.framework -output xxxx.xcframework