Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Is Image rendering allowed inside ActivityReportExtension

Versions

  • XCode version: 16.2
  • iOS version: 17.0

Background

I am trying to generate a QR code inside the ActivityReportExtention which encoded the FamilyActivitySelection information. The code is roughly:

Question

  1. Can I create Image inside the ActivityReportExtension? I cannot even render a simple image (not QR code) inside the extension.
  2. How can I debug inside the extension? Logs of the extension are not shown in the console.

Code

A function to generate QR Code

import CoreImage
import UIKit

func generateQRCode(from string: String) -> UIImage? {
    let data = string.data(using: .ascii)
    guard let filter = CIFilter(name: "CIQRCodeGenerator") else { return nil }
    filter.setValue(data, forKey: "inputMessage")
    filter.setValue("Q", forKey: "inputCorrectionLevel") // Q for medium quality

    guard let outputImage = filter.outputImage else { return nil }

    // Scale the QR code image so it looks clear on screen
    let transform = CGAffineTransform(scaleX: 10, y: 10)
    let scaledImage = outputImage.transformed(by: transform)

    // Create a CIContext and generate a CGImage from the CIImage
    let context = CIContext()
    if let cgImage = context.createCGImage(scaledImage, from: scaledImage.extent) {
        return UIImage(cgImage: cgImage)
    } else {
        return nil
    }
}

Inside ActivityReportExtension sandbox:

struct LineChartView: View {
    var body: some View {
        VStack {
            if let qrImage = generateQRCode2(from: "this is a test") {
                Image(uiImage: qrImage)
                    .resizable()
                    .scaledToFit()
                    .frame(width: 200, height: 200)
            } else {
                Text("QR Code generation failed")
            }
        }
    }
}

Case-ID: 12079215

Sorry some updates: I can render simple image in the extension:

Image(systemName: "photo")
                .resizable()
                .scaledToFit()
                .frame(width: 200, height: 200)
                .foregroundColor(.blue)

but still failed to render a QR Code.

Can CoreImage be used in the ActivityReportExtension?

I have conducted a lot of experiments and found that the problem is

let context = CIContext()

The function failed to run until this line in ActivityReportExtension.

For debugging app extensions:

Use Console.app to monitor to the relevant processes related to your app and extensions.

A good way to start would be with filtering by the BundleID of the target and / or the target name itself (the process name).

Also be sure to check the system processes for additional information. This will vary based on what and where you are looking but some examples:
To debug APNS you'll want to monitor apd along with other relevant processes.
To debug WidgetKit, LiveActivities, Dynamic Island you'll want to monitor springboardd, liveactivitiesd along with other relevant processes.

Is Image rendering allowed inside ActivityReportExtension
 
 
Q