Creating .framework through .podspec file

2.5k views Asked by At

Currently my Framework (myFramework.framework) is available through cocoapods. I am making it's source code public but facing some issue.

I have referred following links:

  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/

How can I create .framework (not library) from podspec file? And even I am able to create library from podspec. But I want to make myFramework.framework file.

Here is podspec file:

    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

currently I am testing framework locally.

use_frameworks!

target 'podDemo' do

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

After pod install result is this:

folder structure in pod project

But I want to add .framework like this:

framework

1

There are 1 answers

2
Cristik On BEST ANSWER

The podspec doesn't specify how the library will be build - statically or dynamically. It's the responsibility of the users of the library to specify how to build it - i.e. in their Podfile.

By default Cocoapods builds static libraries, if you need a framework then you can specify use_frameworks! in your Podfile.

Regarding the header files presence in the project navigator, this is the expected behavior, as the headers need to be referenced somewhere if you want to have them included in the built framework. If you go to the build directory you should be able to find the framework.