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)
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! } }