Table of Contents
/dev/101 (The Holy Grail)


Develop your own applications!

You should have some knowledge of C, C++ (and, ideally, ObjectiveC) programming. Depending on your level of expertise, you may want to go the official (Xcode / Simulator) route, although iFuntastic's simplified approach has some advantages, too.

Advantages
No need to learn (or use) the Xcode environment. You need the iPhone SDK, an Intel machine and Leopard only for the Setup. After that, you can use a PPC running Tiger. You don't need to be a card-carrying iPhone developer to run your applications on the iPhone or iPod touch; you are not restricted to the simulator. No sandbox - have your application do as it pleases. A quick way to start programming on the iPhone; maybe try it here first, and then become a registered developer.

Disadvantages
No interface builder. You will have to create your UI programmatically. No application templates. The structure of an application is simplified; you may get used to the 'easy' way and develop bad habits. Official applications impose restrictions on what you can do and how to do it, but it's the 'right' way. Be prepared for some changes, should you move to official development (oh, for the App Store for example.) No access to the latest (and more complete) documentation and sample code - you need to be a developer for that.

There are excellent iPhone development books available: Beginning iPhone Development is the one I happen to have. Click on the 'Source Code' link in the 'Book Extras' section on the lower left, then on 'Source File Archive' in the middle section of that page, to get some sample code to play with.

The iPhone is a computer running OS X - its CPU is of a different kind than your desktop's or laptop's, so the executable code is not interchangeable and must be compiled differently. Why not let the phone do the compilation? Thanks to the Dev Team and particularly Jay 'saurik' Freeman, the developer of Cydia and WinterBoard and all around UNIX expert, you can install all the necessary tools with Cydia. Now you need the header files from the SDK and you are ready to compile. And thanks to iFuntastic, you don't need Terminal, SSH, WiFi or the command line!

The /dev/101 page has three tabs or sections:
In the Setup section you prepare all the necessary tools - this needs to be done only once (or whenever you restore your phone.) In the Projects section you create new projects and select the one you want to work on. Lastly, in the Develop section you edit the source code files and build the application.

Project files (source code, image, sound and other resources) are stored on disk and copied onto the phone for compilation and execution. iFuntastic's Text Editor is inadequate for intensive text editing, so when you double-click on a source file for editing, it will be opened in the editor of your choice. You will be asked to select one the first time; you can also do it - why not right now? - in the Preferences dialog.
Source code files should be plain text with UNIX line endings.

Setup
The setup section has its own documentation; in short: you install the compiler on the phone, the iPhone SDK on your computer, and iFuntastic will do the rest.

Projects
Select 'New Project...' from the Project menu or select a previously created one. One project will be the active project. Projects are folders on disk (in the Projects folder in the iFuntastic Support folder,) which hold all the resources and source code files required to produce an application. Click on the application icon or application startup image to edit them. The File Manager list on the right shows all files in the application folder. Any sounds and images and other supporting resources go in there. Click 'Save' to write the application to the phone. To begin with, the executable (and also the source code) will be a simple sample application. If you *don't* write the application 'skeleton' to the phone, then it will be done at the time of the first build. And now comes the fun part: build your own application!

Develop
The Develop section displays five lists pertaining to the active project. On the top left are the Project Source Files to Include. These are the source code files in the Project's folder. Click on the checkbox next to a file to include or exclude it from compilation. Double-click on a file to open it in an external editor. When you save the changed file, iFuntastic will mark it with a golden star in the right column to indicate that it has been changed since the last build. Click on the File Manager button to open the folder in the File Manager. This is where you can create or delete code files.

The entitlements.xml file (not really a code file,) should always be included; it is used by the code signing tool (ldid) to set the entitlement block for the code. The default entitlements enable the code to launch other applications.

Below are the Common Source Files to Include. This list works the same as described above, but it shows files that may be common to multiple projects. These are kept in the 'Common' folder in the Projects folder.

The third list on the left shows the Frameworks and Libraries to Link Against. You will rarely have to make changes to this list. It displays the frameworks and libraries (dylib) that are found on the device. The checked ones will be included in the compilation with the -framework or -l directive.

On the top right are the Project Resources to Include. This is essentially the listing of the .app folder from the 'Projects' section. A double-click will open the file for editing in the appropriate iFuntastic editor.

Last, the Build Status and Results listing. It shows the progress of the build process, and the error messages and warnings of the compiler, if any.

Click the Build button to build your application! iFuntastic copies all checked files into a temporary project folder in the bSE folder on the device. It will submit a script to build the executable and display the progress. When the build succeeds, the executable will be pseudo signed, copied to the application in the /Applications folder and its execute permissions will be set. Now your application is ready to run. Click on 'Launch Application', tap it on the device, or, if you checked the 'after build' checkbox, iFuntastic will launch it for you.

If the build fails, then you will see the compiler output in the Status list. Fix the errors and build again. If the problem appears to be with the build environment, or with iFuntastic's build procedure, then please let me know - send a Bug Report with the option in the Help menu. However, I am not a UNIX expert - the /dev/101 page is the state of my knowledge (as recently as version 6.5.0 of iFuntastic, I had no idea how to do any of this!) I'll try to come up with a solution, but there are no guarantees.

Tips
If you try to play a sound and you can't hear it, check that the phone's ringer switch is not set to 'Silent' (this cost me a few hours just now... embarassing, on top of everything else.)

The Dev101 Application
Dev101 is an application that iFuntastic launches whenever you initiate a build. It watches the progress of the build script and displays the build stages with sound and fury. (You're sitting in front of *the* iPhone UI editing program - change the sounds to your own liking if you wish.) Push the X button on the upper right to stop the build process (or click the button in iFuntastic.)

The Build Options Menu
The Build Options menu offers several specialized functions that you may want (or need) to use:

Build Sounds - lets you switch the sounds that the iPhone produces during a build off or on.

Never Sleep when Building - sets the Auto-Lock time to 'Never' before building. You can change the Auto-Lock time back in the Settings application on the phone, or from the Device menu in iFuntastic.

Change Display Name - by default, the display name of your application is the same as the project name, which is also the bundle (application) name. The project and bundle names cannot be changed easily. You should create a new project and copy the code and resources over. However, you can change the name that is displayed on the Home Screen with this option.

Change Bundle Identifier - this identifier must be unique. It defaults to com.DEV.dateAndTime. You can change it with this function.

Change Executable Name - the executable is called 'TheCode' by default. You can change the name here; especially when building a command line tool.

Command Line Tool - when this option is checked, iFuntastic will only compile the executable, but it will not create or update an application folder. To run your tool, you should execute a script or ssh into the iPhone and test your tool from the Terminal.

Bind at Load - affects the way code addresses are resolved. Saurik recommends it to be switched on - and who am I to disagree?

Maintain Build Script Manually - iFuntastic creates a Build.script file on disk and in the project folder on the phone. If you have special needs or circumstances, you can maintain this script yourself. With this option checked, iFuntastic will copy the script to the phone and execute it as is.

Update Build Script - updates the build script. This is what iFuntastic will execute.

View/Edit Build Script - opens the build script in the text editor.