Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Which iOS Frameworks are Available?

Tags:

ios

I'm writing a static library for iOS. I want to programmatically figure out if CoreLocation is added to the project, is there any way to do that?

like image 539
Julie Avatar asked Nov 21 '25 14:11

Julie


1 Answers

Probably something like:

if(NSClassFromString(@"CLLocationManager"))
{
    NSLog(@"CoreLocation is available");
}

Would do it. NSClassFromString takes an NSString and checks whether there's a class of that name currently available in the runtime. If so then it returns the Class object, otherwise it returns nil. The if statement there effectively compares to nil.

So, the logic you're applying is "does a class called CLLocationManager currently exist?", which is a proxy for checking that CoreLocation is loaded because it's one of the fundamental classes to that framework.

like image 186
Tommy Avatar answered Nov 23 '25 02:11

Tommy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!