kstenerud / iOS-Universal-Framework

An XCode project template to build universal frameworks (arm7, arm7s, and simulator) for iOS / iPhone.
2.95k stars 473 forks source link

Categories + LoadableCategory.h #22

Closed u10int closed 12 years ago

u10int commented 12 years ago

Thanks for the awesome work as it works really well for creating custom static frameworks!

I have noticed an issue that seems to be random, though. I have custom categories in my framework, so I had to use your LoadableCategory.h method so that they are properly linked into the final library. For the most part this works well without any issues. At times, especially when creating an archived build for adhoc distribution of my app using the custom framework, I get a compiler error similar to:

ld: duplicate symbol _OBJCCLASS$_FORCELOAD_SomeConcreteClass_MyAdditions in...

In the class category implementations I am using your MAKE_CATEGORIES_LOADABLE(SomeConcreteClass_MyAdditions); method, making sure it's always unique. I don't always get the duplicate symbol error on the same category, which makes it appear to be more random and something odd is happening. I have verified the files don't exist more than once which I know also causes the duplicate symbol error.

Any ideas?

u10int commented 12 years ago

More info... the issue seems to happen mostly in Xcode 4.2, though have verified it occurs in Xcode 4.0 also.

kstenerud commented 12 years ago

Hmm... I'm not sure what would cause this. Can you distill it into a project that you can send to me? I'm still in Xcode 4.0.2 since I haven't been able to get Lion installed yet.

0xced commented 12 years ago

Xcode 4.2 beta also runs on Snow Leopard FYI.

u10int commented 12 years ago

@kstenerud Sample project sent. Note that since I'm using Xcode 4.2 beta the project depends on libz.1.2.5.dylib, which is not yet available in Xcode 4.x. You can just remove this dependency and replace it with libz.1.2.3.dylib when testing.

0xced commented 12 years ago

You can link on libz.dylib which is a symlink that points to the latest version of libz so that it will work with any version of the SDK.

u10int commented 12 years ago

@0xced sweet thanks, good to know.

u10int commented 12 years ago

With the help of @kstenerud, found the issue. Posting it here in case others have the same and for reference.

It appears that somehow a reference to Build/Products was automatically included in the Framework Search Paths build setting. Once I removed that, the duplicate symbol errors were gone. :)

zhouhuishine commented 12 years ago

try this:

add "-all_load" in "other link flag"