Single code base for android and iphone in appccelerator

You must Login before you can answer or comment on any questions.

I want to build and iphone and android app with single code base using appcelerator at same time. i found that some time i have to get the platform name first and write platform specific code into that block.

Suggest me i should maintain two code base for these two build or its enough to have common code base. i have scan integration, native access of the iphone and android.

Please suggest me the correct way.

— asked 2 years ago by Rais Alam
1 Comment
  • Ya.i am also waiting for any reponse to this..but still no replies after people having many review to question...is really there is no answer to this ?

    — commented 2 years ago by Sandeep Kumar

3 Answers

one code base is the solution I am using for an application I am building. yes you should determine the platform by checking the osname property.

you can also create seperate js files for each platform, if you really want to, and place them in the android or iphone folders in the Resources directory. The framework will use the file if it finds one there.

one code base, then something like

if osname=="android" { do stuff here, like add certain buttons, create certain windows, include js files}

else { do it for iphone instead }

A lot of the code is universal, so it depends on the app itself and exactly what functionality isnt working.

I have yet to try my app that i build for Android on the iPhone, but i dont think ill run into any problems.

Your question is what Titanium is all about, creating apps for both platform at the same time.

How i am building my app is as followed:

-Creating a CORE app that has no dependency towards the iPhone or Android, meaning without any OSNAME it will work perfectly on both systems

-After the CORE is robust, use the OSNAME property to program specificly towards the iPhone or Android. This is unavoidable, why? an iPhone app should look like an iPhone app and not an Android app, and vice versa.

The way you programm for each system is up to Your program style, creating .js files only for one system which is less confusing but doubles your .js files.

Hope this helps you ;)

Your Answer

Think you can help? Login to answer this question!