Xcode will build a project on a simulator but not on a device


I'm trying to build a project, it can build fine on the simulator but not on the device. I'm getting this error

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /private/var/mobile/Containers/Bundle/Application/1EF56754-F072-4113-9AC6-9728A685E1AF/testapp3.app/testapp3
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Containers/Bundle/Application/1EF56754-F072-4113-9AC6-9728A685E1AF/testapp3.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x100104000, size=0x0015C000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/1EF56754-F072-4113-9AC6-9728A685E1AF/testapp3.app/Frameworks/libswiftCore.dylib

I have tried deleting the certificate and profile, restarted xcode, cleaned project, changed embed swift to YES. I do have @executable_path/Frameworks in my search paths. None of that worked.

I have no frameworks in my project but I can't even get a default single app to launch on my iPhone 6 plus. Yes everything is up to date, xCode is up to date, and my iPhone is up to date.

What could be causing this problem?

This took me a while to find but I had the same issue and solved it this way.

Download and install WWDR(Apple Worldwide Developer Relations Certification Authority) and try again.