Search code examples
iosswiftcocoapodsmagicalrecord

use_frameworks! and podspec in the root of a library repo


I have the following dependencies in my iOS project:

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

pod 'CocoaLumberjack'

# other dependencies here    

pod 'MagicalRecord', :git => 'https://github.com/magicalpanda/MagicalRecord.git', :branch => 'develop'

I use the latest version of CocoaPods at the moment (0.37.0). pod install gives no warnings or errors, but When I try to build, I get linker error:

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_DDLog", referenced from:
      objc-class-ref in MagicalRecord+ErrorHandling.o
      objc-class-ref in NSManagedObject+MagicalDataImport.o
      objc-class-ref in NSManagedObject+MagicalRecord.o
      objc-class-ref in NSManagedObjectContext+MagicalObserving.o
      objc-class-ref in NSManagedObjectContext+MagicalRecord.o
      objc-class-ref in NSManagedObjectContext+MagicalSaves.o
      objc-class-ref in NSObject+MagicalDataImport.o

Apparently, MagicalRecord does not see CocoaLumberjack, which provides the symbol. Documentation says:

Sometimes you may want to use the bleeding edge version of a Pod, a specific revision or your own fork. If this is the case, you can specify that with your pod declaration. It is important to note, though, that this means that the version will have to satisfy any other dependencies on the Pod by other Pods.

However, it is not explained how exactly these dependencies should be satisfied. Can anyone explain this? Everything worked fine until I added use_frameworks! to use pod written in Swift.


Solution

  • Looks like there's a somewhat useable workaround for this problem by linking CocoaLumberjack.framework in the generated Pods-MagicalRecord target in Pods.xcodeproj. This will allow MagicalRecord to see DDLog, and so you should be able to compile. However, it's a pretty fragile solution, as you'll need to re-link the framework each time you regenerate the Pods project by running pod install.

    source