Tom Kraina
Tom Kraina

Reputation: 3699

Missing required module 'CocoaLumberjack' in iOS 8 app / framework

I'm having a problem with integrating a cocoa pod (CocoaLumberjack in this case) into an iOS app and my own frameworks.

The Podfile looks like this:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "8.0"

target "CommonModule" do
    use_frameworks!
    # CocoaLumberjack wasn't officially released with Swift support yet
    # pod 'CocoaLumberjack'
    pod 'CocoaLumberjack', :git => '[email protected]:CocoaLumberjack/CocoaLumberjack.git', :commit => '6882fb5f03696247e394e8e75551c0fa8a035328'
    xcodeproj 'CommonModule/CommonModule.xcodeproj'
end

I have a hierarchy of modules (dynamic frameworks) like this:

And finally, the main app:

Now, CocoaLumberjack is used in several files in CommonModule and works as expected. However, every time I do import CommonModule in any file in ModelsModule, I get the following compile error:

~/Developer/ModelsModule/ModelsModule/SomeFile.swift:2:8: error: missing required module 'CocoaLumberjack'
import CommonModule
       ^

Any idea how to solve this issue?

UPDATE: Some people Recommend to use Carthage. I would like to avoid that, if possible.

Upvotes: 3

Views: 3485

Answers (2)

emaloney
emaloney

Reputation: 211

You'll also need to ensure that CommonModule.framework and CocoaLumberjack.framework (and any other frameworks) are listed in the Embedded Binaries section of your application target.

All the new iOS 8-style dynamic frameworks must be embedded within your app—even those that you aren't using directly, but that are dependencies of your dependencies—so you might end up seeing references to items you don't recognize.

Incidentally, there is a new Swift-based logging engine called CleanroomLogger that might make things easier if you're having trouble interacting with CocoaLumberjack from Swift.

Upvotes: 1

bolnad
bolnad

Reputation: 4583

I am assuming that CommonModule is swift and that your also using CocoaPods 0.36 as I see your calling use_frameworks!. I'm also assuming that you're using the Obj-C version of CocoaLumberjack, and trying to use it with Swift. That use_frameworks! flag tells CocoaPods to generate frameworks of the pods for linking in your Xcode project. So you need to say at the top of your class

import CocoaLumberjack

instead of using the Swift-Bridging-Header

Here is the blog post on cocoapods.org where they talk about the how to author a pod for the new use_frameworks! flag. Scroll down to the part Common Header Pitfalls

It could also be that your podspec creates a dependency to use CocoaLumberjack, and when linked to your project CocoaLumberjack and CommonModules, but Common Module is not referencing it correctly in the library. To get past that you need to refer to it as a framework when you import it into your Objective-C library

#import <CocoaLumberjack/CocoaLumberjack.h>

Upvotes: 0

Related Questions