Not too long ago, when Western CEOs pondered China’s fast-growing market and billion-plus potential customers, their eyes would fill with dollar signs. But these days, thoughts of China are more likely to elicit serious soul-searching, as some of the companies that eagerly dove into China have withdrawn.

Earlier this year, the car-hailing service Uber surrendered its China operations to arch competitor Didi Chuxing in exchange for a 17.7 percent stake in the combined company. Later this month, Yum Brands, the owner of KFC and Pizza Hut, plans to spin off its China unit amid growing competition in the food delivery business. Even Coca-Cola has announced its intention to refranchise its company-owned bottling operations in China.

Was the China dream just a mirage with Beijing simply using foreign ventures to import Western technologies and skills? Or is there a way to make money in the People’s Republic of China without giving away the store?

While finding success in the People’s Republic can be tricky, several Western companies have prospered – and even some of the companies that have “retreated” in recent years have profited handsomely from their China operations.