tuist: 📦 [Dependencies.swift][SPM] Module map linking not working for ObjectiveC packages

What happened?

When a package defines a modulemap file, it is linked to the projects depending on it using the -fmodule-map-file=… in OTHER_C_FLAGS and OTHER_CPP_FLAGS.

This doesn’t seem to work correctly if the dependent package is an Objective-C target.

As there were a number of issues related to this, I have created this one and will close the others as duplicate

How do we reproduce it?

There are a number of issues related to it, which you can use to reproduce it:

What were you expecting?

Import should work correctly out of the box

macOS version

12.0

Tuist version

3.10.0

Xcode version

13.4.1

Upvote & Fund

  • We’re using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
<picture> <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/tuist/tuist/issues/4688/pledge.svg?darkmode=1"> Fund with Polar </picture>

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 42 (7 by maintainers)

Most upvoted comments

AppLayer ---- Module A -------- Firebase (10.10.*) -------- Google Sign In (7.0.0) or (6.2.4) ---- Module B ---- Module C …

try add build settings at Module A’s build settings.

"HEADER_SEARCH_PATHS": [
    "$(inherited)",
    "$(SRCROOT)/../../Tuist/Dependencies/SwiftPackageManager/.build/checkouts/GTMAppAuth/GTMAppAuth/Sources/Public/GTMAppAuth"
    "$(SRCROOT)/../../Tuist/Dependencies/SwiftPackageManager/.build/checkouts/gtm-session-fetcher/Sources/Core/Public"
],
"OTHER_LDFLAGS" : "-ObjC"

in my case, I solved. pay attention to the file path (public header path).

Hey folks 👋🏼. I started looking into this one. It seems that some build settings are missing in the projects in which dependencies are integrated and that causes the compilation errors that you are all seeing. I’ll use all the dependencies mentioned in this thread to reproduce this issue. Please, if you had issues with other dependencies, I’d appreciate if you could share the name with me.

Hey, folks 👋

This PR should finally fix this issue: https://github.com/tuist/tuist/pull/5887

If there’s any complex dependency that you’d like us to try out, let us know. We hope to include the fix in the next tuist release.

Thanks for the tip! What versions did you use of GoogleSignIn (and Firebase if applicable)? It doesn’t work for me hence the question. Thanks!

GoogleSignIn 6.2.4 firebase-ios-sdk 8.15.0

Thanks!

It worked for me with some slight modifications (paths were incorrect for me):

"OTHER_LDFLAGS": SettingValue(stringLiteral: "-ObjC"),
"HEADER_SEARCH_PATHS": SettingValue(stringLiteral: "$(inherited) $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/GoogleSignIn-iOS/GoogleSignIn/Sources/Public $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/AppAuth-iOS/Source/AppAuth $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/AppAuth-iOS/Source/AppAuthCore $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/gtm-session-fetcher/Sources/Core/Public $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/GoogleSignIn-iOS/GoogleSignIn/Sources/../../ $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/GTMAppAuth/GTMAppAuth/Sources/Public/GTMAppAuth"),

Adding this lines to xcconfig

HEADER_SEARCH_PATHS=$(inherited) $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/GoogleSignIn/Sources/Public $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/AppAuth-iOS/Source/AppAuth $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/AppAuth-iOS/Source/AppAuthCore $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/gtm-session-fetcher/Source/SwiftPackage $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/GoogleSignIn/Sources/../../ $(SRCROOT)/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/GTMAppAuth/GTMAppAuth/Sources/Public/GTMAppAuth

OTHER_LDFLAGS=-ObjC

helped me to build the project successfully in case of use GoogleSignIn SPM package

Firebase and GoogleSignIn can’t work as external dependency, because of this only as a native SPM

Hi, that’s great news ! Here is some dependencies that had issues: Realm https://github.com/realm/realm-swift Sentry https://github.com/getsentry/sentry-cocoa

https://github.com/amplitude/Amplitude-iOS has Objective-C target, but it works without doing something.

I don’t know if it’s relevant but it looks like the publicHeadersPath is defined in Amplitude-iOS’s Package.swift file, Whereas AppAuth is left at “”. I’ve tried importing both and Amplitude does have it’s headers?

how to use that info? I’m not sure yet, just thought it might be something to share in case anyone else is still looking too.

Hi, that’s great news ! Here is some dependencies that had issues: Realm https://github.com/realm/realm-swift Sentry https://github.com/getsentry/sentry-cocoa

Hey, setting "USE_HEADERMAP": "YES" in targetSettings fixed errors in Sentry 8.10.0

@danyf90 I am starting working on it Just to be on a same page, Meanwhile working with tuist test I found an issue with brain tree library where they are using absolute path I created a PR and write a proposal also.

Do you think issue and PR is also related to this 🐞

No, it shouldn’t be related 🙏