How to use frameworks with the same name for different scheme

So I have 2 schemes: prod and staging. And both have their own Debug and Release configuration settings (one of which is the bundle ID, eg. prod-Release: com.mycomp.myApp, prod-Debug: com.myComp.myApp.debug, staging-Release: com.myComp.myApp.staging.debug, staging-Debug: com.myComp.myApp.staging.debug).

Now, there is a framework that is bound to each bundle ID. The framework is not from a So I need 4 instances of the same framework for each bundle ID. I tried separating the frameworks into folders and just link them whenever I need to run the appropriate scheme. Basically like so:

\{PROJECT_ROOT}\Frameworks\MyFramework\prod-Debug\MyFramework.xcframework \{PROJECT_ROOT}\Frameworks\MyFramework\prod-Release\MyFramework.xcframework \{PROJECT_ROOT}\Frameworks\MyFramework\staging-Debug\MyFramework.xcframework \{PROJECT_ROOT}\Frameworks\MyFramework\staging-Release\MyFramework.xcframework

I've added a Run script to create the link before Compile Sources step like so:

cd "${SRCROOT}/zDefend"
if [ "${CONFIGURATION}" = "prod-Debug" ]; then
    rm -rf ./MyFramework.xcframework
    ln -s ./prod-Debug/MyFramework.xcframework MyFramework.xcframework
elif [ "${CONFIGURATION}" = "prod-Release" ]; then
    rm -rf ./MyFramework.xcframework
    ln -s ./prod-Release/MyFramework.xcframework/ MyFramework.xcframework
elif [ "${CONFIGURATION}" = "staging-Debug" ]; then
    rm -rf ./MyFramework.xcframework
    ln -s ./staging-Debug/MyFramework.xcframework MyFramework.xcframework
elif [ "${CONFIGURATION}" = "staging-Release" ]; then
    rm -rf ./MyFramework.xcframework
    ln -s ./staging-Release/MyFramework.xcframework/ MyFramework.xcframework
fi

I only have 1 target, myApp. But in the Build Settings, I set it so that every configurations will create 4 different binaries with 4 different bundle ID like I've mentioned above. I've added the framework by its link and set it to "Embed and Sign".

The framework itself is not from Cocoapods, Carthage or SwiftPM. We just need to compile it ourselves into 4 and bind them with their own bundle ID in the code. Then we manually added them into the project. It will throw error if the app's bundle ID is not the same with the bundle ID bound to the framework.

This can be compiled just fine. But when in created 2 or more binaries in the simulator, it crashes. So this is possibly a linking issue. How do I solve this?

Thank you.

How to use frameworks with the same name for different scheme
 
 
Q