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

OpenCV fails to compile in a mixed source project with resources due to conflicting NO macro definition #6279

Open
jeffremer opened this issue May 13, 2024 · 2 comments
Labels
type:bug Something isn't working

Comments

@jeffremer
Copy link

What happened?

As of tuist@4.11.0 the opencv-spm dependency (source) fails to compile with an Expected identifier error in the headers.

This is is warned against in their headers…

#if defined(NO)
#  warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
#endif

The Apple NO macro definition is being pulled in because tuist is setting the GCC_PREFIX_HEADER setting as of this change causing a build conflict.

Please, include this header before any Apple headers.

Open CV headers need to be included before any Apple header and the tuist set prefix header is causing Apple headers to come in automatically first.

Screenshot 2024-05-13 at 12 48 06 PM

If I stop the prefix header from being set (for instance no resources or Objective-C) then things work fine.

How do we reproduce it?

  1. Use the attached project and run tuist install && tuist generate
  2. Build the OpenCVTuistExample app

OpenCVTuistExample.zip

Error log

Build OpenCVTuistExample_2024-05-13T12-43-14.txt

macOS version

13.5.2

Tuist version

4.11.0

Xcode version

15.2

@jeffremer jeffremer added the type:bug Something isn't working label May 13, 2024
@jeffremer
Copy link
Author

jeffremer commented May 13, 2024

Interestingly if I remove the top level openCV import in the OpenCVWrapper.mm file attached in the project then it compiles just fine.

So, we have a workaround right now…but this still does feel like a bug, or at least something that would be nice to have more control over.

@fortmarek
Copy link
Member

Hey 👋

Yeah, the SPM integration doesn't use GCC_PREFIX_HEADER and we know using it is not ideal as commented here when we initially added this setting (the PR you linked doesn't actually add that flag, it has been there longer).

The fix should be to use -include flags which is what SPM is doing. As mentioned in the linked comment, I wasn't able to get it working in that PR, but we might need to try another time.

We'll put it into our backlog but if you would like to dive deeper into this one, I'm more than happy to provide guidance and pointers to fix this 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants