Ah, but if you don't care about setting a public example, you can punish them in more subtle ways.
The traditional trick in corrupt countries is to have a bunch rules that aren't enforced and everyone breaks all the time - then if the leaders decide they don't like you they just start enforcing the rules on you.
A corrupt regime would simply announce they were shocked - shocked! - to find parts of Apple's Chinese supply chain had low environmental standards.
Keep in mind there's a legal mandate for public traded companies to increase share holders value. It's grey-ish legal requirement but I don't think the executive management wants to risk the legal consequences of doing the right thing.
Edit: it's shareholders and not stakeholders that matter.
What are the legal consequences? I keep reading about these mysterious laws that require management to maximize shareholder value or profits or whatnot, but I’ve never heard of a court punishing management for not doing so (never mind the fact that it’s impossible to define and prove per legal standards).
If you mean that the shareholders would rather please the Chinese government, rather than risk getting kicked out of China, then yes, I think Apple would go a long way to not piss off China.
Apple is also one of the few companies who can either absorb the additional cost or even pass it on to customers.
But IF Apple was to move manufactoring it would set a dangerous precedence for other companies and potentially start a supply chain completely outside China.