Just learning to use Ionic to build a hybrid application, and wasn't really able find a great deal of info on the ionic prepare
command. Anyone happen to know what it is or what the difference between it and ionic build
?
-
Has my answer helped you understand the difference? If so (I see you're new here) consider it marking as an accepted answer.– NikolaJul 6, 2015 at 20:17
5 Answers
From the official documentation:
If you want to get advanced, you can also open up the project file for a specific platform by opening the required XCode or Android Eclipse project in platforms/PLATFORM inside the root of your project. Then, you can build and test from inside the platform-specific IDE. Note: if you go this route, I recommend still working inside of the root www folder, and when you've made changes to this folder, run the command:
$ cordova prepare ios
which will update the iOS specific project with the code from thewww
folder. Note: this will overwrite any changes you've made to theplatforms/ios/www
and other platform-specific folders.
So, to summarize this part - if you're using XCode to test and run your code, after you change some part of the code you just have to run ionic prepare
to update the iOS project which then again you continue to use in XCode.
ionic build
command actually prepares the final (for example in Android it's the .apk file) file which then could be copied to your device and test by running it manually on the device (or by using the ionic emulate
command to test it on the emulator).
Nikola's answer is correct. To sum it up:
ionic prepare <platform>
copies all files from the www folder into the target platform's www folder.ionic build <platform>
also does this, but also builds the app's source code so that it can be run on a simulator/emulator or a device.
Simply, build will do the prepare and compile as well for you.. this is the case for cordova, so Im assuming it is the samething since ionic is built on top of cordova..
As I experienced during the apk run for android and for iPhone, calling ionic cordova or cordova is same, By default ionic calls cordova for build or run or for any operation disjoint.
ionic cordova build: ionic cordova build [], it takes the platform explicitly as argument, other wise it takes the native configuration of the .jeson file under platform.
In case of ionic cordova prepare or cordova pepare, having no argument will add two platforms one as android and other ios.
If we explicitly mention cordova prepare android/ios, it will generate only respective platform accordingly.
Prepare build the platform gathering the necessary dependencies and it try to resolve it partially, but build just stops on dependencies process.
But there should be a clear cut suggestion, that keep track of the versions of the cordova's natives, It may cause some issue.
1.ionic prepare copies all files from the www folder into the target platform’s www folder.
2.ionic build also does this, but also builds the app’s source code so that it can be run on a simulator/emulator or a device.
value will be ios/android