Firstly let me preface this by saying I am using Swift 2.0 and XCode 7.
I’m having trouble with getting the drag image working. In the following function in DieView
override func mouseDragged(theEvent: NSEvent)
The block below causes a compile time error. There are no errors shown in the source error.
item.imageComponentsProvider = {
let component = NSDraggingImageComponent(key: NSDraggingImageComponentIconKey)
component.contents = image
component.frame = NSRect(origin: NSPoint(), size: imageSize)
return [component]
}
When compiling Xcode reports “Command failed due to signal: Illegal instruction: 4”. The detail of the error is beyond my comprehension (and is mostly using Objective-C syntax) but I think it is complaining about the return type of the block. I have tried making the return type optional and using optional chaining to build the component, but it always ends up with either Source Editor errors or the same compile time error.
Here is the detail of the compile time error:
SIL verification failed: type of apply instruction doesn’t match function result type: AI->getType() == substTy->getResult().getSILType()
Verifying instruction:
%4 = apply %2() : @callee_owned () -> @owned Array<NSDraggingImageComponent> // user: %6
// function_ref Foundation._convertArrayToNSArray <A> (Swift.Array<A>) -> ObjectiveC.NSArray
%5 = function_ref @_TF10Foundation22_convertArrayToNSArrayurFGSaq__CSo7NSArray : @convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned NSArray // user: %6
-> %6 = apply %5(%4) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned NSArray // user: %7
autorelease_return %6 : Optional<NSArray> // id: %7
In function:
// reabstraction thunk helper from @callee_owned () -> (@owned Swift.Array<ObjectiveC.NSDraggingImageComponent>) to @callee_unowned @convention(block) () -> (@autoreleased Swift.Optional<ObjectiveC.NSArray>)
sil shared [transparent] [reabstraction_thunk] @_TTRXFo__oGSaCSo24NSDraggingImageComponent__XFdCb__aGSqCSo7NSArray__ : @convention© (@inout @block_storage @callee_owned () -> @owned Array) -> @autoreleased Optional {
bb0(%0 : *@block_storage @callee_owned () -> @owned Array<NSDraggingImageComponent>):
%1 = project_block_storage %0 : *@block_storage @callee_owned () -> @owned Array // user: %2
%2 = load %1 : *@callee_owned () -> @owned Array<NSDraggingImageComponent> // users: %3, %4
strong_retain %2 : @callee_owned () -> @owned Array // id: %3
%4 = apply %2() : @callee_owned () -> @owned Array<NSDraggingImageComponent> // user: %6
// function_ref Foundation._convertArrayToNSArray <A> (Swift.Array<A>) -> ObjectiveC.NSArray
%5 = function_ref @_TF10Foundation22_convertArrayToNSArrayurFGSaq__CSo7NSArray : @convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned NSArray // user: %6
%6 = apply %5(%4) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned NSArray // user: %7
autorelease_return %6 : $Optional // id: %7
}
If I comment out the above lines I can compile and run without error but have no drag image.
Has anyone else had the same issue and overcome it? Or can suggest a solution.