Re: including xibs from another project
Re: including xibs from another project
- Subject: Re: including xibs from another project
- From: Roland King <email@hidden>
- Date: Wed, 20 Jan 2010 21:12:50 +0800
On 20-Jan-2010, at 2:36 AM, Fritz Anderson wrote:
> On 19 Jan 2010, at 11:43 AM, Jocelyn Houle wrote:
>
>> -all_load: This one seems a bit overkill, as all of my unused classes will be kept in the final binary, potentially bloating it.
>
> But that's the point. There is no way in principle for a linker to know whether an Objective-C class or method is unused. If you want a class you do use to be linked from a static library, you have to include them all.
>
> — F
I'm still working on this - I found otool, I found ocx, I'm still confused.
If these were classes which were only in the nib and not in the code at all, I'd understand that, but they aren't. The main class, IPConectionBrowser (which is created in client code and which is correctly linked in from the static library) has a member variable of type IPConnectionList and it calls methods on it. However the code for that class (IPConnectionList), is NOT linked in from the static library, not even the method which IPConnectionBrowser calls.
If however I put a bogus [ IPConnectionList alloc ] then that whole class is linked from the static library. (and yes that is a stupid line but it's just illustrative of the minimum I had to do).
So it seems the linker only links in the class code (all of it) if you call any method on the class itself, calling an instance method is not enough. Why would that be? Is this a rather too-aggressive optimization which presumes that if you don't call any class method on a class then you can't possibly have actually created one so therefore any method calls must be on nil objects so you don't need the code? If so, especially given that NIBs exist, that's slightly overoptimistic. Or is there some other reason for not linking code based just on a method call to an instance and not a class method call?
Where, by the way, in the mach-O file is the 'hint' which tells the linker 'if you link class-A, it has a call to a class method of class-B so you better link that too' or does it just find these class calls on the way through doing link fixup?
I do understand by the way why -all_load works around this, I just don't understand why my instance method calls aren't enough to cause the linker to pull code in and I need class method calls.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden