3

I'm trying to create an application that uses a system extension (NEFilterPacketProvider to be exact). Currently I'm using CocoaPods to manage my dependencies. Everything works fine, up until the point when I try to use a framework inside my system extension.

I have created a private pod spec that is being depended on by the system extension target. The build itself is fine. The problem comes after I try to install and run my system extension. It fails to start, because the framework cannot be found.

After some investigation, it turns out that the framework is not included as part of system extension, but rather copied inside the main application bundle. System extension target simply references the relative framework directory of the application, as part of runtime framework search paths. This is problematic, because system extension is copied to /Library/SystemExtension/* after installation. Because the search path is relative, it no longer works, since extension has been copied outside the application.

After doing some Googling, it seems that the "way" of CocoaPods is to keep all of the frameworks inside application bundle. Ideally, I would like to have CocoaPods copy the framework into my system extension bundle. This would ensure that the system extension can operate as a standalone binary, without having to depend on application being present at a hardcoded path.

I'm wondering if there are any better solutions than just adding /Application/XXX.app/Contents/Frameworks to runtime framework search paths, and telling the user that the extension won't work otherwise.

Kristupas A.
  • 304
  • 5
  • 15
  • Did you find a way to fix it? – munibsiddiqui Mar 08 '21 at 05:58
  • Sadly no. There doesn't seem to be a built in functionality to do this. In the end it turned out my software doesn't need a system extension, so I didn't bother to find a solution to this problem. I think the easiest solution is to hardcode framework search path to /Applications/YourApp.app/Contents/Framework, since its where the app will probably be installed. Or you can try to make a script in Xcode that will copy the file to an appropriate location during build. – Kristupas A. Mar 09 '21 at 07:08
  • Ya right, I end up embedding the frameworks in my system extensions manually. – munibsiddiqui Mar 09 '21 at 07:41

0 Answers0