2

I have a source file, well actually it is a Google API library.

It has this code on GTLCommon_Sources.m:

#if defined(__has_feature) && __has_feature(objc_arc)
#error "This file needs to be compiled with ARC disabled."
#endif

#import "Objects/GTLBatchQuery.m"
#import "Objects/GTLBatchResult.m"
#import "Objects/GTLDateTime.m"
#import "Objects/GTLErrorObject.m"
#import "Objects/GTLObject.m"
#import "Objects/GTLQuery.m"
#import "Objects/GTLRuntimeCommon.m"
#import "Objects/GTLService.m"
#import "Objects/GTLUploadParameters.m"

#import "Utilities/GTLBase64.m"
#import "Utilities/GTLFramework.m"
#import "Utilities/GTLJSONParser.m"
#import "Utilities/GTLUtilities.m"

However, try to build it, results on duplicate symbols on GTLCommon_Sources and GTLJSONParser. I tried change the source file to #import "Utilities/GTLJSONParser.h" instead of #import "Utilities/GTLJSONParser.m" and the duplicate symbols error goes away.

Can anyone advise why this library imports a .m file? While AFAIK, we always import .h file.

Rendy
  • 5,572
  • 15
  • 52
  • 95

1 Answers1

3

It's just a convenient way to build all the source files without having all of them included in your project. See the documentation.

Rather than link to the GTL framework, you can compile the GTL library sources directly into your own project. To do this, find the library's GTLCommon_Sources.m and GTLCommon_Networking.m files, and drag the files into your project's window.

Then add the library's source folders to the Header Search Paths entry of your project's build settings: Source, Source/Objects, Source/Utilities, Deps/gtm-session-fetcher/Source, Deps/gtm-oauth2/Source, Deps/gtm-oauth2/Source/Touch (or Deps/gtm-oauth2/Source/Mac).

For that to work, do not add any other of the other sources (GTLBatchQuery.m, etc.) to your project.

zpasternack
  • 17,838
  • 2
  • 63
  • 81
  • Thanks zpasternack! However I found another issue, if you may help here http://stackoverflow.com/questions/37563249/google-api-gtmoauth2viewcontrollertouch-not-found :) – Rendy Jun 01 '16 at 08:37