Is there a way to do fair exchange between two parties who don't trust each other? Let's suppose we have an Alice who knows a secret key A, and Bob who knows key B. Using their own keys, they each encrypt a message (Alice encrypts $m_A$, Bob encrypts $m_B$) with their own key, and send the encrypted messages to one another.

Now is there some cryptographic scheme thinkable that lets Alice only decrypt her message (using key B) when Bob is able to decrypt his (via key A)? To guarantee that Alice will tell Bob her key after Bob told his?

The simplest solution would be a third-party which releases both keys at exactly the same time, but maybe there is also a cryptographic way to do this?
I think what you want to look at is "fair exchange".  There's a giant catalog of protocols for fair exchange.  They've been designed for doing exactly what (I think) you want.

See, e.g.,


https://en.wikipedia.org/wiki/Multi_party_fair_exchange_protocol
Alice trusts Bob only when Bob trusts Alice


Some fair exchange protocols require a third party who Alice and Bob trust, and involve the third party in the protocol.  Others (called optimistic fair exchange) require that there be a trusted third party, but normally the third party does not have to be involved in any way -- the third party only gets involved to settle disputes, if something goes wrong.  Still others try to avoid any third party (e.g., gradual fair exchange); they're not perfect, but they try to ensure that if Alice can learn Bob's message with some amount of effort, then Bob can learn Alice's messages with not too much more effort.

To learn more about fair exchange, do a literature search on fair exchange.  There are lots of research papers on this topic.