1.设置相关
1.1选择Build setting 中Mach-type 为static
1.2.选中build Avtive Architecture Only 为NO
1.3.选中Build Library for distribution 为 Yes(会生产一个swift module interface的文件,用户点击你的头文件能跳转到声明方法)
2.文件的访问控制
2.1.需要暴露给OC的方法或者类需要加@objc public
2.2.需要暴露给Swift的方法或者类名public以上的访问权限就可以
2.3.默认是internal访问权限,不会暴露给外界,只在本module可见
3.打包发布
3.1 .打包Release模式的模拟器(arm64, x86_64, i386)和真机包(arm64, armv7)
3.2.查看framework支持的架构
lipo -info xxx.framework/xxx
3.3.合并framework为xcframework(包含多种架构的framework,上架AppStrore时候会自动选中合适的架构的framework),
命令:
xcodebuild -create-xcframework \
-framework iphoneos/xxx.framework \
-framework iphonesimulator/xxx.framework \
-output "xxx.xcframework"
4.查看framework支持的架构和库类型(dynamic, static)
file xxx.framework/xxx
返回示例:
LebooSmartSDK.framework/LebooSmartSDK: Mach-O universal binary with 4 architectures: [arm_v7:current ar archive] [i386] [x86_64] [arm64]
LebooSmartSDK.framework/LebooSmartSDK (for architecture armv7): current ar archive
LebooSmartSDK.framework/LebooSmartSDK (for architecture i386): current ar archive
LebooSmartSDK.framework/LebooSmartSDK (for architecture x86_64): current ar archive
LebooSmartSDK.framework/LebooSmartSDK (for architecture arm64): current ar archive
current ar archive:说明是静态库,选择Do not embed
Mach-0 dynamically:说明是动态库,选择Embed
5.发布到cocoapod
#1.创建podspec文件
pod spec create xxxx
#2.创建pod账号
pod trunk register 邮箱地址 '用户名' --verbose
接下来注册的邮箱地址会收到https://trunk.cocoapods.org/sessions/verify/xxxxx的验证地址,打开就算是注册成功。
#3.查看自己发布的开源库
pod trunk me
#4.验证podsped格式是否正确
pod lib lint xxxx.podspec --allow-warnings
#5.添加tag
git tag -a 版本号 -m "描述"
#6.发布到cocoapods --skip-import-validation 爆出编译错误后加
pod trunk push xxxx.podspec --allow-warnings
podspec格式
#
# Be sure to run `pod spec lint LebooSmartSDK.podspec.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#
Pod::Spec.new do |spec|
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# These will help people to find your library, and whilst it
# can feel like a chore to fill in it's definitely to your advantage. The
# summary should be tweet-length, and the description more in depth.
#
spec.name = "LebooSmartSDK"
spec.version = "1.0.1"
spec.summary = "智能牙刷SDK"
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
spec.description = <<-DESC
刷牙SDK
DESC
spec.homepage = "https://gitee.com/JamesLEO/leboo-smart-sdk"
# spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Licensing your code is important. See https://choosealicense.com for more info.
# CocoaPods will detect a license file if there is a named LICENSE*
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
#
# spec.license = "MIT (example)"
spec.license = { :type => "Apache", :file => "./LICENSE" }
# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the authors of the library, with email addresses. Email addresses
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
# accepts just a name if you'd rather not provide an email address.
#
# Specify a social_media_url where others can refer to, for example a twitter
# profile URL.
#
spec.author = { "fenglei" => "fengleicoder@163.com" }
# Or just: spec.author = "fenglei"
# spec.authors = { "fenglei" => "fengleicoder@163.com" }
# spec.social_media_url = "https://twitter.com/fenglei"
# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform.
#
spec.platform = :ios
# spec.platform = :ios, "10.0"
# When using multiple platforms
spec.ios.deployment_target = "10.0"
# spec.osx.deployment_target = "10.7"
# spec.watchos.deployment_target = "2.0"
# spec.tvos.deployment_target = "9.0"
# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP.
#
spec.source = { :git => "https://gitee.com/JamesLEO/leboo-smart-sdk.git", :tag => "#{spec.version}" }
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any swift, h, m, mm, c & cpp files.
# For header files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
#
# spec.source_files = "Classes", "Classes/**/*.{h,m}"
# spec.exclude_files = "Classes/Exclude"
# spec.public_header_files = "Classes/**/*.h"
# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
#
# spec.resource = "icon.png"
# spec.resources = "Resources/*.png"
# spec.preserve_paths = "FilesToSave", "MoreFilesToSave"
# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
#
spec.vendored_frameworks = "LebooSmartSDK.xcframework"
# spec.framework = "SomeFramework"
# spec.frameworks = "SomeFramework", "AnotherFramework"
# spec.library = "iconv"
# spec.libraries = "iconv", "xml2"
# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works.
# spec.requires_arc = true
# spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# spec.dependency "JSONKit", "~> 1.4"
end
网友评论