Skip to content

Undefined symbols when used as dependency of multiple targets (Swift Packages in Xcode) #408

@cjwirth

Description

@cjwirth

Describe the bug
When building the app, I get undefined symbol errors, saying that it can't find symbols that exist in AppAuthCore:

ld: Undefined symbols:
  _OBJC_CLASS_$_OIDAuthState, referenced from:
       in GoogleSignIn.o
  _OBJC_CLASS_$_OIDAuthorizationRequest, referenced from:
       in GoogleSignIn.o
  _OBJC_CLASS_$_OIDAuthorizationService, referenced from:
       in GoogleSignIn.o
  _OBJC_CLASS_$_OIDIDToken, referenced from:
       in GoogleSignIn.o
  _OBJC_CLASS_$_OIDServiceConfiguration, referenced from:
       in GoogleSignIn.o
  _OBJC_CLASS_$_OIDURLQueryComponent, referenced from:
       in GoogleSignIn.o
  _OIDOAuthErrorResponseErrorKey, referenced from:
      +[GIDEMMSupport handleTokenFetchEMMError:completion:] in GoogleSignIn.o
  _OIDOAuthTokenErrorDomain, referenced from:
      ___53-[GIDGoogleUser refreshTokensIfNeededWithCompletion:]_block_invoke.22 in GoogleSignIn.o
  _OIDResponseTypeCode, referenced from:
      -[GIDSignIn authenticateInteractivelyWithOptions:] in GoogleSignIn.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This only happens if GoogleSignIn is added as a dependency of multiple targets that end up in the resulting app. If GoogleSignIn is only included into one target, it seems to be OK. But when it's included in multiple targets, I get the error above.

I have created a reproducible sample using the ObjC sample app provided by this repo.

To Reproduce
Steps to reproduce the behavior:

  1. Open the sample app in Xcode
  2. Create another Framework target that the main app depends on
  3. Make the new Framework target depend on GoogleSignIn
  4. Build the app -- see the errors

Or checkout the reproducible sample that I put together and try building it.

The app is basically structured like this in terms of project and dependencies:

.
└── AppTarget
    ├── GoogleSignIn
    ├── OnboardingFramework
    │   └── GoogleSignIn
    └── LoginFramework
        └── GoogleSignIn

Expected behavior
The app should build.

Screenshots
[available on request, but really nothing worth sharing, I don't think?]

Environment

  • GoogleSignIn-iOS Versions: 7.1.0, 6.2.4
  • Xcode: Have tried on Xcode 15.2, 15.3, and 15.4
  • OS: macOS 14.4.1, 14.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageIssues that need to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions