Should I learn native iOS development (Objective-C

2019-02-05 00:49发布

问题:

Basically I need your advice my good stack friends :D

For the last six months I am exploring/learning/developing iOS apps with Titanium Appcelerator mobile framework. My experiences are mostly good or very good.

Some negative parts of Titanium would be building time, especially when testing on a device. When using only Xcode (native), your app starts immediately on a device, while with Titanium you have to wait for a while (1-2 minutes) for your app to build and then to install it on a device (iTunes or iPhone Configuration Utility).

Basically everything that you can do natively you can do with Javascript + Titanium. If Titanium does not support some part of iOS framework, you can build a native Objective-C module and have those features in your Javascript code.

I feel really comfortable now using Titanium Appcelerator and building apps with Javascript. Also I learned some Objective-C while building a few modules for iOS. Eg. DeviceMotion which I used in my first iOS app Spellery.

Now the question:

Most companies wants only native developers and are sceptic of Titanium. Titanium is different from other cross platform SDKs (Eg. PhoneGap) because here you actually use native components (buttons, labels etc) and your app is not running in a WebView. But if company wants native then you can't force them to use Titanium.

Since I would like to develop mobile apps as a job, should I just throw my last six months of intensive exploring of Titanium and learn programming those apps natively?

What are your thoughts on this because I see no point in learning/perfecting both of them?

I am a very big fan of Appcelerator Titanium now so this is a very heavy decision to make.

回答1:

Frankly, I would still suggest learning some more Objective-C. It's a very powerful language, and it is designed to allow you to many things that Apple considers necessities much more easily (eg. Animation, Persistance, Databases, MVC). Apple has designed their frameworks around Objective-C very tightly, and to really use them well, you have to use them from their language. Also, what other languages do you know? I, for one, found Objective-C much easier after coming from C/C++ and a scripting language (Ruby). It all really depends how much iOSness you want in your app. Even it Titanium can make the user end feel iOSy, iOSy code is actually really fun to write and maintain. It can be quite a beautiful framework.



回答2:

I agree with everything said in previous answers and you seem to have accepted to come back to the light side - good choice!

I'd just like to add this: Don't look at those six months as being wasted. During your time with Titanium, you have learned a lot of technical details, as well as possibilities and limitations of iOS and that should prove useful when you switch to Objective-C.



回答3:

Ahhhmmmm... I'm not sure whether my answer is going to be removed by stackoverflow admin. Pardon me, I'm going to take a few minutes of yours reading this long response (if you are interested to keep on reading).

I started my own company in 2010. We worked on php, mysql, html, jquery based websites only. As the mobile platform was getting more attention we started working on Sencha Touch + PhoneGap based mobile apps. In late 2011, I trained up my 12 developers in Sencha Touch + PhoneGap. You can understand how much effort it was to learn and train up a team of 12 developers in a new framework.

After developing more than two dozens of professional PhoneGap based apps we realised it's far away from native apps. Only one example is enough - PhoneGap app took longer time to load the initial html page into the webview. A blank white screen appeared just after splash screen (On android it is more horrible!). In recent phonegap versions it's fixed. But who are working with phonegap know very well how far it is from real obj-c app. We worked in PhoneGap+Sencha Touch framework for one year.

We stopped working in PhoneGap and started learning & training my 12 guys in Titanium. I know how much hard work it was to start another new framework from scratch. We kept on working with titanium for 2 years, developed 30+ successful professional apps in titanium for both iOS and Android. We got expert in developing titanium modules. Just for example we developed PayPal titanium module on both iOS and Android. (You must be giggling, what is so great about that! It’s already developed by titanium team). No, not using the old MPL library. We used the latest Paypal sdk 2.8.0 and there is no module available online using it.

In mid 2014 we started working on a Tinder/Lovoo clone type app. We developed a ti module for similar animations (by implementing UIView drawRect). Everything was working fine. But when it’s run on iPhone, the device became excessively hot and battery drained out dramatically on the animation page. We created a sample demo Xcode app and applied the same animation, tested in Instruments, everything was fine. No overload on memory or processor, device remained cool, battery performance was fine. We tried every way possible to make it better in titanium module and no luck. Finally discovered titanium itself takes huge footprint to run it’s own bulky framework and for every action, it fires a lot of proxy events and keeps on listening for unnecessary events. Complex UIView animations makes it crazy. It’s just an example - on android it’s a long story.

Why companies decide to use Titanium? The first answer is it’s cross-platform. You just code in js and it runs on both iOS and Android. Ha ha.. such a joke! It’s not true for a real professional app. There are lots of differences and bugs on Android version and it’s a load of more work on android version. And practically we could never use a same iOS codebase exact copy for Android. So that theory of cross-platform is true only for class projects. If you don’t believe me make a simple titanium android project to capture image, upload it on server and then display it again from server. Take a galaxy S5, take a picture (Not in portrait mode) in landscape-right mode (home button on right hand side), you can see the image orientation gets messed up. Oh! I forgot, from titanium android app if you upload image on server, the image extension becomes .txt

In Obj-C UINavigationController popToRootViewControllerAnimated method is a vital functionality to navigate back to home page. This very method is not available in Titanium!

We spent hundreds of extra hours to fix these kind of awkward issues. My dev team got fed up with titanium.

Definitely you’re gonna ask me now, why on earth we didn’t start Obj-C at the beginning? The answer is same from all the titanium developers - Javascript is easy and web developers are already familiar with it. This is a big mistake. We take iPhone app as a web app. A web app runs on a web browser, more specially on iPhone it runs inside iPhone’s Safari. “Safari” itself is a mobile app, and we expect the web application should run as similar visual animations with the same pace, which is never possible. CSS3 animations could never be same as iOS vector based UIView animations.

iOS is NOT a framework or a library, it is a Operating System. Titanium is a framework that is written in Obj-C. You can not use Xcode’s Storyboard UI design tool in titanium. Xcode developers know how sexy the “constraint” is for UI interface design. And this visual appeal of using constraint is totally missing in Titanium. Though ti team claim we can do the constraints stuffs using Ti.UI.FILL/SIZE etc. But after we’ve moved to native Obj-C we know how powerful this constraint system is!

I just pull my hair out and regret why I got scared looking at those Obj-C syntax with square braces and jumped back to titanium. It feels like you are going decades back in the modern age just looking at the unfamiliar syntax of Obj-C. Lucky that Swift is there and it’s now much more easier to code in Xcode. Though it’d need some time to get the existing popular & powerful Obj-C libraries like AFNetworking, MBProgressHUD, OpenCV migrated to Swift.

To be honest, I really feel the Titanium, PhoneGap, Xamarin etc cross-platform frameworks should be banned. Their license should be ceased. Does titanium give you any extra feature that is not available in native iOS or Android? Instead, there are way much less functionality and more bugs. I do not understand why, how on this modern bleeding edge technology they are pulling people back to old days and there is nobody to stop them! How it could be legal to guide developers to wrong direction? If iOS 9 is released “today” will Titanium give you all of the new APIs within next week? Never. They just hold you back and make you bound to use their limited set of buggy APIs, you need pay for modules, which can be easily done in native code.

If you know javascript well, good in logic sense, believe me you can learn Obj-C in a very short time. By the time & efforts you’d lose debugging titanium issues, you can become more efficient in native Obj-C. Ummm.. about android I won’t say that high. Cos Android is never compareable with iOS. iOS is born from the Mac OS, a well established desktop operating system. And you know about android.

Do not fall into the trap of cross-platform dilemma. Loads of Titanium APIs are for iOS only, you know why, Android devices are cheap, hardware is cheap, can’t run animations smoothly.

Finally, stay away from any kind of platforms and stick to pure native OS, no matter how hard it is in the beginning, you’ll be well paid off in the long run, believe me!

To the Titanium team, I reviewed your Obj-C and Java source code. I do respect you guys, you are indeed very much expert and well experienced in Obj-C, Java, node.js, python and javascript. But why? Why are you leading people to the wrong direction? You know very well how much time is wasted to build a titanium android/ios module and test it. Why don’t you put your efforts into something better.



回答4:

I bet a lot of others will chime in with posts to other "duplicate" questions, and their own raging opinions. So I'll leave that to them, and just provide my own experience.

I think there's good reason to know both deeply. Here's why:

Titanium lets you build apps really quickly, and it's getting more and more solid every day. I recently built an app to directly compare development times between Titanium, native, and a couple competitor frameworks. Native was about a week and a half. Competitor was about 2 weeks. Titanium was 3 days. That gave me a whole lot of time to play with the app and make a product a whole lot better than the competitors. I was also able to get it working just as well on Android and Mobile Web. I had around 5 platform-based conditionals, so the code had good parity.

Native has the advantages you brought up. I would add that you can also access whatever the platform has to offer. Knowing native will inform how you build apps (even when using JavaScript), and how you build modules for those apps. You might also try opening up the Xcode project that Titanium generates, and running directly on device through that. You might need to do a clean build (in Xcode), but it's quicker than running through iTunes.

Plus, I think Objective-C is a beautiful language in and of itself. It's very different from the code I "grew up" with (Java, C#, PHP, VB, and some others). It took a while to get accustomed to it, but I am glad for the time I invested.

Disclaimer: I work for Appcelerator. Hopefully you can differentiate opinions and facts in the above.



回答5:

Look at job postings that you are interested in and that should answer your question. If employers are looking for XCode expertise and not interested in Titanium then focus on XCode...



回答6:

To add to @Linuxios's excellent answer:

Since you state you want to enter mobile development as a career, then most definitely learn Objective-C, XCode, and the iOS SDK. At the end, it'll be up to you, your employer, and to some degree your clients needs. But understanding iOS is essential.

Also, in my experience, if the application is complicated, native would be the way to go, if for nother reason than ease of debugging, and as you state, shorter build times.

UPDATE: One other thing to add, if performance is key (i.e. gaming), then native (C/C++/Objective-C) is the way to go.



回答7:

From my point of view it's always very useful to learn native app development, iOS as well as Android. As you have already mentioned, the majority of companies are looking for native app developers, since they do not want to depend too much on external companies or frameworks, other than the actual developers of the platform (Android, iOS and so on). I also think, once you are capable of developing native apps, it's a way easier than using a framework like Titanium or PhoneGap. Furthermore it is always good to enhance your own skills and in particular native app development is a field, where you can learn a lot. Not just about the language but also about the architecture of the underlying mobile operating system. And in particular for Apple, I think it's crucial to learn to develop native. They have very good resources on their developer portal and there you learn also a lot about the intended user interaction design.

Last but not least, I would recommend you to go ahead with Swift. It is a great and powerful language, fixing many of Objective-C's weak points. You can basically start form scratch with Swift without the need of Objective-C. The complete Cocoa-API is accessible via Swift. But if you want, you can still combine Objective-C and Swift. For instance if you need to use a external library which is not implemented in Swift yet.

Hope that I could help you a little.