You posit that A writes code and publishes it, then B takes it, makes copyrightable modifications to it, and republishes the resulting work. You ask what the copyright position in this resulting work is, and whether such activity is lawful.
The result would indeed be copyrighted, as the Berne Convention requires, but the rights would vest in more than one entity. Both A and B now have a copyright interest in the resulting work.
Making a derivative work, as B has done in this case, is an activity normally controlled by copyright. Whether B's activity is lawful depends on the licence under which A made their work available. If A made it available under a permissive free licence (such as the three-clause BSD), then A has granted permission for such derivative works to be made and published. If A made it available under a copyleft free licence (such as GPLv3) then A has granted permission for derivative works to be made and published, subject to B observing certain conditions (including but not limited to publication of source, and relicensing under GPLv3) which B's failure to observe would invalidate, rendering B's activity a violation of A's copyright. If A didn't publish under a licence that permitted derivative works (such as most proprietary licences) then B is violating A's copyright.
We cannot tell from the information you have provided what Apple's licence on the original work was, so we cannot say which scenario applies here.