Breaking News
Home / iOS / iOS Snippets / How to Weak Link a Lib in iOS?

How to Weak Link a Lib in iOS?

Ios Framework WeaklinkIn an iOS project you specify a Base SDK and a target SDK for a project. Normally the base SDK is a higher version SDK say 4.3 and target SDK version is generally equal to or less than the base SDK. Every release of the SDK some new classes and function are added. In order to run you app on more devices you would generally chose a lower target say 3.2 as more and more people would have that compared to the latest. However when you build your app with a higher base version it links certain classes which may not be available in the lower version, resulting in an exception as show below.

sharedlibrary apply-load-rules all
dyld: Symbol not found:
I<!>

Issue

_OBJC_CLASS_$_UIPopoverController
Referenced from: /var/mobile/Applications/C7A675D5-BA8B-4C1E-B990-098C5EC03312/Contacto.app/Contacto
Expected in: /System/Library/Frameworks/UIKit.framework/UIKit
in /var/mobile/Applications/C7A675D5-BA8B-4C1E-B990-098C5EC03312/Contacto.app/Contacto
kill
quit
Program ended with exit code: 0

Class cls = NSClassFromString(@”UIPopoverController”);

In the above error UIPopoverController class is being referenced with is used for iPad and the same app needs to run on iPhone as well. The iPhone device does not have this class as its running 3.2 SDK. Even though this class is not in the code execution path and just referenced, yet you still get this error.

Solution

In order to solve this Weak link the Framework where we get this error. If you see in the below screenshot the UIKit.framework has been made Optional instead of required. In this way you can still use a higher base version of SDK , target for lower version by weak leaking of any such conflicting Frameworks.

UIKit Weak Kit

[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger