Re: Problem with extension moved to a static library - "unrecognized selector sent to instance"
Re: Problem with extension moved to a static library - "unrecognized selector sent to instance"
- Subject: Re: Problem with extension moved to a static library - "unrecognized selector sent to instance"
- From: "Stuart Williams" <email@hidden>
- Date: Tue, 7 Oct 2008 12:07:00 -0700
Jean-Daniel-
Thank you for you quick reply.
I tried adding the flag "-W,ObjC" to the application project first, in the "Other linker flags" section; that did not fix the problem. I then added it to the static library project, and got the following link error:
"libtool: unknown option character 'W' in: -W,ObjC"
If I remove the -W, and just enter -ObjC, it compiles, but the result is the same.
I also noticed that there is an option in XCode under "Deployment" called "Strip Linked Product", but that doesn't seem to have any affect either.
Am I setting the linker flag incorrectly?
Regards,
Stuart
On Tue, Oct 7, 2008 at 11:41 AM, Jean-Daniel Dupas
<email@hidden> wrote:
Le 7 oct. 08 à 20:28, Stuart Williams a écrit :
XCode experts-
I have an extension to NSFileManager that was working fine. The .h and .m for the extension was located in a project that built my application. Since the extension was pretty generic, I decided to move the extension (along with a number of other classes) to another XCode project, the target of which was a static library.
The new static library project builds fine with no errors, as does the original application project that has a dependency on the new static library project.
The problem is that when I run the application, I get a "unrecognized selector sent to instance" error when I attempt to use the extension from the application. My guess is that that link phase is failing to pick up the application's dependency on the the object code in the static library, but I'm not sure if that's the problem.
Can anyone shed any light on this problem? Is there any reason I can't define an extension in a static library and then use that extension in another project?
Thanks,
Stuart
You should add a linker flags:
-W,ObjC
man ld:
-ObjC Loads all members of static archive libraries that implement an Objective-C class or category.
The linker strip the code that is not referenced in static libraries, and objc extensions are never directly referenced (due to the dynamic nature of ObjC), and so, it does not include it in your final executable.
_______________________________________________
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