google-api-objectivec-client-for-rest: Swift Package Manager Support is broken

I have added the dependency for GoogleAPIClientForREST_Drive in a completely new and clean project using the Swift Package Manager in Xcode. An import GoogleAPIClientForREST_Drive fails with: Could not build Objective-C module 'GoogleAPIClientForREST_Drive'. And there is also the error: 'GTLRService.h' file not found' in the file GTLRDriveService.h. Shouldn’t it actually use the conditional import @import GoogleAPIClientForRESTCore; here?

#if SWIFT_PACKAGE || GTLR_USE_MODULAR_IMPORT
  @import GoogleAPIClientForRESTCore;
#elif GTLR_BUILT_AS_FRAMEWORK
  #import "GTLR/GTLRService.h
#else
  #import "GTLRService.h
#endif

Based on the comment from cassareh (#351), I could fix it manually. Is this really necessary or is there another way to do it automatically? If there is no other possibility, we should probably point this out in the README, because in my opinion this is not obvious.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 27 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Running the following command under GoogleAPIClientForREST project root directory:

swift package generate-xcodeproj

Will generated an Xcode project that contain the following Preprocessor Macros:

For Debug configuration:

  • SWIFT_PACKAGE=1
  • DEBUG=1

For Release configuration:

  • SWIFT_PACKAGE=1
Generated project

The flags above should be added to fix the issue until Xcode get fixed.

fyi - we’re getting close to cutting a 2.0 release that reshuffles the source and should hopefully resolve these issues once and for all.

(the 2.0 version will be because the reshuffle could break some specific setups for imports, but we’re trying to make the changes minimal)

Hello, Same issue for me after adding this library with SPM (core + youtube) : Capture d’écran 2021-04-27 à 15 04 48 I stay on cocoapods since this is not fixed 😃