2

In a library that may be built with an iOS 5.x/OS X 10.7 deployment target or with a newer one I had a problem for properly defining a dispatch_queue_t property.

For the most part I could solve it as suggested here:

#if OS_OBJECT_HAVE_OBJC_SUPPORT // == 1 not really needed
@property (nonatomic, strong) dispatch_queue_t loggerQueue; // An Objective-C object
#else
@property (nonatomic, assign) dispatch_queue_t loggerQueue; // A C pointer
#endif

This works when manually creating a static library or when including the file directly in a project.

When this code is added to a CocoaPods library however it breaks for iOS 6+/OS X 10.8+ deployment targets. CocoaPods properly sets the deployment targets and the compiler do sets OS_OBJECT_HAVE_OBJC_SUPPORT == 1 and chooses the strong definition. I get however the iOS 5.x/OS X 10.7 error:

Property with 'retain (or strong)' attribute must be of object type

I tried comparing the resulting environment variables between CocoaPods and the static library but there's nothing that seems suspicious.

For now I have patched it by disabling the strong definition altogether when building with CocoaPods:

#if OS_OBJECT_HAVE_OBJC_SUPPORT && !defined(COCOAPODS)
@property (nonatomic, strong) dispatch_queue_t loggerQueue; // Always disabled
#else
@property (nonatomic, assign) dispatch_queue_t loggerQueue;
#endif
Community
  • 1
  • 1
Rivera
  • 10,792
  • 3
  • 58
  • 102

1 Answers1

2

Seems like older CocoaPods was redefining OS_OBJECT_USE_OBJC breaking OS_OBJECT_HAVE_OBJC_SUPPORT.

We got this fixed by checking OS_OBJECT_USE_OBJC and using a newer CocoaPods.

Rivera
  • 10,792
  • 3
  • 58
  • 102