Re: OS_OBJECT_USE_OBJC_RETAIN_RELEASE and xpc_release()
Re: OS_OBJECT_USE_OBJC_RETAIN_RELEASE and xpc_release()
- Subject: Re: OS_OBJECT_USE_OBJC_RETAIN_RELEASE and xpc_release()
- From: Greg Parker <email@hidden>
- Date: Sat, 03 Nov 2012 16:28:49 -0700
On Nov 3, 2012, at 12:55 PM, Jerry Krinock <email@hidden> wrote:
> About a year ago, I built a tool which did some XPC and, following documentation I read somewhere, invoked xpc_release(). This little project uses ARC and stills builds OK in Xcode 4.5.2.
>
> I want to absorb it into a big old project that contains a couple dozen targets. So I added a target for it, with ARC. But building the big project fails because the macro OS_OBJECT_USE_OBJC_RETAIN_RELEASE is defined, and in xpc.h this redefines xpcrelease, which is also apparently a macro, to be a function which invokes -release, which is not allowed under ARC.
>
> In the little project, OS_OBJECT_USE_OBJC_RETAIN_RELEASE is not defined. And *I* have not defined it in the big project, in any of my code, but apparently this definition got included somewhere.
>
> How might it have gotten defined, and should it be defined or not? In the documentation of xpc_release(), there is no indication to not use it under ARC. Indeed it could be defined elsewhere, to do something different.
If you build with the 10.8 SDK, and your deployment target is 10.8 or later, then dispatch objects and XPC objects become Objective-C objects. If you use ARC then they are ordinary ARC-managed objects and you do not retain and release them yourself.
You can temporarily revert to the old behavior by defining OS_OBJECT_USE_OBJC=0. Going forward the solution is to remove your manual retain/release calls and let ARC do the work. (I can't remember if the ARC migrator handles dispatch and XPC now. You might try re-running the ARC migrator on your ARC code and see if it catches them.)
My guess is that your two projects behave differently because they have different deployment targets.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden