Reputation: 2167
I am trying to run my project on iOS 6 and I have set all the appropriate build settings to let me do so, but when I run on iOS 6 I get this error:
dyld: Symbol not found: _OBJC_CLASS_$_NSURLSession
Referenced from: /var/mobile/Applications/8AC09960-A403-413E-B70A-E03DB2AF5844/Flywheel.app/Flywheel
Expected in: /System/Library/Frameworks/Foundation.framework/Foundation
in /var/mobile/Applications/8AC09960-A403-413E-B70A-E03DB2AF5844/Flywheel.app/Flywheel
What gives?? iOS 7 works fine.
Upvotes: 4
Views: 3569
Reputation: 280
NSURLSession
is available above iOS 7. you could find the defination in NSURLSession.h
.
NS_CLASS_AVAILABLE(10_9, 7_0)
@interface NSURLSession : NSObject
Please use before checking the system version or checking if this class is available.
if (NSClassFromString(@"NSURLSession") != nil) {
// available
// your code
} else {
// not available
// other solutions
}
UPDATE
Explanation:
Some friends thought NSClassFromString()
is not recommended that I needn't use it here.
I agree to half. Generally, NSClassFromString()
is not recommended when using to new a instance or operate a class. But I now use to judge whether the class is available (is nil
or not), and I do not produce a class pointer with a string.
I believe that sometimes we can be flexible.
Anyway, if you don't like use NSClassFromString()
, I finally found a better way to check if the class is available:
if ([NSURLSession class]) {
// available
} else {
// not available
}
Upvotes: -1
Reputation: 702
The issue here is that the symbol isn't available on iOS 6. So you have to weak link the Foundation Framework by setting it's status to "optional" in Build Phases -> Link Binary With Libraries.
Upvotes: 16
Reputation: 6844
NSURLSession
is an iOS7 thing only. You will have to use the good old NSURLConnection
with iOS 6, sadly.
Upvotes: 0
Reputation: 318884
NSURLSession
was added in iOS 7. Any improper reference to it in your app will cause this problem when run on a device with iOS 6. You need to use proper techniques to ensure the class is never referenced under iOS 6.
Upvotes: 6
Reputation: 2167
If you're using cocoapods, check your Podfile. It may have
platform :ios, '7.0'
instead of
platform :ios, '6.0'
Upvotes: 13