问题描述
我需要在 cocoapods 上发布一个 MySDK.framework(混合 obj-c + Swift).我按照发布通用二进制iOS中的步骤进行操作使用 CocoaPods 的 Swift 框架
当我运行 pod install
时,它说:
分析依赖从 `..` 获取 `MySDK` 的 podspec下载依赖使用 AFNetworking (3.1.0)使用 Crashlytics (3.9.3)使用 FXBlurView (1.6.4)使用织物 (1.7.2)使用 HexColors (2.3.0)使用 JSONModel (1.7.0)使用 KVOController (1.2.0)使用砌体 (1.0.2)使用 SAMKeychain (1.5.3)使用 SDWebImage (3.8.2)使用 SnapKit (3.0.2)使用 SwiftyBeaver (1.2.2)使用 Toast (3.1.0)使用 YYImage (1.0.4)使用 MySDK (0.0.1)生成 Pods 项目整合客户项目发送统计信息Pod安装完成!Podfile 有 1 个依赖项,总共安装了 15 个 Pod.
但是 MySDK.zip 未下载或安装在 Pods 项目中,因此 Xcode 抱怨缺少模块 MySDK(在导入 MySDK 时).
MySDK.podspec
## 请务必运行 `pod lib lint MySDK.podspec' 以确保这是一个# 提交前的有效规范.## 任何以 # 开头的行都是可选的,但鼓励使用它们# 要了解有关 Podspec 的更多信息,请参阅 http://guides.cocoapods.org/syntax/podspec.html#Pod::Spec.new 做 |s|s.name = 'MySDK's.version = '0.0.1's.summary = 'MySDK 的简短描述.'# 此描述用于生成标签和改进搜索结果.# * 思考:它有什么作用?你为什么写它?重点是什么?# * 尽量保持简短、活泼和切中要害.# * 在下面的 DESC 分隔符之间写下描述.# * 最后,不用担心缩进,CocoaPods 把它去掉了!s.description = <<-DESC适用于 iOS 的 MySDK 框架.* TODO:文档在哪里?发展研究中心s.homepage = 'http://www.MySDK.com'# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2's.license = { :type =>'Apache 2', :file =>'执照' }s.author = { '我' =>'我的电子邮件@email.com' }s.ios.deployment_target = '8.0's.source = { :http =>'http://working-link.to/MySDK.framework.zip' }s.ios.vendored_frameworks = 'MySDK.framework's.frameworks = 'UIKit's.dependency 'AFNetworking', '~>3.1.0's.dependency 'Crashlytics', '~>3.9.3's.dependency 'Fabric', '~>1.7.2's.dependency 'JSONModel', '~>1.7.0's.dependency 'KVOController', '~>1.2.0's.dependency '砌体', '~>1.0.2's.dependency 'SAMKeychain', '~>1.5.3's.dependency 'SDWebImage', '~>3.8.2's.dependency 'SnapKit', '~>3.0.0's.dependency 'SwiftyBeaver', '~>1.2.2's.dependency 'Toast', '~>3.1.0's.dependency 'YYImage', '~>1.0.4'结尾如果我将框架添加到嵌入框架中,一切都会按预期工作.
尝试清理 Pods 缓存,但没有成功
请帮忙!
在 Podfile 中使用 :podspec
而不是 :path
使其工作(因为在教程中提供了 :path
使用):
target 'MySDK-example' 做# 如果你不使用 Swift 并且不想使用动态框架,请注释下一行使用_框架!# Pods for MySDK-examplepod 'MySDK', :podspec =>'..'结尾
I need to publish a MySDK.framework (mixed obj-c + Swift) on cocoapods. I followed steps in Publish a Universal Binary iOS Framework in Swift using CocoaPods
When I run pod install
, it says:
Analyzing dependencies
Fetching podspec for `MySDK` from `..`
Downloading dependencies
Using AFNetworking (3.1.0)
Using Crashlytics (3.9.3)
Using FXBlurView (1.6.4)
Using Fabric (1.7.2)
Using HexColors (2.3.0)
Using JSONModel (1.7.0)
Using KVOController (1.2.0)
Using Masonry (1.0.2)
Using SAMKeychain (1.5.3)
Using SDWebImage (3.8.2)
Using SnapKit (3.0.2)
Using SwiftyBeaver (1.2.2)
Using Toast (3.1.0)
Using YYImage (1.0.4)
Using MySDK (0.0.1)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 15 total pods installed.
But MySDK.zip is not downloaded nor installed in Pods project, so Xcode complains about missing module MySDK (at import MySDK).
MySDK.podspec
#
# Be sure to run `pod lib lint MySDK.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'MySDK'
s.version = '0.0.1'
s.summary = 'A short description of MySDK.'
# 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!
s.description = <<-DESC
MySDK framework for iOS.
* TODO: where docs are?
DESC
s.homepage = 'http://www.MySDK.com'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'Apache 2', :file => 'LICENSE' }
s.author = { 'me' => '[email protected]' }
s.ios.deployment_target = '8.0'
s.source = { :http => 'http://working-link.to/MySDK.framework.zip' }
s.ios.vendored_frameworks = 'MySDK.framework'
s.frameworks = 'UIKit'
s.dependency 'AFNetworking', '~> 3.1.0'
s.dependency 'Crashlytics', '~> 3.9.3'
s.dependency 'Fabric', '~> 1.7.2'
s.dependency 'JSONModel', '~> 1.7.0'
s.dependency 'KVOController', '~> 1.2.0'
s.dependency 'Masonry', '~> 1.0.2'
s.dependency 'SAMKeychain', '~> 1.5.3'
s.dependency 'SDWebImage', '~> 3.8.2'
s.dependency 'SnapKit', '~> 3.0.0'
s.dependency 'SwiftyBeaver', '~> 1.2.2'
s.dependency 'Toast', '~> 3.1.0'
s.dependency 'YYImage', '~> 1.0.4'
end
If I add the framework to embed frameworks, everything is working as expected.
Tried clean Pods cache, no luck
Please help!
Using :podspec
instead of :path
inside Podfile made it work (because in the tutorial provided :path
is used):
target 'MySDK-example' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MySDK-example
pod 'MySDK', :podspec => '..'
end
这篇关于iOS 在 cocoapods 上发布私有代码框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!