Cocoapods: Issue sharing the same pod with different subspec in app and extension

Created on 3 Aug 2016  Â·  2Comments  Â·  Source: CocoaPods/CocoaPods

ℹ Please fill out this template when filing an issue.
All lines beginning with an ℹ symbol instruct you with
what info we expect.
Please remove this line and all above before submitting.

Report

I have a pod that supports app extensions that partially uses precompiler flag to disable some of code. So to do that I created subspec with dependency on default subspec and modified flags. I see that CocoaPods creates two separate targets for the same library but I am not able to import header in extension. @import statement seems to work but I don't understand how to make it work the same way for both app and extension.

Using ss.ios.source_files directly instead of dependency in my pod spec does not seem to change anything..

What did you do?

ℹ Please replace this with what you did.
e.g. Run pod install

What did you expect to happen?

Expect that #import <Operative/Operative.h> should work just fine for both app and extension.

What happened instead?

Compiler says it cannot import <Operative/Operative.h>. However @import works fine.

CocoaPods Environment

ℹ Please replace this with the output of pod env.
e.g. via pod env | pbcopy

Project that demonstrates the issue

Part of spec:

  s.source_files     = 'Pod/Classes/Operative.h'

  s.default_subspec  = 'Core'

  s.subspec 'Core' do |ss|
    ss.ios.source_files = 'Pod/Classes/{Core,iOS}/**/*'
    ss.osx.source_files = 'Pod/Classes/{Core,OSX}/**/*'
  end

  s.subspec 'Extension' do |ss|
    ss.platform = :ios
    ss.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) OP_TARGET_IS_EXTENSION' }
    ss.dependency 'Operative/Core'
  end

Pod file:

target 'App' do
  pod 'Operative', :git => 'https://github.com/pronebird/Operative', :branch => 'develop'
end

target 'Widget' do
  pod 'Operative/Extension', :git => 'https://github.com/pronebird/Operative', :branch => 'develop'
end

ℹ Please link to a project we can download that reproduces the issue.
You can delete this section if your issue is unrelated to build problems,
i.e. it's only an issue with CocoaPods the tool.

Most helpful comment

@neonichu Can we somehow force cocoapods to build and bundle 2 differently named frameworks (one for extension and one for the main app, for example 'Operative-Main.framework', 'Operative-Extension.framework')

or this is architecturally wrong?

Thanks!

All 2 comments

See #5643 — since you'll end up with only one copy of your framework in the application bundle, this scenario will likely not work at runtime anyway and should probably raise an error.

@neonichu Can we somehow force cocoapods to build and bundle 2 differently named frameworks (one for extension and one for the main app, for example 'Operative-Main.framework', 'Operative-Extension.framework')

or this is architecturally wrong?

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steffendsommer picture steffendsommer  Â·  3Comments

evermeer picture evermeer  Â·  3Comments

spencerkohan picture spencerkohan  Â·  3Comments

iosdev-republicofapps picture iosdev-republicofapps  Â·  3Comments

marzapower picture marzapower  Â·  3Comments