Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoapod spec with separate frameworks per sub spec

Tags:

ios

cocoapods

I'm struggling with creating a cocoapod spec including multiple sub specs where each sub spec should be its own framework. Basically I have the following spec:

Pod::Spec.new do |s|
  s.name     = 'BMCommons'
  ...
  s.default_subspec = 'BMCore'

  s.subspec 'BMCore' do |s_core|
    s_core.header_dir = 'BMCore'
    ...
  end

  s.subspec 'BMUICore' do |s_uicore|
    s_uicore.header_dir = 'BMUICore'
    ...
  end
end

Now I would like this to result in a BMCore.framework and BMUICore.framework instead of one BMCommons.framework. Is this possible or do I need to create multiple specs to achieve this?

like image 297
Werner Altewischer Avatar asked Jul 04 '16 08:07

Werner Altewischer


1 Answers

In short: no, you can't have subspecs that result in different frameworks, because - as the name implies - it's a subspec, that is part of something. From the cocoapod docs:

subspec

Represents specification for a module of the library.

But it will result in separate frameworks internally when you use it in a project, their filenames being BMCommons-BMCore and BMCommons-BMUICore. Their actual framework name you import will remain BMCommons.

You can try this out by creating a project with 2 targets, and in the Podfile for one target you add the first subspec, and for the other the second one. After a pod install you should look the targets in the Pods project, there are the generated frameworks by cocoapod.

like image 52
izerik Avatar answered Sep 25 '22 13:09

izerik