Xcode 4.2 innovations for iOS developer

    Simultaneously with the release of iOS5, the developers received at their disposal an updated Xcode 4.2, which was expected to reveal some new "features". Under cat, we briefly review the main innovations introduced in Xcode 4.2.

    Automatic Reference Counting (ARC)

    Now, when creating most of the new applications from ready-made templates, you can choose whether you want to use ARC or not. For those who don’t want, everything remains as before, for those who choose to use ARC, life becomes somewhat easier in terms of writing code (and more difficult in terms of finding bugs in old code when ARC is turned on) .

    In short, ARC automates memory management for Objective-C objects, and now you don't have to write retain, new, release, autorelease. Moreover, for projects in which this function is enabled, the presence of the specified keywords in the code (as well as unspecified, but used previously for memory management) will cause compilation errors.

    In order to automatically transfer your project to ARC, you need to enable the Continue building after errors option in Xcode> Preferences> General, and then select Edit> Refactor> Convert to Objective-C ARC. In this case, the target of the project will automatically change the compiler used to build the project on LLVM (about it a little later).

    I will note that on Habré there is already a rather detailed note on the use of Automatic Reference Counting , so I boldly send all those who are interested in the details of the innovation there.

    A Transitioning to ARC Release Notes document may also be useful on this topic .
    In addition, there is a wonderful video from WWDC 2011 on the same topic .

    Default compiler

    The already mentioned LLVM 3.0 has become the default compiler in Xcode 4.2. Apple claims that compared to GCC in Xcode 4.0 and LLVM-GCC in Xcode 4.1, LLVM generates and optimizes code faster, better, stronger.
    In addition, as mentioned above, LLVM supports the use of ARC in Objective-C.

    Storyboarding

    This term is carefully translated as Storyboard, which, in fact, reflects the essence of the innovation. Now, for newly created applications, you can draw each screen separately (in some books - view), set transitions between screens, as well as controls that cause transitions between screens. To do this, when creating a new project, it is enough to check the Use Storyboard checkbox.

    When creating a project, you will be presented with a view controller, which is like the first “scene” (the term scene means Apple understands a separate specific screen of the iPhone application), i.e. The initial, initial screen of the application. To add new views to your application, just select the Controllers & Objects subsection from the Object library, select the desired controller and drag it to the workspace.

    It should be noted that in update 4.2 new view controllers appeared, such as Page View Controller, which is a sequence of view controllers in the form of scrolling pages of a notebook, as well as GLKit View Controller, which controls the GLKit view.

    On the iPhone, each view controller is responsible for displaying one specific screen of the application (scene); on the iPad, more than one such “scene” can be presented on the screen simultaneously.

    In order to set transitions from interface elements to other view controllers, it is necessary to associate these same controls with the headers of view controllers by dragging and holding Control. At the same time, arrows will appear between the view controllers representing the transition from one scene to another. You can set the appearance of the transition animation between scenes.

    Since this innovation is quite interesting, I’m supposed to write a separate note that reveals the essence of this innovation in more detail.

    Geolocation emulation

    Leaving aside the debate about the correct translation of Simulation into emulation or simulation (for example, orgasms) , we note that in Xcode 4.2 it was possible to emulate in the simulator the geographical location of the emulated device, different from the real geographical location of the developer. In Xcode 4.0 and 4.1, this possibility was not observed.

    In order to set the location, you need to open the Run tab MyLocationSimulationApp in the menu of the choice of options for the emulated device Edit Scheme ... (your application name will most likely be different), go to the Options tab and check the box for Core Location - Allow Location Simulation. After that, from the drop-down menu, you can select the emulated location (supported including Moscow, Russia).

    Application Data Management

    In Xcode 4.2, you can now save and restore application data files in a simulator or on a real device during debugging or unit tests. I have not yet been able to use this ability, so unfortunately I can’t say anything more.

    Selective download of the Xcode distribution

    Developers upgrading to version 4.2 (including myself) will most likely not feel this innovation, but those who install Xcode 4.2 from scratch will appreciate that the Xcode installer doesn’t load by default some great components, like older versions of device simulators. In this case, the missing components can always be downloaded separately.

    Improved debugging of OpenGL ES applications

    I do not consider myself an expert on OpenGL ES applications, so I will not comment on this innovation. As I understand it, it is now more convenient to study the state of an application with OpenGL ES at any given moment in time, including the state of textures and shaders. I hope that more competent comrades will correct me in this (and maybe not only in this) issue.

    You can read more about other innovations in Xcode 4.2, as well as in iOS 5, for example, in this description of iOS 5.0 innovations .

    Also popular now: