Problem about Image filter in swift

Hi,
I am testing the CIAreaMinimum filter in swift, for MacOS platform.

The problem I meet is: in run mode in Xcode, the code works fine. But when I open the app path and try to run it independently, the filter function will not work.

As the demo code show, if running in Xcode, after pressing the button, there will be a color block shown in interface. If build and independently execute the app, pressing the button will not trigger anything, no color block, no crash or any error popup.

Appreciate your help!

macOS: 10.15.6
Xcode: Version 12.2 (12B45b)

Code Block
struct ContentView: View {
    @ObservedObject var testvm = testVM()
    var body: some View {
        VStack{
            Button(
action: {testvm.ShowMinimun()},
label: { Text("Button")
            })
            Image(nsImage: testvm.origin.ToNSImage())
            Image(nsImage: testvm.result.ToNSImage()).scaleEffect(100)
        }
    }
}

Code Block
class testVM: ObservableObject {
    @Published var origin: CIImage = CIImage.init()
    @Published var result: CIImage = CIImage.init()
    init(){
        guard let url = Bundle.main.url(forResource:"eye", withExtension:"png") else {
          return
        }
        origin = CIImage(contentsOf: url)!
    }
    func ShowMinimun() {
        let filter = CIFilter(name: "CIAreaMinimum")!
        filter.setValue(origin, forKey: kCIInputImageKey)
        filter.setValue(origin.extent, forKey: kCIInputExtentKey)
        let filteredImage = filter.outputImage
        result =  filteredImage!
    }
}


I've opened the package and run directly from unix executable file. Log shows in terminal while pressing the button:
Code Block
2020-12-27 22:07:59.157 test2[5305:94032] -[NSConcreteValue CGRectValue]: unrecognized selector sent to instance 0x7f88452584e0


Problem has been solved. For key "kCIInputExtentKey", the value type should be CIVector, not CGRect.
However, still wondering why it works fine in run mode??
Problem about Image filter in swift
 
 
Q