This is the second post from a very own personal newbie guide to iOS programming. The first post from the series is here: Is It Your First iPhone App Ever?. I’m following Apple’s Roadmap and adding in bits and pieces from elsewhere with the solely intention of serving as personal summary and future reference.
As we already know, Xcode is Apple’s Integrated Development Environment to deal with Mac and iOS developing. This time I will focus on a few of its tools and features that could ease our work later on.
Xcode provides a workflow-sensitive help accessible from the Xcode user interface as a menu item in a contextual menu by clicking anywhere in the source editor (ctrl+click or secondary button click). Apple’s guide says to locate the go-back button because the Help Assistant will prompt on the same window you are coding in, but mine opened a different window instead, also accessible from: Window >> Organizer >> Documentation.
Breakpoints for Debugging
Click the gutter to the left of the code to insert a breakpoint.
After building and running an app in the iOS Simulator, it will stop the execution on that point so that you can see in the debug area the local variables, registers… and their current values. To remove a breakpoint simply drag and drop it away from the gutter.
You can gather data about your app’s memory usage, disk activity, network activity and graphics performance, among other measurments, and present it in a graphical timeline, compare it at different stages…
To access the Instruments panel: Window >> Profile (⌘+I). While it is associated to your project as a target you can always run the iOS Simulator and record readings.
– To manually create a snapshot (current project state): File >> Create Snapshot
– To view all previous snapshots (to restore your project): Window >> Organizer >> Projects
Source control management (SCM) allows you to keep track of changes at a more fine-grained level than snapshots allow. Xcode supports two popular SCM systems: Git and Subversion.
The iOS Simulator is generally fine for testing but it doesn’t run all threads that run on devices. Still, it is good to provide a development experience before enrolling as a developer (which is not cheap). It is also good for testing, but limited. And finally it is useful to have an idea of the app’s memory usage before carrying it into a real device.
The Simulator provides several ways to interact with it by using the keyboard and mouse to simulate taps, device rotation and other user actions. To change the device simulated go to Hardware >> Devices and choose from iPhone, iPhone with Retina Display or iPad.
To set the user content and settings of a simulation environment to their factory state and remove the apps you have installed, choose iOS Simulator > Reset Content and Settings.
If your app crashes while running in a simulator, the CrashReporter facility displays details about the crash.
Becoming a Registered Developer
Use this link to obtain a registered developer Apple ID. You will now be able to access documentation and resources for developers, but being a registered Apple developer, however, doesn’t allow you to run apps on iOS devices. To do so you must become a member of a Development Team by being invited to one or by creating your own enrolling in the iOS Developer Program (this costs $99/year).
Testing on a real device
Ideally you should test the app on all of the devices and iOS versions that you intend to support.
To do this:
1) Your app must be cryptographically signed before it can run on a device and your development certificate from Apple will be used for this matter.
2) Install an associate provisioning profile on the device.
You will now be able to run your app on a real device. The instructions to every step are detailed in Apple’s guide, under the title: Test you App on an iOS Device.
Although running your app on a device you are still able to use all debugging and performance profiling facilities from Xcode.
Validation and publishing
When you’re ready to publish your app, use the Archives organizer to perform essential validation tests required for App Store publication: Window >> Organizer >> Archives. You can also use the Archives organizer to share your app with others for testing and finally to submit your app directly to the App Store from Xcode.