问题
I've got an app that has a pro and free version, both are almost identical and I'd like to have as much common code as possible to avoid copy & paste issues when moving from one project to the next.
As far as I understand app stores recognize apps based on their package names but I understood that changing the package name of a completed app is difficult.
Is there a best practice for such a situation?
Currently the only thing I can think of is to try to move as much of the logic into a cn1lib file and have two separate apps. Other ideas/approaches would be appreciated.
回答1:
The cn1lib approach is definitely a good one but not always easy or practical.
An approach we offered to some developers is to create one version of the app as usual (free or pro) then add a new package name for the other version e.g. if your app is com.mycompany.myfreeapp
then you can add the package com.mycompany.myproversion
after the fact.
Your pro main class can derive the free main class and even have the same exact name (since they are in different packages) and so you can have one project with two versions.
To get this to actually work you will need two tricks, copy your codenameone_settings.properties
files and replace all mentions of the package (and main class if you changed that too) to the pro/free version. You will also need to replace the provisioning profiles for iOS (just re-run the wizard).
To run this in the debugger just edit the run section in the project preferences to point at the right main class.
You can codify this into a small script that does all of those things once you go thru this process.
来源:https://stackoverflow.com/questions/34627860/two-codename-one-projects-with-shared-code