📜 ⬆️ ⬇️

Review of innovations in Xcode 4.2 for iOS developer

Simultaneously with the release of iOS5, developers got at their disposal an updated Xcode 4.2, in which, as expected, some new features were discovered. Under the cat a brief look at the main innovations presented 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 do not want, everything remains the same, 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 the old code when you turn on ARC) .

In short, ARC automates memory management for Objective-C objects, and now it’s not necessary 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 translate your project to ARC, you must in the Xcode> Preferences> General enable the option Continue building after errors, then select Edit> Refactor> Convert to Objective-C ARC. At the same time, the target of the project will automatically change the compiler used to build the project to LLVM (about it just below).
')
I will note that on Habré there is already a rather detailed note on the use of Automatic Reference Counting , so I’m boldly sending everyone interested in the details of the innovation.

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

Default compiler

LLVM 3.0 already mentioned above became the default compiler used in Xcode 4.2. Apple claims that, compared with 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 will be 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, a view, view), set transitions between screens, as well as controls that cause transitions between screens. To do this, when creating a new project, tick the Use Storyboard checkbox.

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

I should note that in version 4.2 there appeared such new view controllers as the Page View Controller, which is a sequence of view controllers in the form of turned over pages of a notebook, and also GLKit View Controller, which controls the presentation of GLKit.

On the iPhone, each view controller is responsible for displaying one particular application screen (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 the view controllers by dragging and dropping the Control. At the same time, arrows will appear between the view controllers, representing the transition from one scene to another. You can set the type of animation of the transition between scenes.

Since this innovation is quite interesting, I will presumably write a separate note, revealing in more detail the essence of this innovation.

Geo Location Emulation

Leaving aside disputes about the correctness of translating Simulation into emulation or simulation (for example, orgasms) , we note that in Xcode 4.2 it became possible to emulate in the simulator the geographical position of the emulated device that is different from the real geographical position of the developer. In Xcode 4.0 and 4.1, this feature was not observed.

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

Application Data Management

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

Selectively downloading an Xcode distribution

Developers upgrading to version 4.2 (and myself included) will most likely not feel this innovation, but those who install Xcode 4.2 from scratch will, I think, appreciate what the default Xcode installer does not download some larger components, such as 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 examine the state of the application with OpenGL ES at any given 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.

In more detail about other innovations in Xcode 4.2, and also in iOS 5, it is possible to read, for example, in this description of innovations of iOS 5.0 .

Source: https://habr.com/ru/post/130915/


All Articles