Getting error in IPCConnection.swift file- "Couldn’t communicate with a helper application" in System Extension Sample application

Hello,

I'm trying to launch the sample from NetworkExtension on MacOS- Catalina (version- 10.15.3).


In order to do that I downloaded the source code from- https://developer.apple.com/videos/play/wwdc2019/714/


And did the following steps-

  1. Using Xcode 11.3.1, I opened the project.
  2. I searched for com.example.apple-samplecode and replaced that with com.(companyName).(productName).
  3. I changed this bundle id to these files-
    1. SimpleFirewall.entitlements with- com.(companyName).(productName)
    2. Info.Plist (NEMachServiceName) with- com.(companyName).(productName).simpleFirewallExtension
    3. SimpleFirewallExtension.entitlements with- com.(companyName).(productName)
  4. I set the Bundle id for both the targets. One is com.(companyName).(productName) and another one is com.(companyName).(productName).simpleFirewallExtension. Respective Provisioning profile has been taken from the Provisioning Profile list.
  5. Did clean the app and built the app.
  6. Copied the application and pasted it to /Applications.
  7. I ran the app.
  8. Opened Console app to see the logs
  9. Getting Error in IPCConnection.swift file
    Function name-func register(withExtension bundle: Bundle, delegate: AppCommunication, completionHandler: @escaping(Bool) -> Void)
    Error-
    registerError.localizedDescription (Couldn’t communicate with a helper application.)


Can you please help me out on that.

TIA.

Replies

Hi,


did you check app.group entitlement? It's needed for IPC communication.

You need to set it for both, app and the extension, to the same value, eg. <TeamId>.com.(companyName).(productName)

When editing entitlements on Apple portal, you will see that it adds "group." into app group id and you cannot change it, so leave it as is and use "group.com.(companyName).(productName)". The group will be replaced in provisioning profile by team id.

Make sure in Xcode you have following entitlements enabled:

App target:

- Network Extension

- System Extension


System Extension target:

- Network Extension


Make sure NSMachServiceName com.(companyName).(productName).simpleFirewallExtension matches to bundle id of the system extension target.


There could be other potential issues. If you are sending data (objects) through a protocol function you wrote, it requires that all classes are derived from NSObject and implement NSSecureCoding protocol. If any property or referenced object anywhere in the hierarchy does not fulfill those criteria, you will receive precisely the error you described. Just today I had to write bunch of unit tests to verify encoding/decoding, because I was receiving "Couldn’t communicate with a helper application".

The problem is that app doesn't provide much info in Xcode debug view. You can also check Console app, where you will also see what system extension logs. You might find errors, like extension dropped connection and stack trace with decoding errors.


But there are many more potential problems. You may need to resolve them step by step.

Regards,

Robert