Wednesday, September 28, 2011

Weak link in iphone SDK


Well, there happened a case when I was using the latest iOS SDK  for the development purpose, and built an application which utilized the eventKit framework, and the framework used "eventKit" was a new addition to the framework list.

I used the eventKit on the fly and submitted to the appstore for the approval process, and as a matter the application was approved.

But, the case happened when the application was being downloaded and it used to crash at the app launch on the earlier iOS's.

Digging around the problem, I came to know about the weak link thing for a framework, and uploaded the updated build to app store.

The idea is that, If you are using a framework that is not available to all the devices that you have selected as target devices, make the framework as weak link.

This can be done as below:
* Select the project target > Right click > Get-Info.
* Go to general tab > Linked libraries.
* Select the framework and make it a weak link.



Also, keep in if you mark a framework as weak linked, be sure to check for its availability before using any of its functionally.

You can check for the existence of the class like below code sample:

Class theClass = (NSClassFromString(@"UILocalNotification"));
if(theClass){
// Class exists
}
else{
// Class does not exists
}

No comments:

Post a Comment