SPM command line app with CoreImage

I'm creating a command line tool using the Swift package manager and having trouble with CoreImage. When I build, I get the following error:

Undefined symbols for architecture x86_64:
   "_OBJC_CLASS_$_CIImage", referenced from:
        objc-class-ref in Image.swift.o
ld: symbol(s) not found for architecture x86_64

However, it looks like it can find CoreImage, it's there in the module cache with other system libraries I am using.

% find . -name "CoreImage*"

Any ideas how to proceed? I like the ability to set up the tool code as a "framework" which gets automatically embedded in the command line tool and allows much easier unit testing.

A regular Xcode project does build if I add CoreImage to the target's frameworks, but it also creates my internal framework and ArgumentParser as separate frameworks which is awkward.

You can't link to CoreImage when using swift build. You need to build with xcodebuild to load in the SDK

Ok. I had created an Xcode project using swift package generate-xcodeproj and added CoreImage as a dependency and got the tests to run. When archiving the tool it created standalone frameworks instead of embedding them. I guess there's probably a way to statically embed them, but I didn't go any further down that path yet.

One problem I ran into is that when the tests ran against the CoreImage code, it spent around a second compiling Metal filters. It did this every time the tests ran. Does anyone know if the release-built command line tool will need to do this every time it runs? I was considering making a mini server for other reasons but this may force the issue.

Terms of Service

Privacy Policy

Cookie Policy