Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing with SPM fails with Xcode 12 #300

Open
mickael-menu opened this issue Oct 2, 2020 · 8 comments
Open

Importing with SPM fails with Xcode 12 #300

mickael-menu opened this issue Oct 2, 2020 · 8 comments

Comments

@mickael-menu
Copy link

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
Copy link
Contributor

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
Copy link
Author

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

@fabianmuecke
Copy link

fabianmuecke commented Jan 28, 2021

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
Copy link

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
Copy link

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
Copy link

JonSalerno commented Jul 5, 2021

@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
Copy link

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
Copy link

JonSalerno commented Jul 7, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants