Moses Harding
Moses Harding

Reputation: 165

MailCore 2 works on simulator but not on device

I am able to use just about every feature of MailCore 2 successfully when I run it on a simulator, but every time I run it on a device it fails. It doesn't give me an error, it just stop on a thread with the message "EXC_BREAKPOINT (code=1, subcode=0x21cc8b374)". I know the thread has the message :Queue : shared_tcpConnWorkQueue (serial)." I don't really understand what this means other than the fact that clearly, this function is running on that thread and every time it runs it crashes.

I just don't understand why it would work on a simulator and not a device. The below code can be pasted into the ViewController file of an XCode project with MailCore added, and once a username and password are added, should work properly.

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        getEmailText()
    }
    
    func getEmailText() {
        print(#function)
        
        let username = "EMAIL ADDRESS"
        let password = "PASSWORD"
        
        let folder = "INBOX"
        let session = MCOIMAPSession()
        
        session.hostname       = "imap.gmail.com"
        session.port           = 993
        session.username       = username
        session.password       = password
        session.connectionType = .TLS
        session.isVoIPEnabled = true
        
        let uids = MCOIndexSet(range: MCORange(location: 1, length: UInt64.max))
        
        if let fetchOperation = session.fetchMessagesOperation(withFolder: folder, requestKind: .headers, uids: uids) {
            fetchOperation.start { error, fetchedMessages, vanishedMessages in
                print("Messages retrieved")
                if let error = error {
                    print("Error downloading message headers: \(error.localizedDescription)")
                } else if let messages = fetchedMessages {
                    for messageId in messages {
                        print(messageId)
                    }
                }
            }
        }
    }
}

Upvotes: 1

Views: 164

Answers (1)

Drewes
Drewes

Reputation: 2707

Try to add:

        session.isVoIPEnabled = false

Upvotes: 0

Related Questions