Search code examples
iosswiftmessageios-app-extension

Breakpoint not getting hit, nor the Message extension is getting attached in iOS


I am writing a SMS filter extension for iOS. I created a MessageFilterExtension. The extension code is

import IdentityLookup

final class MessageFilterExtension: ILMessageFilterExtension {
    var words: [String] = ["deal", "spam", "offer"]
    override init() {
        print("message filter init")
    }
}

extension MessageFilterExtension: ILMessageFilterQueryHandling {

    func handle(_ queryRequest: ILMessageFilterQueryRequest, context: ILMessageFilterExtensionContext, completion: @escaping (ILMessageFilterQueryResponse) -> Void) {
    //...
}

I had set breakpoints in the container app did launch, in the appex handle and other methods. The appex does not call remote services. Then I choose the appex target, clicked run, in the attach list chose the container app as the likely target which was already mentioned. It then shows "Waiting to attach". Then I choose container app and hit run, it build and runs, and hits the breakpoint. However, the appex is not getting attached or launched. I then send some SMS texts, but it does not filter. No print statements in Xcode or Console.app. I have enabled message filter and set the Container app to filter SMS.

I am testing this on iPhone 7 Plus and iOS 12.1.4. Tested on previous release of iOS, but still did not work.

Methods I tried so far:

How To Debug iOS Appex
Messages App Extension won't hit breakpoints

I do not have the contact name saved. (With some combination, it worked once, but I now I am not able to debug). How do debug message filter extensions?


Solution

  • We can debug an extension by running the extension alone from the Xcode schema menu. In this case the breakpoint will be hit. When running with the main app, the extension breakpoints will not be hit. In general app extension programming seems to work that way.