magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.79k stars 1.79k forks source link

Cocoapods 0.36 CocoaLumberjack error #988

Closed wimhaanstra closed 8 years ago

wimhaanstra commented 9 years ago

I upgraded my project to use Cocoapods 0.36 and I started to fix the errors that causes. One of the errors I was getting is the following:

Undefined symbols for architecture x86_64:
  "_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
      ...

In my project I have both CocoaLumberjack as MagicalRecord in my Podfile. I solved it by adding CocoaLumberjack.framework to the Link Binary With Libraries in the Pods-MagicalRecord target my Pods project has, but I am not sure that is the way to go.

wimhaanstra commented 9 years ago

Just a couple of test results, might help you out, I tried this on an my original project and an empty test project:

tonyarnold commented 9 years ago

I've just made some changes to the module-support branch that I hope (haven't had a chance to properly test yet) will fix CocoaLumberjack support. Would you mind having a look for me as well? Thanks!

Feel free to re-open this issue if it isn't fixed.

benvium commented 9 years ago

@tonyarnold I'm running into the same issue (Undefined symbols for "_OBJCCLASS$_DDLog")

use_frameworks!
pod 'MagicalRecord', '2.3.0'
pod 'CocoaLumberjack', '2.0.0'

The module-support branch is no longer there so I can't comment on that.

pavm035 commented 9 years ago

Same issue here. I used @depl0y solution as work around, not sure if it's the right way to go..?

Ziewvater commented 9 years ago

I'm having the same issue here as well. My podfile looks like this

platform :ios, '8.0'

target '[App Name]' do
    use_frameworks!
    pod "MagicalRecord", "~> 2.3.0"
    pod 'CocoaLumberjack', :git => "https://github.com/CocoaLumberjack/CocoaLumberjack.git", :branch => "swift_support"
end

I'm using the swift_support branch of CocoaLumberjack as suggested on their repo, which uses version 2.0.0.

Linking the framework in the Pods-[App Name]-MagicalRecord target like @depl0y suggested allows me to build, but seems pretty fragile since I'd need to remember to do that each time I run pod install.

ajself commented 9 years ago

Having the same problem as well

krypt-lynx commented 9 years ago

Same issue.

use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'

platform :'ios', '7.0'
xcodeproj '<proj1>'
link_with 'target1'

xcodeproj '<proj2>'
link_with 'target2_1'
link_with 'target2_2'

pod 'AFNetworking'
pod 'CocoaLumberjack'
pod 'MagicalRecord'

target :<...>Tests do
    pod 'OCMock', '~> 3.0.2'
    pod 'XCAsyncTestCase'
end
ArtSabintsev commented 9 years ago

Putting in my 2 cents as well (cc @ssoper)

pavm035 commented 9 years ago

Any update on this? it's the same issue here

tonyarnold commented 9 years ago

No update. I haven't been using MR in any projects recently, and I haven't had the opportunity to work on it outside of hours. I'm happy to accept pull requests toward this issue.

lolgear commented 9 years ago

same here, any info about this issue?

Using CocoaLumberjack (2.0.1) Using MagicalRecord (2.3.0)

Works well ( as @depl0y mentioned above ) CocoaLumberjack (2.0.0) MagicalRecord (2.2.0)

krypt-lynx commented 9 years ago

Issue not reproducing if async logging in CocoaLumberjack is disabled. But you need to create fork of CocoaLumberjack pod for this.

pratik6554 commented 9 years ago

Any updates on this ?

thomasaw commented 9 years ago

Why is this closed? Isn't it still an issue?

ghost commented 9 years ago

Still having problems with this. Any updates?

melbic commented 9 years ago

Same issue here: pod 'CocoaLumberjack', '~> 2.0' pod 'MagicalRecord', '~> 2.3'

melbic commented 9 years ago

Ok, I found a workaround. The problem is, that the MagicalRecord Target doesn't link with the CocoaLumberjack Framework. (Build Phases >> Link Binary With Libraries) When one adds CocoaLumberjack as optional dependency, all works great.

ghost commented 9 years ago

Hey Melbic, are you adding the dependency to cocoa lumberjack from Magical Record? If so then I've used this trick as a workaround too. The only issue is that every time you do a 'pod install' the dependency is wiped out. Still hoping for a permanent solution...

melbic commented 9 years ago

Take a look at my pull request. Using that to install MagicalRecord it works without manually linking the framework.

lolgear commented 9 years ago

does this error appears in Swift-based projects?

pratik6554 commented 9 years ago

Yes.

lolgear commented 9 years ago

@pratik6554 and this error still exists?

In my case: cocoapods 0.39.0 cocoalumberjack 2.1.0 magicalrecord 2.3.0 xcode 7.1 And error occurs.

I use @melbic approach and add cocoalumberjack as optional dependency - everything works fine

pratik6554 commented 9 years ago

@lolgear Facing same issue for

pod 'MagicalRecord', '~> 2.3.0' pod 'CocoaLumberjack/Swift'

anton-matosov commented 8 years ago

I have improved podspec a little bit in #1132 so subspec with CocoaLumberjack is selected automatically

frenya commented 8 years ago

Just in case it helps anyone, here's the workaround I used.

In my Pod's Podspec file:

s.dependency 'MagicalRecord', '~> 2.3.0'
s.dependency 'CocoaLumberjack', '~> 2.0'
s.pod_target_xcconfig = {  CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES' }

In the actual project's Podfile:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == 'MagicalRecord'
            target.build_configurations.each do |config|
                config.build_settings['OTHER_LDFLAGS'] ||= ['$(inherited)', '-framework "CocoaLumberjack"']
            end
        end
    end
end

This seems to work without having to adjust build settings every time I run pod install.

P.S.: I'm not an expert on CocoaPods and/or Ruby, so if you see an error in the post_install script or know a way of including it directly in the Podspec file, feel free to comment.

P.P.S.: Let's hope MagicalRecord 2.4.0 CocoaPod contains the CocoaLumberjack subspec and this is no longer needed :)

magicalpandatest commented 8 years ago

Cocoa lumberjack has never been a requirement for magical record or logging to work and compile. Magical record was designed to simply connect to the logging framework if it was available.

Sent from my iPhone

On Dec 9, 2015, at 8:42 AM, Frantisek Vymazal notifications@github.com wrote:

Just in case it helps anyone, here's the workaround I used.

In my Pod's Podspec file:

s.dependency 'MagicalRecord', '~> 2.3.0' s.dependency 'CocoaLumberjack', '~> 2.0' s.pod_target_xcconfig = { CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES' } In the actual project's Podfile:

post_install do |installer| installer.pods_project.targets.each do |target| if target.name == 'MagicalRecord' target.build_configurations.each do |config| config.build_settings['OTHER_LDFLAGS'] ||= ['$(inherited)', '-framework "CocoaLumberjack"'] end end end end This seems to work without having to adjust build settings every time I run pod install.

P.S.: I'm not an expert on CocoaPods and/or Ruby, so if you see an error in the post_install script or know a way of including it directly in the Podspec file, feel free to comment.

P.P.S.: Let's hope MagicalRecord 2.4.0 CocoaPod contains the CocoaLumberjack subspec and this is no longer needed :)

— Reply to this email directly or view it on GitHub.

frenya commented 8 years ago

Exactly! And since it's not a requirement (and therefore the pod's dependency), it's not linked in by default. This is what's causing the headache - the conditional compile sees the CocoaLumberjack header, imports it and starts using it, but in the link phase, the library is not added, causing the _(Undefined symbols for "OBJC_CLASS$DDLog") error.

Just to be clear - my comment wasn't meant to be confrontational. Apparently, this has already been fixed in the master branch by the subspec. Unfortunately, this change has not yet propagated into the CocoaPods repo.

And since I'm not allowed to use the :git option in Podspec, I'm dependant on the main repo. With my workaround, I was just trying to help other people in the same situation :)

serkrapiv commented 8 years ago

@frenya this post install fix doesn't work for me in my application's podfile

danielgalasko commented 8 years ago

Also seeing this

pod 'MagicalRecord', '2.3.0'
pod 'CocoaLumberjack', '2.2.0'
Nikita2k commented 8 years ago

Same for me

Using CocoaLumberjack (2.2.0)
Using MagicalRecord (2.3.0)
anton-matosov commented 8 years ago

There is a solution for this problem (https://github.com/magicalpanda/MagicalRecord/pull/1101) It was merged into the main repo but for some reason not yet submitted to CocoaPods master specs repo. In order to fix linker issue update the podfile entry to:

 pod "MagicalRecord/CocoaLumberjack", :git => "https://github.com/magicalpanda/MagicalRecord.git"

P.S. I have not tried this with Swift.

rahulmeena13 commented 8 years ago

@anton-matosov Checked with swift, working fine.

tonyarnold commented 8 years ago

Sorry guys, I've been swamped — I released version 2.3.2 a couple of days ago, which should address this issue. Feel free to reopen this issue if it doesn't.

semireg commented 8 years ago

Version 2.3.2 from branch MagicalRecord/CocoaLumberjack works for me. However, the default podspec when using "pod 'MagicalRecord' doesn't work for me. Both show version 2.3.2, though... weird.

santiago commented 8 years ago

After fixing the Undefined symbols issue by installing from 'MagicalRecord/CocoaLumberjack' I start seeing these other errors.

Any ideas on what might be going on?

xradeon commented 8 years ago

I still have the issue with the default podspec using 'pod MagicalRecord'. It shows version 2.3.2 too..

anton-matosov commented 8 years ago

Default podspec should not fix the issue. CocoaLumberjack is optional component and if you use it, you should use another subspec

xradeon commented 8 years ago

In fact I wasn't using it. I installed the appodeal pod, then the issue appeared. Even uninstalling the appodeal pod didn't solve the problem. I solved it deleting derived data folder. Thanks!