AVSpeechSynthesisVoice crashing in iOS 16 beta - ios

On iOS 16 beta, the following code is crashing:
AVSpeechSynthesisVoice(language: "en-US")!
with the following error code:
Fatal error: Unexpectedly found nil while unwrapping an Optional value
It worked fine before and I'm not seeing any API change.
Does anyone know what could be going on?

I believe you are experiencing this in the simulator, but not on actual devices - correct? The reason is that for iOS 16, the devices in the Xcode simulator do not come with any built-in voices, whereas they always used to.
As a result, AVSpeechSynthesisVoice.speechVoices() returns [], and AVSpeechSynthesisVoice(language: "en-US") returns nil.
To solve this, simply download one or more voices to the simulated device you are compiling to. To do that, on the device go to Settings > Accessibility > Spoken Content > Voices > English, select a voice, and download it.

It seems like Apple missed to add voice libraries to iOS 16 betas. Below code returns nil.
AVSpeechSynthesisVoice.speechVoices()
Which should return the list of available voices. I filed a bug, you should also.

Related

Swift warning in Xcode 14 : Method confirm(intent:) conflicts with method confirm(intent:completion:) with the same Objective-C selector

Testing the new widget for iOS 16 with Xcode 14, I'm facing an issue trying to port the iOS 14 widget with the new WidgetFamily like .accessoryInline or .accessoryRectangular.
After adding conditional macros to solve some errors in order to build for watchOS and iOS (cf Apple WWDC 22 video: https://developer.apple.com/videos/play/wwdc2022/10050/), Xcode display no red errors but yellow blocking warnings:
Method 'confirm(intent:)' with Objective-C selector
'confirmConfiguration:completion:' conflicts with method
'confirm(intent:completion:)' with the same Objective-C selector; this
is an error in Swift 6
Any idea how to solve it?
EDITED : Finally works without fix that, see answer below. But I'm still interesting to remove this warning.
Finally, it passed without fixing this warning. I remove the last errors around the extension bundle name (has to be prefixed with the watch app bundle and follow by ".xxxxxx" of your choice without any further dot). I also had a "4" (Apple Watch) value to "Targeted Device Families" in build settings (was previously "1,2" for iPhone, iPad).

iOS 13 - FileManager url(forPublishingUbiquitousItemAt:expiration:) not working anymore

I've developed an iOS app that uses the url(forPublishingUbiquitousItemAt:expiration:) method of Apple's FileManager class. Starting with the first Beta of iOS 13 this function stopped working and now it throws an error, stating "This code has been removed. You should switch off of this SPI". But I can't find anything related to this function neither in the release notes of iOS nor in the documentation for this function, and it even states there that it would be supported on Mac Catalyst 13.0+.
This also has nothing to do with Xcode 10 and 11, as it occurs when the app is built using either one of those versions.
Does anyone of you know more about that? It would be great to get new information on that.
Thanks,
Fabian.
This is fixed in iOS 13 beta 6. Updated today and this error magically disappeared!
Had my mind blown when I saw this error message.

DispatchQueue.main.async availability iOS 10 works on prior iOS

After migration to new swift 3we've got a lot of automatic syntax changes among which:
DispatchQueue.main.async(execute: {
// Do something
})
documentation says that it's available in iOS 10 and later.
So I expected to see unrecognized selector error when running on iOS 8 but it still works.
So I'm just wondering if it would affect some users since our deployment target is iOS 8?
I just tested it on an iPod touch running 8.4 and DispatchQueue.main.async{} works just fine.
The docs are misleading (wrong?)
I went to log a documentation problem, but wait, among lots of other stuff that's been removed from the Xcodebuilt-in documentation system, you can't log issues with the docs anymore!
I suggest filing a radar bug, then.

What happens if I use LAPolicyDeviceOwnerAuthentication on iOS 8?

In my app, I would like to know if the user has setup a passcode or fingerprint (touchID). There's a pretty easy method just for that: [LAContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:error].
However, Apple's docs say LAPolicyDeviceOwnerAuthentication is only available on iOS9 and above. I would rather not crash iOS 8 users without explanation, even if it is getting older. The thing is, I've tried it on an iOS8.4 simulator, and it seems to compile and just work.
What ill effects can happen if I use LAPolicyDeviceOwnerAuthentication on iOS 8?
I use code similar to this:
LAPolicy localAuthPolicy = LAPolicyDeviceOwnerAuthenticationWithBiometrics;
if (![[UIDevice currentDevice].systemVersion hasPrefix:#"8."]) {
localAuthPolicy = LAPolicyDeviceOwnerAuthentication;
}
This ensures I only use LAPolicyDeviceOwnerAuthentication on iOS 9 and later.
It's undocumented what actually happens on an iOS 8 device when you attempt to use LAPolicyDeviceOwnerAuthentication. It's very unlikely anything will crash but the authentication may return NO due to an unknown value or it may succeed because iOS 8 only had one valid value and it may not do any checking.
Unfortunately Objective-C doesn't provide any runtime checks for valid enum values like you can do with constants, methods, and classes.
If you use LAPolicyDeviceOwnerAuthentication on anything below iOS 9, the app will crash. That is what happened to my app when I didn't realize that this was not available on anything below iOS 9, but my app supported iOS 8.x as its minimum supported OS version.

Running Metal and Swift on the iPhone 5s

Was really excited to find Warren Moore's sample project using Metal and Swift, but when I try to run it on my device (5s, 8.2, XCode 6.2), I get an error saying that the Info.plist [...] specifies device capability requirements, which are not met by Davis's iPhone.
As far as I can tell, the only relevant Keys in the plist are:
Required device capabilities: armv7, metal
Application requires iPhone environment: YES
I have to assume that armv7 means armv7 or later, in which case, the 5s should qualify. And anyway at WWDC they kept saying it would work on A7, which was introduced on the 5s.
What I've tried:
I removed the requirements (felt like a bad idea), after which I get fatal error: unexpectedly found nil while unwrapping an Optional value. A little digging around shows that MTLCreateSystemDefaultDevice() is returning nil.
This lead me to a similar question where the solution was to update iOS, but both Xcode and iOS are up to date.

Resources