Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS_OBJECT_USE_OBJC is disabled for all Cocoapods #2659

Closed
rsanchezsaez opened this issue Oct 13, 2014 · 4 comments
Closed

OS_OBJECT_USE_OBJC is disabled for all Cocoapods #2659

rsanchezsaez opened this issue Oct 13, 2014 · 4 comments

Comments

@rsanchezsaez
Copy link

Since iOS 6.0+ and OS X 10.8+, GDC queues are full ObjC objects, and hence they are managed by ARC. This is denoted by the OS_OBJECT_USE_OBJC preprocessor constant having a non-zero value, as seen here.

We are using a project with the Base SDK set to iOS 8.0 and the Deployment Target set to iOS 7.0.

This is the first line of our Podfile:

platform :ios, '7.0'

so all of our Pods project targets have a iOS 7.0 Deployment target as well.

Using this code

#if OS_OBJECT_USE_OBJC
    NSLog(@"OS_OBJECT_USE_OBJC=1")
#else
    NSLog(@"OS_OBJECT_USE_OBJC=0");
#endif

from our AppDelegate correctly prints OS_OBJECT_USE_OBJC=1. Using that code from within any source file on the Pods project seems to print OS_OBJECT_USE_OBJC=0.

I read somewhere that using of GDC queues as objects can be opted-out, but I cannot find any related setting on Xcode's Build Settings. I think this is a Cocoapods bug and that OS_OBJECT_USE_OBJC should be enabled by default within the Pods when the Deployment target is iOS 6.0+ or OS X 10.8+.

See this SO question for additional info.

@segiddins
Copy link
Member

@rsanchezsaez where does the OS_OBJECT_USE_OBJC definition usually come from? A system header that must be imported?

@rsanchezsaez
Copy link
Author

It comes from libdispatch's os/object.h, which is in turn imported by <dispatch/dispatch.h> (docs). According to the code, it should be 1 when the deployment target is OS X 10.8+ or OS X 6.0+.

#ifndef OS_OBJECT_HAVE_OBJC_SUPPORT
#if defined(__OBJC2__) && !defined(__OBJC_GC__) && ( \
    __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8 || \
    __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0)
    #define OS_OBJECT_HAVE_OBJC_SUPPORT 1
#else
    #define OS_OBJECT_HAVE_OBJC_SUPPORT 0
#endif
#endif

#if OS_OBJECT_HAVE_OBJC_SUPPORT
    #ifndef OS_OBJECT_USE_OBJC
        #define OS_OBJECT_USE_OBJC 1
    #endif
#elif defined(OS_OBJECT_USE_OBJC) && OS_OBJECT_USE_OBJC
    /* Unsupported platform for OS_OBJECT_USE_OBJC=1 */
    #undef OS_OBJECT_USE_OBJC
    #define OS_OBJECT_USE_OBJC 0
#else
    #define OS_OBJECT_USE_OBJC 0
#endif

I'm not sure where the problem is coming from. Adding #import <dispatch/dispatch.h> to the relevant files makes no difference, the printed result from the Pods seems to always be OS_OBJECT_USE_OBJC=0 (and yet it works from the main project's AppDelegate).

@alloy
Copy link
Member

alloy commented Oct 15, 2014

This is not a CocoaPods bug. Please see the documentation about the deployment target of a podspec http://guides.cocoapods.org/syntax/podspec.html#deployment_target

And a quick search of the tickets yielded at least:

In the future, please read the CONTRIBUTING file before posting new tickets.

@alloy alloy closed this as completed Oct 15, 2014
@rsanchezsaez
Copy link
Author

My bad, sorry about that. Thanks for the clarification! Makes perfect sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants