Xcode 12.5 dyld issue with binary frameworks

I have a binary Swift xcframework which references two other open-source Swift frameworks (built from source).

My framework along with its dependencies are built with the BUILD_LIBRARY_FOR_DISTRIBUTION option enabled (in order to support module stability).

This setup has worked fine for many years, but now when building my framework in Xcode 12.5 or above, I'm getting the following dyld error when an app using the framework is compiled in Xcode <12.5:

dyld: Symbol not found: __ZN5swift34swift50override_conformsToProtocolEPKNS_14TargetMetadataINS_9InProcessEEEPKNS_24TargetProtocolDescriptorIS1_EEPFPKNS_18TargetWitnessTableIS1_EES4_S8_E

I do not seem to be the only one experiencing this problem. A look on Github provides a number of other frameworks experiencing the same issue in Xcode 12.5.

It is suggested here that this issue is being caused by the following warning apparently now causing this fatal error:

Using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead

I note that the affected dependency involved in my case (Starscream) has not yet changed the class keyword to AnyObject, however I have not (yet) verified this is definitely the cause.

Unfortunately there is very little documentation out there about this issue, but it seems like it could potentially be quite widespread and increasing in prevalence as people upgrade to Xcode 12.5+, and more binary frameworks are built against this new version.

Does anyone have any ideas about how this can be resolved/mitigated, other than downgrading to Xcode 12.4?

In my case, in Podfile I have code that replaces IPHONEOS_DEPLOYMENT_TARGET for all pod targets with 'some' min version. Originally I had a '13.0' version. When I changed '13.0' to '9.0', did pod update , clean the project, and build & run again, the error didn't appear again.

Below is a piece of that code I have now:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']) < Gem::Version.new('9.0')
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
      end
    end
  end
end

Hope my answer will help somebody and save time.