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

Fix build on OS X #159

Conversation

rivera-ernesto
Copy link
Member

#156 and #121 were not tested on OS X.

  • Fix build on OS X
  • Test for OS X 10.9
  • Stop ignoring deprecation warnings.

利辺羅エルネスト added 3 commits November 8, 2013 11:20
No longer necessary after pull requests CocoaLumberjack#121 and CocoaLumberjack#156, and more importantly, that was ugly.
@rivera-ernesto
Copy link
Member Author

Came up with three cases:

a) Newer SDK's (iOS 7+/OS X 10.9+) on newer (iOS 7.0+/OS X 10.9+) runtime
queueLabel = dd_str_copy(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL));

b) Systems where dispatch_get_current_queue is not yet deprecated and won't crash (< iOS 6.0/OS X 10.9)

dispatch_queue_t currentQueue = dispatch_get_current_queue();
queueLabel = dd_str_copy(dispatch_queue_get_label(currentQueue));

c) Give up
queueLabel = dd_str_copy("");

Any comments? @robbiehanson, @bpoplauschi, @kolyuchiy, @sprhawk?

@bpoplauschi
Copy link
Member

I think DISPATCH_CURRENT_QUEUE_LABEL is not defined for OS X

@rivera-ernesto
Copy link
Member Author

From MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/dispatch/queue.h:

/*!
 * @const DISPATCH_CURRENT_QUEUE_LABEL
 * @discussion Constant to pass to the dispatch_queue_get_label() function to
 * retrieve the label of the current queue.
 */
#define DISPATCH_CURRENT_QUEUE_LABEL NULL

/*!
 * @function dispatch_queue_get_label
 *
 * @abstract
 * Returns the label of the given queue, as specified when the queue was
 * created, or the empty string if a NULL label was specified.
 *
 * Passing DISPATCH_CURRENT_QUEUE_LABEL will return the label of the current
 * queue.
 *
 * @param queue
 * The queue to query, or DISPATCH_CURRENT_QUEUE_LABEL.
 *
 * @result
 * The label of the queue.
 */
__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW
const char *
dispatch_queue_get_label(dispatch_queue_t queue);

@bpoplauschi
Copy link
Member

I can't find it. Could you try building Xcode/LumberjackFramework/Desktop just to be sure?

// a) Compiling against newer SDK's (iOS 7+/OS X 10.9+) where DISPATCH_CURRENT_QUEUE_LABEL is defined
// on a (iOS 7.0+/OS X 10.9+) runtime version
BOOL gotLabel = NO;
#ifdef DISPATCH_CURRENT_QUEUE_LABEL
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It builds, but it would anyway because of this check.

@bpoplauschi
Copy link
Member

You're correct. I meant to say that because DISPATCH_CURRENT_QUEUE_LABEL doesn't exist on Mac OS, the Mac path from case a) is never executed. If you see DISPATCH_CURRENT_QUEUE_LABEL defined on Mac, could you tell me in which file?

@bpoplauschi
Copy link
Member

Disregard my last comment. I just saw your definition of DISPATCH_CURRENT_QUEUE_LABEL. I'm still running Mountain Lion, that's why it's undefined for me.

@rivera-ernesto
Copy link
Member Author

I'll have to leave now but you and @kolyuchiy can work directly on this pull request if you feel like (added you as collaborators in the fork).

@bpoplauschi
Copy link
Member

@rivera-ernesto The pull request sounds right to me. I will go ahead and merge it.

bpoplauschi added a commit that referenced this pull request Nov 8, 2013
@bpoplauschi bpoplauschi merged commit bf7f218 into CocoaLumberjack:master Nov 8, 2013
@bpoplauschi
Copy link
Member

@robbiehanson @kolyuchiy @sprhawk you guys should still review and comment

#if TARGET_OS_IPHONE
[[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending // 7.0+
#else
[[NSApplication sharedApplication] respondsToSelector:@selector(occlusionState)] // No nice way to check for OS X 10.9+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this bug actually reproduces on Mac OS? Maybe we don't have to check and just use dispatch_queue_get_label(currentQueue)?

@rivera-ernesto
Copy link
Member Author

I think that avoiding deprecated methods is good even if they don't crash on OS X.

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

Successfully merging this pull request may close these issues.

None yet

3 participants