fpillet / NSLogger

A modern, flexible logging tool
Other
5k stars 573 forks source link

Importing with SPM fails with Xcode 12 #300

Open mickael-menu opened 3 years ago

mickael-menu commented 3 years ago

After updating Xcode to the version 12, I can't import NSLogger anymore with SPM. The build fails with:

The package product 'NSLogger' cannot be used as a dependency of this target because it uses unsafe build flags.

I'm using the latest master version.

krugazor commented 3 years ago

Yep (author of the SPM attempt here)

A little surprise from the Xcode team to disallow "unsafe" build options in dependencies.

In this particular case, NSLogger requires to disable ARC here and there in its objective c code. Thus, "unsafe", and therefore not allowed.

I have been trying to solve this without much success, given the long backwards compatibility of NSLogger, and the general lack of backwards compatibility support in SPM.

In the meantime, use other means of integrating the lib in your projects (subproject is my favorite, I shy away from cocoapods or carthage), if it's time-critical.

mickael-menu commented 3 years ago

Thanks for the heads-up @krugazor, I'll follow your suggestions until it's fixed.

fabianmuecke commented 3 years ago

If I make a local wrapper Swift Package, referencing NSLogger as a dependency there and adding the local package to my app it works for me.

JonSalerno commented 3 years ago

If I make a lokal wrapper Swift Package, referencing NSLogger as a dependency there and adding the local package to my app it works for me.

Could you elaborate on this a little more? Are you saying you made a package that contains NSLogger as a package and reference that?

fabianmuecke commented 3 years ago

Don't know, how else I could describe it. I made a local package, added the package to the Xcode project of my app, added NSLogger as a dependency in the Package.swift of this package, then added the local package as a dependency of my app. This makes NSLogger available within my app and does not trigger the build error.

JonSalerno commented 3 years ago

@fabianmuecke Thanks for the response. So far when I try following your instructions I keep getting this error missing required module 'NSLoggerLibObjC'. Though I am able to import NSLogger and my project can now see it. Can you share the Package.swift file that you used in the local package you created?

fabianmuecke commented 3 years ago

I made a mini sample project, which compiles and runs on my machine. Please have a look, if you can spot, what you might be missing. https://github.com/fabianmuecke/NSLoggerSPMWorkaround Especially check, if you added your local package to "Frameworks, Libraries, and Embedded Content".

JonSalerno commented 3 years ago

@fabianmuecke I imported your library and that seemed to have worked 👏. You package file was almost exactly the same as mine. So as of right now I do not know why I could not get it to work. I appreciate you taking time out of your day to make that workaround though.

You should consider writing an article about this. I think there are still quite a few people that don't know how to do this.