When creating an Intents.intentdefinition file, the generated Intent subclass source defines the class as:
#available(iOS 12.0, macOS 10.16, watchOS 5.0, *) #available(tvOS, unavailable)
#objc(OrderSoupIntent)
public class OrderSoupIntent: INIntent {}
But INIntent became available in iOS 10: https://developer.apple.com/documentation/sirikit/inintent
Why is the generated class iOS 12+ only? Can it be iOS 11+?
I found that custom intents was introduced in iOS 12. While I couldn't find in the SiriKit documentation, here's the WWDC video introducing the feature: https://developer.apple.com/videos/play/wwdc2018/211
Siri Shortcuts are a powerful new feature in iOS 12 that allow your app to expose its functionality to Siri.
Related
I want to use NotificationCenter inside a watchOS target. But I get the following error message when building the app at import NotificationCenter:
NotificationCenter is not available when building for watchOS Simulator.
Consider using `#if !os(watchOS)` to conditionally import this framework.
How do you handle this situation? Can I no longer use the simulator?
Ok, I mixed things up. All I want to do in my watchOs framework was something like this:
NotificationCenter.default.post(...)
The class with import NotificationCenter was in the wrong framework. No need for such a class in a watchOs framework. So my problem is fixed.
My app needs to target iOS 12, but use features from iOS 13 when they're available (notably menus for Catalyst).
I've marked my AppDelegate as available in iOS 13+ with the #available attribute; I think I saw this as a solution on another post here. But my app crashes on iOS 12 because it still calls an iOS 13 function that's not available in iOS 12 (UIWindow's overrideUserInterfaceStyle). This seems like a bug, but then... why does the app even launch under iOS 12, when I've marked its entire delegate as iOS 13+ only?
And what's the correct way to provide an alternate definition of the class for pre-iOS 13 versions? If I create another declaration in the same file but mark it with #available(iOS 12, *), the compiler complains about the duplicate definition.
I can mark each offending method with #available instead of the whole class, but this breaks down when you encounter a stored property of a type that's not available in the older OS version; the compiler complains that you can't make a stored property potentially nonexistent by putting #available on it.
I need to notify WidgetKit to reload my iOS 14 widget. In Swift you can do that using WidgetCenter:
WidgetCenter.shared.reloadAllTimelines()
However, WidgetKit seems to be unavailable in Xamarin.iOS.
WidgetKit's reloadAllTimelines is not currently available to Xamarin.iOS (it is available only via the Swift-based frameworks and technically Xamarin.iOS binds the ObjC frameworks).
It is on the Xamarin.iOS enhancement list
[Xcode 12] WidgetKit reloadTimelines API is Swift only but really needs to be callable from C# host app #9215
Currently you would need to write a Swift library and then Xamarin.iOS bind it to expose it so you can call it from .Net code.
Bind iOS Swift libraries
[xcode12] WidgetKit #8933
Third-party repo/project that exposes WidgetKit's ReloadTimeLinesOfKind, ReloadAllTimeLines, & GetCurrentConfigurationsWithCompletion (see Wojciech Kulik's comment below)
I want to receive RSSI of iBeacon on my iOS application this code can run on iOS12. Now I have updated to iOS 13 this code can't run.
and alert
'init(proximityUUID:identifier:)' was deprecated in iOS 13.0
'startRangingBeacons(in:)' was deprecated in iOS 13.0
'stopRangingBeacons(in:)' was deprecated in iOS 13.0
How to fix this problem?
If you look at the documentation for the method your are using it tells you that it was deprecated in iOS 13 and also tells you what to use instead.
In case the link breaks, this is the alternative option:
init(uuid:major:minor:identifier:)
Check the documentation for the other methods and it will tell you which alternatives to use.
Now.. to configure your app to switch between methods based on the iOS version you can use an #available check..
if #available(iOS 13, *) {
// use the shiny new one
} else {
// use the old one
}
I am going through a few Swift tutorials on how to build simple apps, as I am just starting to code. I want to make my app iOS 9 compatible, as I have an iPad 3. However, all the os.log statements generate an error in Xcode which tells me to add an if #avaliable statement before any of the os.log statements. What does os.log do, and if I need it, is there an issue using an if #avaliable statement for iOS 9 compatibility? If not, what is the equivalent code for iOS 9 to go in the else statement after the if #avaliable statement? Thanks.
From Apple's documentation:
Unified logging is available in iOS 10.0 and later, macOS 10.12 and
later, tvOS 10.0 and later, and watchOS 3.0 and later, and supersedes
ASL (Apple System Logger) and the Syslog APIs. Historically, log
messages were written to specific locations on disk, such as
/etc/system.log. The unified logging system stores messages in memory
and in a data store, rather than writing to text-based log files.
There is no iOS9 equivalent. You could use a third party logging tool like CocoaLumberjack, which is very popular.
As a concrete example of how to use this logging:
if #available(iOS 10.0, *) {
let bundleID:String = Bundle.main.bundleIdentifier ?? "unknown"
let oslog = OSLog(subsystem: bundleID, category: "Model")
os_log("%#", log: oslog, type: .info, message)
}