Quentin Hayot
Quentin Hayot

Reputation: 7876

How do I weak link frameworks on Xcode 4?

I need to weak link some framework with my target.
But I can't find how to do it...

If I try to run my project on 3.2 iPad simulator i get the following error:

dyld: Library not loaded: /System/Library/Frameworks/iAd.framework/iAd
Reason : Image not found

Thanks !

Upvotes: 34

Views: 13661

Answers (2)

ronguotech
ronguotech

Reputation: 91

This doesn't work now. Please follow the link below: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html

Select the target you want to modify and reveal its build phases.

Expand the Link Binary With Libraries build phase to view the frameworks currently linked by the target.

If the framework you want to weakly link to is listed in the Link Binary With Libraries build phase, select it, and choose Edit > Delete to remove it.

Now you can tell the linker to use weak linking for that framework.

Select the target, open its Info window, and click Build.

To the Other Linker Flags build setting, add the following command-line option specification, where FRAMEWORK_NAME is the name of the framework you want to weakly link to: -weak_framework FRAMEWORK_NAME

Build your product.

Upvotes: 9

uvesten
uvesten

Reputation: 3355

Go to your project -> Targets -> Build Phases -> Link Binary with Libraries.

Then change the library you want to weak-link from "Required" to "Optional".

Upvotes: 57

Related Questions