The not so hidden cost of sharing code between iOS and Android
I have come to this same conclusion after many years. It&#x27;s not cost-effective to have any bespoke business logic (models, controllers, etc.) shared between the two mobile platforms (don&#x27;t get me started on sharing UI code). If you have some incredibly tricky low-level algorithm&#x2F;library and&#x2F;or need for speed, think database, crypto, intense graphics, etc., then fine, you may be able to swing a shared module in C++ or something. Other than that, it&#x27;s almost like the collective consciousnesses of Google and Apple conspire to make cost-effective code-sharing of typical CRUD apps almost impossible.<p>Here&#x27;s a fine alternative to code-sharing: well first and foremost you need to have a good requirements spec. After that, implement it on one platform first in a platform agnostic way. So heavy use of delegates&#x2F;interfaces&#x2F;injections to handle platform-specific functionality, even for one-liners like getting current system time. So the code should be pure, boring, plain old Java, Kotlin, Swift, whatever. Minimal use of fancy language features that may not port cleanly. After one platform has the module in place and well-tested, do a copy&#x2F;paste port to the other platform. You will find that the copy&#x2F;paste port will actually uncover bugs, optimizations, edge cases, etc., that can then be ported back to the original platform. Things you would not have found if you were only writing the code once. It&#x27;s like the most intense kind of PR code review you can get.<p>So I&#x27;ve found that copy&#x2F;paste-port-based code sharing between platforms is not just a lesser evil, but actually a strategy that has its own unique benefits. If you get into a groove you can build up a set of regexes to give you a sloppy transpiler that does most of the tedious porting for you.