3

I have been so frustrated for so long with this problem. My code was working just fine and then I took a break from the program for winter break. When I came back to it, whenever I tried to switch from the default keyboard to my custom keyboard, I got two error messages: "Connection to plugin interrupted while in use" and "Connection to plugin invalidated while in use"

After scouring the internet and trying one thing after the next to no avail, I resorted to commenting out code to see if a certain part was causing the problem and it was. I have a section that loops through a list of objects that have names that correspond to the exact name of the image files I want to use in my keyboard and the loop adds those images to the keyboard.

let emojisLocal = emojiStore.emojis

var xPos = 10
var yPos = 10
var count = 0;

for emoji in emojisLocal
{
     if (count >= 5)
     {
          yPos += 70
     }

     let button = UIButton(type: UIButton.ButtonType.system) as UIButton
     button.frame = CGRect(x: xPos, y: yPos, width: 40, height: 49)
     if let image = UIImage(named: emoji.name)
     {
          button.setBackgroundImage(image, for: .normal)
     }
     button.backgroundColor = .white
     view.addSubview(button)
     count += 1
     xPos += 50
}

I just don't understand because this code was working just fine not even a month ago and all of a sudden it just has stopped working. I even tried creating a new project and transferring all the code onto the new project and that gave the same errors. It's possible that I updated to Xcode version 13.1 between when it was working and when it stopped working, but I can't remember, could that be the problem? I know for sure that there is one item in the list when the program starts and that the name is correct.

Here's the code for the EmojiStore:

import Combine

class EmojiStore: ObservableObject
{
    @Published var emojis : [EmojiListItem]
    
    init (emojis: [EmojiListItem])
    {
        self.emojis = emojis
    }
}

and for the EmojiListItem:

import Foundation

struct EmojiListItem : Codable, Identifiable
{
    var id = UUID().uuidString
    public var name : String
}

My post is similar to this one Plugin interrupted, invalidated errors for custom keyboard but the solution suggested on that post will not work for my program as I am not using UINibs.

Skwishyat
  • 31
  • 3

0 Answers0