2

I want to create entity from dictionary using MR_ImportFromObject method. It worked before I update Xcode 6 to 7. But when I use Xcode7, ImportFromObject method is not working. Every call that method, willImport Delegate method is not called and application is crashed.

But ImportFromArray method is working very well.

Here is error message. I think the points are "swift_bridgeNonVerbatimFromObjectiveC" and "value type is not bridged to Objective-C".

libswiftCore.dylib`swift_bridgeNonVerbatimFromObjectiveC: 0x1060d4d50 <+0>: pushq %rbp 0x1060d4d51 <+1>: movq %rsp, %rbp 0x1060d4d54 <+4>: pushq %r15 0x1060d4d56 <+6>: pushq %r14 0x1060d4d58 <+8>: pushq %r12 0x1060d4d5a <+10>: pushq %rbx 0x1060d4d5b <+11>: movq %rdx, %r14 0x1060d4d5e <+14>: movq %rsi, %rbx 0x1060d4d61 <+17>: movq %rdi, %r15 0x1060d4d64 <+20>: leaq 0x54a15(%rip), %rsi ; _TMpSs21_ObjectiveCBridgeable 0x1060d4d6b <+27>: movq %rbx, %rdi 0x1060d4d6e <+30>: callq 0x1060d4610 ; swift_conformsToProtocol 0x1060d4d73 <+35>: movq %rax, %r12 0x1060d4d76 <+38>: testq %r12, %r12 0x1060d4d79 <+41>: je 0x1060d4dc9 ; <+121> 0x1060d4d7b <+43>: movq %rbx, %rdi 0x1060d4d7e <+46>: movq %rbx, %rsi 0x1060d4d81 <+49>: callq *0x8(%r12) 0x1060d4d86 <+54>: testb %al, %al 0x1060d4d88 <+56>: je 0x1060d4e49 ; <+249> 0x1060d4d8e <+62>: movq %rbx, %rdi 0x1060d4d91 <+65>: movq %rbx, %rsi 0x1060d4d94 <+68>: callq *0x10(%r12) 0x1060d4d99 <+73>: movq %r15, %rdi 0x1060d4d9c <+76>: movq %rax, %rsi 0x1060d4d9f <+79>: callq 0x1060d2100 ; swift_dynamicCastUnknownClass 0x1060d4da4 <+84>: testq %rax, %rax 0x1060d4da7 <+87>: je 0x1060d4e49 ; <+249> 0x1060d4dad <+93>: movq 0x20(%r12), %r8 0x1060d4db2 <+98>: movq %rax, %rdi 0x1060d4db5 <+101>: movq %r14, %rsi 0x1060d4db8 <+104>: movq %rbx, %rdx 0x1060d4dbb <+107>: movq %rbx, %rcx 0x1060d4dbe <+110>: popq %rbx 0x1060d4dbf <+111>: popq %r12 0x1060d4dc1 <+113>: popq %r14 0x1060d4dc3 <+115>: popq %r15 0x1060d4dc5 <+117>: popq %rbp 0x1060d4dc6 <+118>: jmpq *%r8 0x1060d4dc9 <+121>: movq (%rbx), %rcx 0x1060d4dcc <+124>: xorl %eax, %eax 0x1060d4dce <+126>: cmpq $0x80, %rcx 0x1060d4dd5 <+133>: cmovbeq %rcx, %rax 0x1060d4dd9 <+137>: cmpq $0xf, %rax 0x1060d4ddd <+141>: jne 0x1060d4df1 ; <+161> 0x1060d4ddf <+143>: testl $0x80ffffff, 0x10(%rbx) 0x1060d4de6 <+150>: jne 0x1060d4e49 ; <+249> 0x1060d4de8 <+152>: leaq 0x54959(%rip), %r12 ; protocol witness table for Swift._BridgeableMetatype : Swift._ObjectiveCBridgeable in Swift 0x1060d4def <+159>: jmp 0x1060d4d7b ; <+43> 0x1060d4df1 <+161>: cmpq $0xd, %rax 0x1060d4df5 <+165>: jne 0x1060d4e49 ; <+249> 0x1060d4df7 <+167>: movq 0x8(%rbx), %rax 0x1060d4dfb <+171>: movq (%rax), %rcx 0x1060d4dfe <+174>: xorl %eax, %eax 0x1060d4e00 <+176>: cmpq $0x80, %rcx 0x1060d4e07 <+183>: cmovbeq %rcx, %rax 0x1060d4e0b <+187>: leaq 0x54936(%rip), %r12 ; protocol witness table for Swift._BridgeableMetatype : Swift._ObjectiveCBridgeable in Swift 0x1060d4e12 <+194>: cmpq $0x3f, %rax 0x1060d4e16 <+198>: jg 0x1060d4e33 ; <+227> 0x1060d4e18 <+200>: cmpq $0xf, %rax 0x1060d4e1c <+204>: ja 0x1060d4d7b ; <+43> 0x1060d4e22 <+210>: movl $0xb706, %ecx 0x1060d4e27 <+215>: btq %rax, %rcx 0x1060d4e2b <+219>: jae 0x1060d4d7b ; <+43> 0x1060d4e31 <+225>: jmp 0x1060d4e49 ; <+249> 0x1060d4e33 <+227>: leaq -0x40(%rax), %rcx 0x1060d4e37 <+231>: cmpq $0x2, %rcx 0x1060d4e3b <+235>: jb 0x1060d4e49 ; <+249> 0x1060d4e3d <+237>: cmpq $0x80, %rax 0x1060d4e43 <+243>: jne 0x1060d4d7b ; <+43> 0x1060d4e49 <+249>: leaq 0x4467e(%rip), %rax ; "value type is not bridged to Objective-C" 0x1060d4e50 <+256>: movq %rax, 0x86561(%rip) ; gCRAnnotations + 8 0x1060d4e57 <+263>: int3
-> 0x1060d4e58 <+264>: nopl (%rax,%rax)

Hyeonjin Jang
  • 257
  • 1
  • 3
  • 11

2 Answers2

1

I changed the MagicalRecord MR_importFromObject Library for now from

id value = [objectData MR_valueForAttribute:primaryAttribute];

if (primaryAttribute != nil)
 {
      managedObject = [self MR_findFirstByAttribute:[primaryAttribute name] withValue:value inContext:context];
 }

to

 if (primaryAttribute != nil)
 {
   id value = [objectData MR_valueForAttribute:primaryAttribute];
            managedObject = [self MR_findFirstByAttribute:[primaryAttribute name] withValue:value inContext:context];
 }

You can probably put this in a category or extension (swift) on NSManagedObject and use that until MagicalRecord fixes this. That's what I'll do. This fixed this crash for me.

NickDK
  • 999
  • 10
  • 24
0

Try disabling the swift compiler optimizations. We had a similar crash unrelated to magical record that was fixed by changing that setting.

casademora
  • 67,775
  • 17
  • 69
  • 78