MFMailComposeViewController Unexpectedly Returns Nil When MFMailComposeViewController.canSendMail is False

Originator:paul
Number:rdar://28115437 Date Originated:9/1/16
Status:Open Resolved:
Product:iOS SDK Product Version:
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
When compiling with the iOS 10 SDK, and running on an iOS 10 device, calling MFMailComposeViewController() can return nil when MFMailComposeViewController.canSendMail is false, despite the fact that its initializer is not marked as failable.

Steps to Reproduce:
1. Start with a fresh simulator that has no mail accounts installed.
2. Write an app that initializes a MFMailComposeViewController, like this: MFMailComposeViewController().
3. Notice that the value returned by MFMailComposeViewController() is actually nil and could potentially cause a crash.

Expected Results:
There are two expected results:
a. MFMailComposeViewController() would never return nil (this was the behavior on iOS 9), or
b. MFMailComposeViewController() would be marked as failable, so Swift consumers would have to handle the optionality of the return value.

Actual Results:
MFMailComposeViewController() returns nil, despite not being marked as a failable initializer.

Version:
Xcode Version 8.0 beta 6 (8S201h)

Notes:


Configuration:
iPhone SE Simulator

Attachments:
'MFMailComposeViewControllerBug.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!