dyld: Library not loaded: @rpath/libswiftAVFoundation.dylib Reason: image not found

When including a framework built with Swift in a non-Swift project, the Swift standard libraries need to be copied into the final output. Xcode has a checkbox for this (#4 in the original question), but apparently there's a bug where, in some cases, it doesn't actually happen.

I saw another thread somewhere that said this happens when you have a framework built with Swift, which is built for multiple architectures, such as armv7 and arm64. (See the thread here.)

In any case, the solution is to add them all manually. The files you are looking for are in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos.

What I did was this:

Step 1. Open Terminal and type this, copying the libraries to a new folder, swiftStdLib, in your home directory.

cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
mkdir ~/swiftStdLib
cp libswift*.dylib ~/swiftStdLib

Step 2. Within Xcode, go to General -> Embedded Binaries, and hit the + to add. Click Add Other, then navigate to your home folder/swiftStdLib. Select all and hit enter.

Step 3. Clean and build the project.

Hope this helps someone.

UPDATE FOR XCODE 11:

In Xcode 11.3, the Swift libraries folder has changed to include the major Swift version number. The original question was based on Xcode 9, so this probably changed earlier than Xcode 11.3, but I haven't checked.

The new folder is /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos.

So that makes Step 1, above, this instead:

cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos
mkdir ~/swiftStdLib
cp libswift*.dylib ~/swiftStdLib

Before adding frameworks try this:

I deleted derived data in xcode9 - it works for me

refer link below: How to delete contents from derived data

How can I delete derived data in Xcode 9?