1

I have scenario where i have couple of SDKs and a test app. Here is the example.

SDKCore - “Objective-C Framework”

SDKUI - “Objective-C Framework”

  • SDKCore is added as a dependency using Cocoapods pod 'SDKCore', :path => '../SDKCore' and with flag ‘use_frameworks’
  • SDKUIViewController uses methods from SDKCore. I’m importing like this @import SDKCore;

Code

#import "SDKUIViewController.h"
@import SDKCore;

@interface SDKUIViewController ()

@end

@implementation SDKUIViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [SDKClass hitTest];
    self.view.backgroundColor = [UIColor redColor];
}

@end

SDKTestSwift

  • SDKCore is added as a dependency using Cocoapods pod 'SDKCore', :path => '../SDKCore' and with flag ‘use_frameworks’
  • SDKUI is added as a dependency using Cocoapods pod 'SDKUI', :path => '../SDKUI' and with flag ‘use_frameworks’

Problem is when i compile SDKTestSwift I’m getting Module SDKCore not founda compile error on one of the files from SDKUI (See attached) enter image description here

Really got stuck here. Thanks a lot in advance.

You can download the sample project from here.

Bilal
  • 18,478
  • 8
  • 57
  • 72
  • Why dont u just import the headers? I think Cocoapods doesnt support modules for pod with only headers/static lib/framework – Tj3n May 18 '17 at 05:16
  • i tried with headers '#import ' but same issue `SDKUI` works fine no errors and in `SDKTestSwift` i am getting this error `SDKCore/SDKClass.h file not found` – Bilal May 18 '17 at 06:04
  • and i have to use modules because Im using ObjectiveC pods in Swift project. – Bilal May 18 '17 at 06:06
  • In swift you MUST create `bridging-header` file and import header file there in order to use obj-c in swift, another suggestion is that create an empty class (visible .m file) to make the pod generate modules, but it will create confusing for your user – Tj3n May 18 '17 at 07:39
  • I think module do the bridging-header thing... i think that's way if i use SDKCore in app directly it works. Problem comes when i use SDKCore in SDKUI and use SDKUI in app. – Bilal May 18 '17 at 07:52
  • Just try create bridging-header in your swift project and import the header there, see if it works – Tj3n May 18 '17 at 07:56
  • still no luck :( – Bilal May 18 '17 at 08:04
  • Make sure you create the file properly, like in [here](http://stackoverflow.com/questions/36438455/no-such-module-ensembles-error-importing-objective-c-framework-to-use-in-swi?rq=1) – Tj3n May 18 '17 at 08:28
  • Still its not working..... whenever you have time please have a look at the sample project. Thanks – Bilal May 18 '17 at 09:16

1 Answers1

3

Sorry, I actually have misunderstood you from the start, your issue lying in your pod, not project, this happen because you didn't state that the SDKUI depend on SDKCore, thats why you cant use any code from SDKCore

To fix this, simply add s.dependency 'SDKCore' in your SDKUI.podspec and run pod install again, then it works

Tj3n
  • 9,837
  • 2
  • 24
  • 35