As of ionic v1.0.0-beta.12, you can create a project with a unique project name as well as a unique package name.
Follow the steps below:
Step 1. First, update your ionic CLI.
$ npm update -g ionic
Step 2. On the ionic command line, provide an app name (Project Name) and an id (Package Name) as command line parameters.
Example:
$ ionic start HelloWorld tabs --appname "Hello World" --id 'com.mycompany.helloworld'
(NOTE: For the --appname, use " " (double quotes) to be able to use a space between words.)
========== The article below is obsolete as of ionic v1.0.0-beta.12 =======
The beta 1.0.0-beta.9 ionic creates a new project with a default project name āHelloCordovaā and a default Java package name ācom.ionicframework.starterā.
Here is a step-by-step instruction on how to replace the default project name with your own project name and your own package name on Windows.
It also shows you how to import the newly created ionic project into Eclipse, so you can further work on the ionic project using Eclipse.
STEP 1. Start Git-Bash command window.
STEP 2. In Git-Bash command window:
(1) Go to the Eclipse-workspace root directory.
(ex) $cd /c/Eclipse-workspace-PhoneGap
$ pwd
$/c/Eclipse-workspace-PhoneGap
STEP 3. Create an ionic project on the Eclipse workspace root directory
Format: $ionic start projectName [template]
Examples
$ionic start NewBlankApp blank (for no template)
$ionic start TestTabs tabs (for tabs template)
$ionic start TestSideMenu sidemenu (for sidemenu template)
STEP 3.1 ------------ Possible errors I can get at this step ------------------------------
(1) Problem Description
When I create a new ionic project,
I can get the following error message.
Fetching plugin āhttps://github.com/driftyco/ionic-plugins-keyboardā via git clone
^^^^^^^^^^^^^^^^
Error: Command failed: fatal: could not create work tree dir āC:\Users\Home\AppData\Local\Temp\plugman\git\1405247576143ā.: No such file or directory
at ChildProcess.exithandler (child_process.js:647:15)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Socket. (child_process.js:968:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
ERROR: Unable to add plugins. Perhaps your version of Cordova is too old.
^^^^^^^^^^^^^^^^^^^
Try updating (npm install -g cordova), removing this project folder, and trying again.
(2) SOLUTION
The error message says there is no directory āC:\Users\Home\AppData\Local\Temp\plugman\git\1405247576143ā.
All I need to do is to create āplugmanā and āgitā sub-folders under āC:\Users\Home\AppData\Local\Tempā manually and make sure they are not read-only.
STEP 4. cd ./projectName
Example:
$cd ./MyProject
STEP 5. Make a project name and a Java package name unique.
Change the project name and package name in the ~/MyProject/config.xml file:
(1) Change the project name from the default āHelloCordovaā to a unique project name such as āMyProjectā
(2) In ~/MyProject/config.xml file,
Change the default Java package name to a unique Java package name as shown below:
"<widget id="com.ionicframework.starter" " -> <widget id="com.unique.package-name"
(3) If I want to change the app version number, in ~/MyProject/config.xml file,
change version=ā0.0.1ā -> to version=ā0.0.2ā (in tag)
STEP 6. Now, in the project directory (such as"~/MyProject")
add a platform (Android or iOS) to the project.
in ~/projectName/ (such as ~/MyProject/) directory, execute the following command:
$ ionic platform android
(or $cordova platform add android)
NOTE: This command now will create an Android project using the unique names given in STEP 5 above.)
STEP 7. To work on the project using Eclipse, import the project into Eclipse
(CAUTION)
When you import an ionic project into Eclipse, make sure you do not check the ācopy project into workspaceā checkbox on the Eclipse import projects window. Otherwise, you will not be able to build and deploy your ionic app using Eclipse āRunā button.
And, Eclipse āimport Projectsā window will list two project names to import. You should check both project names to be imported and import both of them as follows:
For example, if your unique project name is āTestProjā, when you import it to Eclipse, Eclipse āImport Projectsā window will list the following two projects names to be imported on the āNew Project Nameā column:
(1) TestProj
(2) TestProj-CordovaLib
You have to check both project names to be imported and import both of them.
After importing is completed, you will see two project folders on Eclipse āPackage Explorerā as follows:
(1) TestProj
(2) TestProj-CordovaLib
You work on the āTestProjā.
Go to āTestProj/assets/wwwā folder. That is your ionic app.
Do not touch the āTestProj-CordovaLibā project. It just needs to be there, otherwise āTestProjā wonāt work.
STEP 8. After importing the project into Eclipse,
To show "~MyProject/assets/www/" directory within Eclipse,
click the following Eclipse menu items
Project -> Properties -> Resource -> Resource Filters
and delete the exclusion filter.
CONCLUSION:
Now, you can work on your app within Eclipse with a unique ionic project name.
When you install the new app on your device (such as Android phones),
the new app will be installed with a unique app name, a Project Name you gave, not as āHelloCordovaā.