iMessage extension crash in simulator

I've done a simple swift iMessage Extension but the simulator crashes when I change user


Steps to Reproduce:

Run the extension, click on button "Send Hello" when you are in Kate in the simulator. It sends "Hello", click on back to go to "John Appleseed" conversation


Expected Results:

Possibility to open the extension and click Send Hello


Actual Results:

Crash of iMessage


The extension has only a button "Send Hello"


===


import UIKit

import Messages


class MessagesViewController: MSMessagesAppViewController {

public var actualConversation : MSConversation?

override func viewDidLoad() {

super.viewDidLoad()

// Do any additional setup after loading the view.

}

// MARK: - Conversation Handling

override func willBecomeActive(with conversation: MSConversation) {

// Called when the extension is about to move from the inactive to active state.

// This will happen when the extension is about to present UI.

// Use this method to configure the extension and restore previously stored state.

actualConversation = conversation;

}

override func didResignActive(with conversation: MSConversation) {

// Called when the extension is about to move from the active to inactive state.

// This will happen when the user dissmises the extension, changes to a different

// conversation or quits Messages.

// Use this method to release shared resources, save user data, invalidate timers,

// and store enough state information to restore your extension to its current state

// in case it is terminated later.

}


override func didReceive(_ message: MSMessage, conversation: MSConversation) {

// Called when a message arrives that was generated by another instance of this

// extension on a remote device.

// Use this method to trigger UI updates in response to the message.

}

override func didStartSending(_ message: MSMessage, conversation: MSConversation) {

// Called when the user taps the send button.

}

override func didCancelSending(_ message: MSMessage, conversation: MSConversation) {

// Called when the user deletes the message without sending it.

// Use this to clean up state related to the deleted message.

}

override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {

// Called before the extension transitions to a new presentation style.

// Use this method to prepare for the change in presentation style.

}

override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {

// Called after the extension transitions to a new presentation style.

// Use this method to finalize any behaviors associated with the change in presentation style.

}


@IBAction func resetKey(_ sender: Any) {

let message = composeMessage(with: "Hello" , type: "", caption: "", session: nil, image: nil)

actualConversation?.send(message) { error in

if let error = error {

print(error)

}

}

}


func composeMessage(with msg: String, type: String, caption: String, session: MSSession? = nil, image: UIImage? = nil) -> MSMessage {

var components = URLComponents()

let comp1 = URLQueryItem(name: "msg", value: msg)

let comp2 = URLQueryItem(name: "type", value: type)

let comp3 = URLQueryItem(name: "caption", value: caption)

components.queryItems = [comp1, comp2, comp3]

let layout = MSMessageTemplateLayout()

layout.caption = msg

layout.image = image

let message = MSMessage(session: session ?? MSSession())

message.url = components.url!

message.layout = layout

return message

}

}

I have this problem too! It’s made the simulator next to useless for testing messages apps or creating App Store screenshots. Did you ever find a solution or file a radar? I searched all over and never found anything to solve it.

I've been working on a rich iMessage app for over a year.

Give up on testing in the simulator - it crashes reliably in every XCode version with iMessage when you call dismiss()


Note that there is also a bug with XCode if you have the permission keys allowing you access to the camera - that causes crashes trying to debug your app even on device.


I have a few very tiny samples on github testing different aspects of the iMessage SDK which may help folks.

I have the same exact problem. Please let me know if you found a solution!

I am facing same issue. It has become incredibly difficult to test message exchange between two users on iMessage extension. It has been an year and there is no solution still... I hope they come up with solution in iOS 14 😟

iMessage extension crash in simulator
 
 
Q