In XCode 9.4.1, #fileLiteral is working well with .txt file, .pdf file while crashed with loading a .mlmodel
Below is the error msg:
Playground execution failed:
error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
* frame #0: 0x000000011fc1356e libswiftFoundation.dylib`Foundation.URL.init(fileReferenceLiteralResourceName: Swift.String) -> Foundation.URL + 206
frame #1: 0x000000012368f5c3 $__lldb_expr2`main at Image Detection.xcplaygroundpage:17
frame #2: 0x0000000109763600 CoreML`linkResources + 304
frame #3: 0x000000010aeff15c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
frame #4: 0x000000010aefe910 CoreFoundation`__CFRunLoopDoBlocks + 336
frame #5: 0x000000010aef9174 CoreFoundation`__CFRunLoopRun + 1284
frame #6: 0x000000010aef8931 CoreFoundation`CFRunLoopRunSpecific + 625
frame #7: 0x00000001124911b5 GraphicsServices`GSEventRunModal + 62
frame #8: 0x000000010ebd72ce UIKitCore`UIApplicationMain + 140
frame #9: 0x00000001097636cd CoreML`main + 205
frame #10: 0x000000010c912c9d libdyld.dylib`start + 1
frame #11: 0x000000010c912c9d libdyld.dylib`start + 1
The same code is running well with iPad Playground.
If rename the .mlmodel to .model, then the loading can be successful.
But another error occured:
Playground execution terminated: An error was thrown and was not caught:
Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “MobileNetml.model” in the folder “76A50A4E-22A7-4079-A58C-736B5D79E0B8”." UserInfo={NSURL=file:///var/folders/ln/lm0p4h5x1dl1qgqwmnnb2hxr0000gn/T/com.apple.dt.Xcode.pg/resources/76A50A4E-22A7-4079-A58C-736B5D79E0B8/MobileNetml.model, NSUnderlyingError=0x60000287f660 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
The same source code is running well in iPad Playground.
How to fix this in XCode? Thanks.