• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with extension moved to a static library - "unrecognized selector sent to instance"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:37:29 -0700

Jean-Daniel-

That did the trick!  I added -ObjC to the "Other Linker Flags" in the application, and everything started working again.

Thanks for your help.

Regards,
Stuart

On Tue, Oct 7, 2008 at 12:25 PM, Jean-Daniel Dupas <email@hidden> wrote:
Yep, sorry I misspell the flags:

According to this thread, it should work with just -ObjC

http://www.cocoabuilder.com/archive/message/xcode/2008/7/28/23713

Make sure Xcode relink your application after you set this flag. (a clean/build may be require).


Le 7 oct. 08 à 21:07, Stuart Williams a écrit :

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

References: 
 >Problem with extension moved to a static library - "unrecognized selector sent to instance" (From: "Stuart Williams" <email@hidden>)
 >Re: Problem with extension moved to a static library - "unrecognized selector sent to instance" (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Problem with extension moved to a static library - "unrecognized selector sent to instance" (From: "Stuart Williams" <email@hidden>)
 >Re: Problem with extension moved to a static library - "unrecognized selector sent to instance" (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Problem with extension moved to a static library - "unrecognized selector sent to instance"
  • Next by Date: RE: XCode and Interface builder
  • Previous by thread: Re: Problem with extension moved to a static library - "unrecognized selector sent to instance"
  • Next by thread: Link to static library
  • Index(es):
    • Date
    • Thread