iMessage extension runs old compiled code on device instead of new code in debug mode in Xcode

Why is it that when I change to code in MessagesViewController in an iMessage extension the old compiled code runs instead on my connected iPhone device?


I have tried to fix the problem by deleting the DerivedData folder in the Xcode folder on my Mac mini that runs Xcode. I have run Option + Product->Clean Build Folder in the Xcode menu. I have completely removed the containing app on the iPhone device, which also removes the iMessage extension. I have done all of those things combined, and it doesn't fix the problem.


This is the old compiled code that the device actually runs:

        guard let conversation = activeConversation else { fatalError("Expected a conversation") }
        
        // Create a new message with the same session as any currently selected message.
        let message = composeMessage(with: sticker, caption: "messageCaption", session: conversation.selectedMessage?.session)
        
        // Add the message to the conversation.
        conversation.insert(message) { error in
            if let error = error {
                print(error)
            }
        }


This is the new code that the device is supposed to run in debug mode in Xcode:

        guard let conversation = activeConversation else { fatalError("Expected a conversation") }
        
        conversation.insertText("Hello there!") {
            (error: Error?) in
            print("completionHandler insert(text:_:)")
        }

Replies

I have some insane caching issues with Message apps with images, but nothing like that where the actual code is being cached. That does seem a bit unlikely, but who knows. Have you tried changing the bundle ID so it installs a new app entirely instead of replacing the old?


Has anyone else seen the iMessage image cache? I have an animated PNG that just keeps showing from a couple versions ago in my app. I've replaced the app with new Test Flight builds, 2 new live versions, and this PNG just keeps showing. The image is no longer in the project, but one with the same name is.

(And yes, I've done Clean Build Folder a million times).

Its not a huge deal of course, but it'll confuse the heck out of you if you aren't expecting images to get cached. Can't help but feel it's related to Messages not actually deleting apps when they are toggled on and off. So back to your issue, I suppose anything is possible.