I recently became interested in iPhone app development, so I've been looking at online tutorials, and also reading a book, trying out the examples as I go along.
I'm getting better, but one of the things I still find quite annoying about the usual development model is that I really have no idea what the SDK is really doing behind the scenes to make the app "work" because Apple protects me from this. For example, when I make connections on interface builder, this presumably corresponds to code being generated somewhere... Where that code is and what it does and how it works are not obvious (to me).
So I'm wondering, is it possible to create an iPhone app entirely programmatically? That is, have execution start in some main method, which will then programmatically create any views, register event listeners, etc. And if yes, what are some good resources for something like this?
There is no generated code. It's serialization. Interface Builder serializes the object tree to the .xib file, your app deserializes it back.
Of course, you can also build your UI in the code, it's just more code. In early versions of the SDK this was even necessary, since Interface Builder was not available yet.
I don't use interface builder and it works great for me. When creating a new app in XCode you can chose "Window-based app" and it will create you a window in your new project and the application delegate. The application delegate has method applicationDidFinishLaunching which is effectively your "main" method - you can create views and them into window directly, or you can create viewcontrollers and then add their views into the window.
I'm getting better, but one of the things I still find quite annoying about
the usual development model is that I really have no idea what the SDK is really
doing behind the scenes to make the app "work" because Apple protects me from
this. For example, when I make connections on interface builder, this presumably
corresponds to code being generated somewhere... Where that code is and what it
does and how it works are not obvious (to me).
You've got it all wrong. IB helps you instantiate your control objects and helps you connecting them to your code logic through IBOutlets, but these are real, live objects, it's not code generated, this is a misconception. This code is archived in Nib files (runtime) and in Xib files (used by IB during design) all of this and more, including the Nib Object Life Cycle is explained in detail at https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW8
And yes, you can bypass IB entirely, but it's definitely not for beginners.
Short answer: Yes
Long answer:
Interface builder isn't doing much more than generating XML for you. You can open the XIB in a text editor to prove it, and Xcode is even smart enough to eval the XML and give you compiler warnings when appropriate.
There are lots of tools that auto-gen iPhone projects, probably the most popular being Unity. There is also the open source project Titanium for the adventurous. It's a lofty project to undertake by yourself, so I'd recommend pitching in to help one of the open source projects that are already out there first until you are well versed with it before trying to go off and reinvent a better wheel again.
Related
I have 3 apps developed in LWUIT using the Resource editor and adding more functionallity with Netbeans. I want to port them to codenameone. What is the best way to do that?
I see that the navite Componentsfrom LWUIT have an equivalent Componentin codenameone, but J2ME methods and classes , now have to be ported to J2SE, is that right?
The methods in the StateMachineBase have changed too. showForm() for example, doesn't exist now.What further changes are in StateMachineBase?
Thanks
Start by creating a new Codename One project then just copy your source code/resource files and fix the import statements.
You can't use the MIDP API's anymore (and you can't use J2SE either), there are new API's and a new lifecycle object which you can use for pretty much everything. showForm does exist and wasn't modified, I'm not exactly sure why you didn't find it.
Generally Codename One is much simpler since it doesn't have the project hierarchy issue and you don't need to deal with MIDP/RIM/Android differences. Its all handled for you.
I have created a Mac app that can generate iphone ebook app project source codes.
I know I can using xcodebuild to build the project to get the release binary file.
Is it possible to hide the source codes of .m files(maybe store in memory) and build project using xcodebuild?
Welcome any comment
Thanks
Marc
It sounds to me like you are attempting to generate source code for others to use, but then hide it so they cannot see whats been generated. Basically not possible. You could generate obfuscated code which would make it harder to read, but not impossible.
Realistically what you are trying to do is generate template code for others to use. If you don't want them to be able to see it, then you presumably don't want them modifying it. The easiest answer is to simple not do it. Instead, create a compile static framework containing your code and IP, and then only generate templates which makes calls to your framework. Thus your code is protected.
Your question lives on the edge of being programming related, and I'm not exactly sure what problem you're trying to solve.
However, you can create a RAM disk, store your project there and run xcodebuild against that. Just be aware that you're not really protecting the .m files so much as limiting how long they are easily visible.
In general I know how to do the Localization of iOS apps, the only thing is to choose between available ways and do it the right way. So I'd like to ask you about your l10n approach for your projects.
Here are my inputs:
I have 15 XIB files (packed with
lots of IB outlets that are not
synthesized as properties, but will
have to be localized).
It is most likely that that my
app will have 3-5 language versions,
but it is possible that I will even
go for 10 languages in the future.
In near future I plan to add new
targets that may change UI design
(paid/free versions).
I see two ways I could go:
Option A: localize each nib file by making XIBs localizable and adding language versions:
I fear that with 15 XIBs and 3-5 languages it will be maintenance horror that will go out of my control when I'll extend localization to ~10 languages and introduce new targets (maintenance horror is not about SCM, I'm using git btw).
I'd need to keep in sync all versions of XIBs which would effect in painful change-request process.
I also fear that my app bundle will grow big (currently XIBs use ~1.1 MB and translate to ~120 kB of NIB files).
when I'll decide to do iPad version, the number of XIBs will grow again.
Option B: do the localization in the code by wiring up all needed outlets synthesizing them to properties and setting their labels/titles correctly:
I fear that my app memory footprint will be really big. Or, considering proper mem mgmt, should I not consider this an issue?
I'd go for 2nd option as I see less cons to it and it can allow having everything in one place under control in each view controller, but I'd like to know what would be your choice? Which way works better for you?
EDIT: I know that that ibtool could simplify the process in Plan A, but I'm still not convinced for it.
I am using Option B in all of my projects, since this also makes it easy for me to distribute the string files to the localizers. Testing is of course needed after that to make sure the strings fit into place. Also some projects do not use XIB files, so the process is always the same, no matter if XIB files are used or not.
There is no memory issue with that option at all in my experience.
Well, I was expecting a little more feedback from SO users, but that's fine as after some research I've made my own decision to abandon option B and go for a modified version of option A.
I've heavily used ideas from a Compile-time approach by Philippe Casgrain. In general it uses ibtool to automatically localize nibs when building. Philippe's approach keeps maintenance reasonably sane for now. All other strings that I use in the code are handled using NSLocalizedString approach which was quite easy to implement in my case (just used genstrings tool). The only issue that can potentially hit me in the future is adding new targets with different/modified UI layouts.
It's hard to say whether it was the best choice. Time will tell, so some day I'll update the question and share with you how the decision worked out for me. Maybe someone will benefit from it in the feature ;)
Hi experts i have created a set of UItableviewcustom cell classes. Now can i group those classes to an static library so that i can include that library in whichever project i want and i can use it.
You can, but it really isn't worth the trouble... with the rate that they keep on releasing new SDKs, and considering that you'd have to make it a Universal binary supporting both the simulator and the iPhone device, it really isn't worth the effort... I'd just save the ".h" and ".m" files and drop them in a new project.
However, if you are absolutely determined to go that route... I do have some articles on creating iPhone frameworks: here. Note that they are somewhat outdated (circa iPhoneOS3.1), so I don't know how much has changed, and I've since converted to the Android camp... but you still might find the info there useful.
I just have a question about binary file in an iPhone app.
When an iPhone developer wants to submit their app to testers or App store they build the binary file of their appliction. My question is it possible to edit your app's binary to get the source code, or just simply edit the binary for someones purpose.
If it is posible how can I prevent it to happen.
In general, getting source from compiled code is technically possible, but not to the extent you fear. Decompiling isn't usually done for a few reasons.
One of the things a compiler is optimize a lot of different things in your application, e.g. unrolling some loops or inlining some functions. That would make a decompiled code very different from the source and harder to modify.
Symbols are generally lost when compiling. I don't know the process for every compiler (Especially not for iPhone apps), but I know Visual Studio keeps a separate database for debugging. Without that database, var UserPreferences would turn to _a or something along those lines.
All that said, you can't completely keep someone from decompiling your code, but there's pretty much nothing you need to do to make it hard for them to get something useful.
As Alex said you cannot prevent someone from decompiling your binary if they really want to do so however unless you have some secret code or something they can't get any other way it is usually less work to write a clone of your app then decompile it and use the result.
If you do have a secret code or something you need to hide from people (usually as part of a DRM or DRM-like system) one way to made it harder to get to would be to not directly put the code in your app. Use a state machine or something to build the code so it is harder to figure out what is going on. That might buy you a week, anyway.