This worked for me, so just give it a try. i got this error while converting the code from swift 3 to swift 4.
Simply, go to Project>Target>Build Setting and search 'Swift Compiler - Code Generation' and set Optimization level to 'No Optimazation[-Onone]'.