I've an iOS app that has spotlight search feature which allows user to search items from an app. It works fine on iOS app
I am in the process of migrating the app as a catalyst app, somehow the spotlight search on mac catalyst app is not working
So far following things have been checked
Spotlight search logic is working as expected, there are no errors
Restarted Mac
Open catalyst app multiple times just to check if it is syncing with core spotlight and it is.
No previous issues registered on stack-overflow
Env: macOS 12.0.1
P.S: I am unsure if it is related to specific to my code as it is working fine on iPad and iPhone devices.
let attributeSet = CSSearchableItemAttributeSet(contentType: .content)
attributeSet.title = decodeItem.name
attributeSet.relatedUniqueIdentifier = decodeItem.id
attributeSet.url = URL.init(string: decodeItem.url)
let searchableItem = CSSearchableItem(uniqueIdentifier: decodeItem.id,
domainIdentifier: "com.xxx.xxxx",
attributeSet: attributeSet)
searchableItems.append(searchableItem)
CSSearchableIndex.default().indexSearchableItems(searchableItems) { error in
if let error = error {
print("Issue indexing: \(error)")
} else {
print("Indexed.")
}
}
Found the issue: Assign value to attributeSet.relatedUniqueIdentifier only from initializer
Related
I am trying to add Chromecast in my iOS app. I have installed google cast pod file and integrate the google cast developer console.Now when I tried with the GCKUICastButton in my screen, after tapping the button for first time the button is diss appearing and facing a error in console
"Message from Chromecast = Failed to search for net services with error dictionary {NSNetServicesErrorCode = "-72008";NSNetServicesErrorDomain = 10;}"
let discoveryCriteria = GCKDiscoveryCriteria(applicationID: appId)
let castOptions = GCKCastOptions(discoveryCriteria: discoveryCriteria)
GCKCastContext.setSharedInstanceWith(castOptions)
GCKLogger.sharedInstance().delegate = self
Wrote this code in app delegate, still unable to solve the issue. any help much appreciated.
We are using Core Data with Core Spotlight integration. Very sporadic Crashlytics sends an error report about with the crash NSInvalidArgumentException reads as "Can't add store". We never had this problem in development nor during testing. We have configured Core Data and Spotlight like this:
let mom = NSManagedObjectModel(contentsOf: modelURL)
let container = NSPersistentContainer(name: "DataModel", managedObjectModel: mom!)
container.persistentStoreDescriptions = [NSPersistentStoreDescription(url: storeURL)]
if let persistentStoreDesc = container.persistentStoreDescriptions.first {
persistentStoreDesc.shouldInferMappingModelAutomatically = false
persistentStoreDesc.shouldMigrateStoreAutomatically = false
persistentStoreDesc.type = NSSQLiteStoreType
let spotlightDelegate = CoreDataCoreSpotlightDelegate(forStoreWith: persistentStoreDesc, model: container.managedObjectModel)
persistentStoreDesc.setOption(spotlightDelegate, forKey: NSCoreDataCoreSpotlightExporter)
}
I have searched the internet and cam up with one person who has the same problem https://forums.developer.apple.com/thread/115897
Did any of you had the same problem and knows a solution?
The last time it happened it was on:
OS Version: 12.0.1 (16A404)
Device: iPad Air 2
That's my post from a while back - sorry, I should have followed up on it! I talked to an engineer at WWDC who informed me that it was fixed in iOS 13. And indeed, we have not seen that crash on any 13 variant. As far as I know there is no workaround for prior versions of iOS. Sorry to be the bearer of bad news.
I have faced very strange bug in my application where I show list of news from remote server.
I have 2 languages - english as main, and russian as supplementary. My server has two json files, for eng and ru localisations.
When requesting for data from server I do language check like this:
let preferredLanguage = NSLocale.preferredLanguages[0]
if preferredLanguage == "uk" || preferredLanguage == "ru" {
requestLink = RequestLinks.secondDateProgram.rawValue
} else {
requestLink = RequestLinksEng.secondDateProgram.rawValue
}
And this all system works fine, correct link being generated and request shows correct data, all works fine but ONLY on my iPhone 7.
When I install and launch exactly the same app version (from TestFlight or Diawi) on any other device my list of news in russian version of app for some reason has first item from english json file. But when I switch phone to english - everything works fine.
I don't have any cache, and I don't store any news to Realm. I do manual cache cleaning before each request and still the same - on my iPhone it works fine, on other nope(tested on iphone 7 plus, and 11).
If anyone had same issue before - would be grateful for any help.
My problem was here - let preferredLanguage = NSLocale.preferredLanguages[0]
This detects Application language, but not iPhone's, that's why I got english instead of russian.
Changing it to NSLocale.current.languageCode did the trick.
I'm quite new to Swift programming
I've made a simple test application that open the settings programmatically, by a specific button.
Unfortunately after the update the button, instead of opening the desired setting page (the wifi page, in this case) open only the generic setting screen
Could someone please help me understanding what exactly changed in swift 4, in order for me to fix this behaviour? Thansk a lot!
First code used - (i've either changed the iOS available to iOS 11.0, in order to match the deployment)
if let url = URL(string:"App-Prefs:root=WIFI") {
if UIApplication.shared.canOpenURL(url) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
second code used:
let url = URL(string: "App-Prefs:root=WIFI")
UIApplication.shared.openURL(url!)
EDIT
Unfortunately the question raised is different from mine - i cannot anymore open the settings of the device, the other question ask how to open directly the settings of the APP
Urls like App-Prefs:root are prohibited in App Store and using it causing app rejection.
If you want open app preferences you could use UIApplicationOpenSettingsURLString
I am using the GoogleMaps SDK (maps & places). For some reason the following callback is not being called. I have put loggers in there but nothing happens.
var placesClient : GMSPlacesClient?
...
func run(){
self.placesClient?.currentPlaceWithCallback({ (list: GMSPlaceLikelihoodList?, error: NSError?) -> Void in
if let error = error {
println("error: \(error.description)")
return
}
if let list = list {
self.renderList(list)
}
})
}
For some reason the block in currentPlaceWithCallback does not get called. Yesterday it happened because my API had a wrong bundle identifier, after changing which it started working. But today it stopped.
Any idea why this would happen ? Also, are we exposed to any API logs by Google ?
I was getting the same issue on my iPhone 6 device AND iPhone 6 simulator.
The fix was to add the NSLocationWhenInUseUsageDescription permission in Info.plist! But, it worked only on my iPhone 6 device, NOT the simulator.
As mentioned in the Google Place Guide:
(https://developers.google.com/places/ios-api/start)
Please note, as this sample requires access to the location of the device to get the current location, you will need to set the NSLocationWhenInUseUsageDescription key with appropriate explanatory text in your project's Info.plist file. For more details, see the guide to getting current place.
Now, the way I got it working on the iPhone simulator was by changing my location on the Simulator: Debug -> Location. That is, it was set to 'Apple' by default, I just changed it to Bicycle Ride.
It worked for me, may not for all.