On Nov 3, 2012, at 12:55 PM, Jerry Krinock <je...@ieee.org> 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     gpar...@apple.com     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to