Interestingly, if you accept that code can be copyrighted, and that only things that are expressions (speech) are eligible for copyright ("A copyrighted work must be an original work of authorship which is fixed in a tangible medium of expression"), then code == speech.
So, by compelling Apple to code something that doesn't exist, the government would indeed actually be compelling speech.