iOS在cocoapods上发布私有代码框架

时间:2017-12-07 21:56:32

标签: ios swift xcode frameworks cocoapods

我需要在cocoapods上发布MySDK.framework(混合obj-c + Swift)。我按照Publish a Universal Binary iOS Framework in Swift using CocoaPods

中的步骤进行操作

当我运行pod install时,它会说:

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.

MySDK.zip 未在Pods项目中下载或安装,因此Xcode抱怨缺少模块MySDK(在导入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' => 'my-email@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 '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
  • 如果我将框架添加到嵌入框架中,一切都按预期工作。

  • 尝试干净的Pod缓存,没有运气

请帮忙!

1 个答案:

答案 0 :(得分:1)

在Podfile中使用:podspec代替:path使其正常工作(因为在使用的教程中提供了:path):

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