I want my app to support iOS 8 and 9. I updated my app to use Swift 2 and added spotlight indexing for iOS 9 devices, but now on iOS 8 my app will crash on launch with the error
dyld: Library not loaded: /System/Library/Frameworks/CoreSpotlight.framework/CoreSpotlight
Referenced from: /private/var/mobile/Containers/Bundle/Application/77AE43CF-C71D-462B-92FD-D8EAF6DB53B5/TVShows.app/TVShows
Reason: image not found
If I comment out the code I have in the app delegate method
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool
then the app will run fine.
Here is my implementation of continueUserActivity,
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
if #available(iOS 9.0, *) {
if userActivity.activityType == CSSearchableItemActionType {
if let showIdentifier = userActivity.userInfo?[CSSearchableItemActivityIdentifier] as? String {
// More code
}
}
}
else if let userInfo = userActivity.userInfo {
/
if let episodeTraktID = userInfo["displayEpisode"] as? NSNumber {
// More code
}
}
return true
}
If I comment out from the first if to the else, then it will work fine. Is this just a bug or how can I implement CoreSpotlight and keep this method for handoff on iOS 8?