I ran into the same issue but the accepted solution did not work for me. Instead the solution was to modify the framework's install name.
The error in the original post is:
dyld: Library not loaded: /Library/Frameworks/TestMacFramework.framework/Versions/A/TestMacFramework Referenced from: /Users/samharman/Library/Developer/Xcode/DerivedData/TestMacContainer-dzabuelobzfknafuhmgooqhqrgzl/Build/Products/Debug/TestMacContainer.app/Contents/MacOS/TestMacContainer Reason: image not found
Note the first path after Library not loaded. The framework is being loaded from an absolute path. This path comes from the framework's install name (sometimes called rpath), which can be examined using:
otool -D MyFramework.framework/MyFramework
When a framework is embedded into an app this path should be relative and of this form: @rpath/MyFramework.framework/MyFramework. If your framework's install name is an absolute path it may not be loaded at runtime and an error similar to the one above will be produced.
The solution is to modify the install name:
install_name_tool -id "@rpath/MyFramework.framework/MyFramework" MyFramework.framework/MyFramework
With this change I no longer get the error