Search code examples
iosswiftxcode

How to make stickers appear in iMessage extension using Xcode 15.1


I'm trying to write a very simple extension to display a sticker. None of Apple's sample code works on device or in simulator. I can't tell if it's a complete regression on Apple's part or something specific to my setup. The only error message that the console displays is:

Error creating the CFMessagePort needed to communicate with PPT.

I have used this sample code: creating a sticker app and have also tried the vanilla 'Sticker Pack App' at File > New > Project > Sticker Pack App. In both cases, iMessages shows an icon of my app in the extension list, but no images are displayed. I have tried using images of various sizes per the guidance here, but stickers still refuse to display.

Is a new entitlement/setting required by Apple that is not flipped on in the sample code or Xcode template?

I'm using Xcode 15.1 and iOS 17.2


Solution

  • There are two separate frustrating issues here.

    1. For sticker packs (File > New > Project > 'Sticker Pack App'), you must fill the full set of icons (in the project tree select 'Stickers' and then 'iMessage App Icon'). With unset icons, no images that you add to your sticker pack will display.

    2. For iMessage extensions, adding icons is not enough. Developing for iMessage extensions is really finicky. I have found it best to use the 16.4 simulator instead of latest (which today is 17.2). Add a simulator by going to Window > Devices and Simulators and tap the plus icon in the bottom left of the sidebar. Then, and this is crucially important, do not tap on either button in the modal that pops when you build and run the first time. The modal looks like this:

    If you tap on either of the buttons, then the next time you run your extension the UI won't load. I don't know why this is, some privacy flag getting flipped maybe. Swipe the modal down instead