I am using the GData static library in my app that uses ARC. Google's instructions say to link the header files from the library to the project target.
The problem is that when I do so I get compiler errors as the GData library is not compatible with ARC.
Google states that:
ARC Compatibility
When the library source files are compiled directly into a project that uses ARC, then ARC must be disabled specifically for the library sources.
To disable ARC for source files in Xcode 4, select the project and the target in Xcode. Under the target "Build Phases" tab, expand the Compile Sources build phase, select the library source files, then press Enter to open an edit field, and type -fno-objc-arc
as the compiler flag for those files.
(reference)
But since I have only the header files I can not use this flag in the app target.
Well I asked and found the unswear 10 minutes later. Any way if it will help someone:
- The problem is only with the .h files, Goole remark is only for cases you embed the library not as static library.
- After someone reported the problem to google, they added new macros that solve the problem, this is how:
search the header files for file named : GDataDefines.h
and add this code inside:
//
// Simple macros to allow building headers for non-ARC files
// into ARC apps
//
#ifndef GDATA_REQUIRES_ARC
#if defined(__clang__)
#if __has_feature(objc_arc)
#define GDATA_REQUIRES_ARC 1
#endif
#endif
#endif
#if GDATA_REQUIRES_ARC
#define GDATA_UNSAFE_UNRETAINED __unsafe_unretained
#else
#define GDATA_UNSAFE_UNRETAINED
#endif
Then in the GDataObject.h which causes the ARC errors
Change the GDataDescriptionRecord struct to
typedef struct GDataDescriptionRecord {
NSString GDATA_UNSAFE_UNRETAINED *label;
NSString GDATA_UNSAFE_UNRETAINED *keyPath;
GDataDescRecTypes reportType;
} GDataDescriptionRecord;
And the
__weak GDataObject *parent_; // parent in tree of GData objects
to
GDataObject GDATA_UNSAFE_UNRETAINED *parent_;
This is the link to google update:
http://code.google.com/p/gdata-objectivec-client/source/detail?r=712
That's it.
Hope it will help someone
Shani