通过 .podspec 文件创建 .framework

Creating .framework through .podspec file

目前我的框架 (myFramework.framework) 可通过 cocoapods 使用。我正在制作它的源代码 public 但遇到了一些问题。

我参考了以下链接:

  1. CocoaPod/Podspec and *.framework
  2. https://guides.cocoapods.org/making/using-pod-lib-create.html
  3. http://blog.cocoapods.org/Pod-Authors-Guide-to-CocoaPods-Frameworks/

如何从 podspec 文件创建 .framework(不是库)? 甚至我也可以从 podspec 创建库。但是我想制作 myFramework.framework 文件。

这是 podspec 文件:

    Pod::Spec.new do |s|
s.name             = 'myFramework'
s.version          = '1.0.0'
s.summary          = 'Product summary will go here'

s.description      = <<-DESC
Product description goes here. It can be anything which describes your product in few lines.
 DESC

s.homepage         = 'homepage link'
s.license          = { :type => 'Commercial',:text => 'Link to website'}
s.author           = { 'abcd' => 'email address' }
s.source           = {:path => ':path => ‘local_path/framework-folder'}
s.social_media_url = 'social_media_url'

s.ios.deployment_target = '7.0'

s.source_files = 'framework-folder/inner-folder/*.h'
s.public_header_files = 'framework-folder/inner-folder/*.h'

s.frameworks =  'CoreGraphics', 'MobileCoreServices', 'Security', 'SystemConfiguration'
s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' }

end

目前我正在本地测试框架。

use_frameworks!

target 'podDemo' do

pod 'myFramework', :path => ‘~folder_path/myFramework.podspec’
end

pod install 之后的结果是这样的:

但我想像这样添加 .framework:

podspec 没有指定库的构建方式 - 静态或动态。库的用户有责任指定如何构建它 - 即在他们的 Podfile.

Cocoapods 默认构建静态库,如果您需要一个框架,那么您可以在 Podfile.

中指定 use_frameworks!

关于项目导航器中存在的头文件,这是预期的行为,因为如果要将头文件包含在构建的框架中,则需要在某处引用头文件。如果你去构建目录,你应该能够找到框架。