CocoaPods库中强大的dispatch_queue_t [英] Strong dispatch_queue_t in CocoaPods library
问题描述
在一个可能使用iOS 5.x / OS X 10.7部署目标或更新目标构建的库中,我遇到了正确定义 dispatch_queue_t
属性的问题。
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.
将此代码添加到CocoaPods库中后,对于iOS 6 + / OS X 10.8+部署目标,它就会中断。
CocoaPods正确设置了部署目标,编译器确实设置了 OS_OBJECT_HAVE_OBJC_SUPPORT == 1
并选择了 strong
定义。但是,我得到了iOS 5.x / OS X 10.7错误:
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:
具有 retain(或strong)属性的属性必须是对象类型
Property with 'retain (or strong)' attribute must be of object type
我尝试比较CocoaPods和静态库之间的结果环境变量,但似乎没有可疑之处。
I tried comparing the resulting environment variables between CocoaPods and the static library but there's nothing that seems suspicious.
到目前为止,我已经通过在使用CocoaPods进行构建时完全禁用了 strong
的定义对其进行了修补:
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
推荐答案
似乎像旧版的CocoaPods一样正在重新定义 OS_OBJECT_USE_OBJC
打破 OS_OBJECT_HAVE_OBJC_SUPPORT
。
Seems like older CocoaPods was redefining OS_OBJECT_USE_OBJC
breaking OS_OBJECT_HAVE_OBJC_SUPPORT
.
我们得到了这个已修复,方法是检查 OS_OBJECT_USE_OBJC
并使用较新的CocoaPods。
We got this fixed by checking OS_OBJECT_USE_OBJC
and using a newer CocoaPods.
这篇关于CocoaPods库中强大的dispatch_queue_t的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!