How to get started with Xcode 6 quickly in iOS development

Source: Internet
Author: User
Tags spritekit

How to get started with Xcode 6 quickly in iOS development

BKJIA: Every version update of Xcode focuses on bringing more powerful tool solutions to developers to help them build applications more smoothly. In Xcode 6 released this year, developers continue to welcome more new methods of software design and construction. In today's tutorial, we will give an overview of the new and improved features in Xocde 6, and introduce how to apply them to your own development work.

1. Playgrounds

At this year's WWDC conference, Apple officially announced Swift, a new programming language for Apple's mobile device software development. In concert with the birth of the new language, Xcode 6 has added a feature named Playgrounds-which is actually a set of interactive work areas, developers can write Swift code here and get real-time running effect feedback without running it on a device or simulator. This is undoubtedly a good supplement for Xcode. Now you can add your own code results to the main code base before, quickly and conveniently grasp the real-time running effect in an experimental way.

2. Interface Builder

Another major topic of this year's WWDC conference is building adaptive applications. Compared to building applications for specific screen sizes, Apple now encourages developers to create applications that automatically adapt to the running platform by ignoring the actual screen size.

This was actually originated from Auto Layout and several subsequent versions of the iOS 6 system. This solution allows developers to directly create applications that can run on both the 3.5 inch and 4.0 inch screens. Now this mechanism has been further improved, and iOS developers have been able to build applications that run directly on all supported iPhone platforms, this includes the next-generation 4.7 inch iPhone 6 and 5.5 inch iPhone 6 Plus-the same code library can be used even for iPad.

After a series of major changes, the Interface Builder can develop and support such adaptive applications. Some other new functions are added to improve the design process of the user interface. Next we will introduce the specific adjustments.

Size Classes

Size classes defines the canvas Size used by the layout scheme. These classes allow developers to specify how the user interface of an application can deliver available display ranges based on changes in the View Controller. With the help of Size Classes, we can build an application with a unified display template. In contrast, in the past, developers needed to design two independent display templates, one for iPad and the other for iPhone.

A Size Class dimension Class) defines the relative quantity of items in the display area, such as the display height (vertical dimension) or the display width (horizontal dimension ). Currently, Xcode provides two dimensional classes: compact and regular ). For example, an iPhone is in portrait mode with a compact width but a standard height. The width and height of the iPad in portrait and horizontal display mode are normal.

However, we should note that the size class does not have to map to a certain display mode of a certain device. For example, an iPad can use only a small area of the screen to provide a view similar to the iPhone layout style, that is, a horizontally compact, vertical, and regular size class ), you can also use the natural style layout inherent in the large screen size of the flat device, that is, the horizontal and vertical sizes are the same as the regular size ).

You need to adjust the Size class by using the Size Classes control mechanism close to the bottom of the canvas in the Interface Builder toolbar. In the starting state, the Interface Builder provides the dimension class settings of any) width and any) height, we can place various user interface components and fix their positions based on the actual screen sizes and horizontal/vertical display modes of different devices. Next, when the available screen size changes, you will use another different size class to update the component positions in the user interface, so as to provide a more suitable layout effect.

Adaptive transition type

The adaptive transition type mechanism provided by Xcode 6 is more suitable for use with the New Adaptive Layout, because these adaptive types can provide different view schemes based on the environment in which they are running. For example, if you use Show Detail to display details in the Split View partition View on the iPad), the Detail will be replaced; but on the iPhone, the same operation will push Detail to the Master. Some old transition types, such as push and modal, have been deprecated.

Real-Time Rendering

The Interface Builder canvas is far better than the previous version in terms of interaction capabilities. In the past, you had to run your own applications to view the changes in the user-defined objects, user-defined fonts, and component positions. Now, we can select a Custom font through the font picker of Interface Builder and display it directly in Interface Builder canvas.

You can even create custom objects and render them within the Interface Builder canvas. To achieve this goal, we need to create a custom framework, add our own custom classes to the target, and use @ IBDesignable to mark IB_DESIGNABLE in Objective-C) mark this class. In this way, the Interface Builder will realize that this is a class that can display custom content in the canvas.

In addition to viewing custom objects in Interface Builder, you can also use @ IBInspectable to mark attributes so that they appear in the Interface Builder check menu. Here, we can edit the preceding attributes, just like editing other attributes in the view. In other words, we do not need to design or annotate a class to make it a checkable attribute.

You can also specify the design time in the form of pure code. For example, we can use this method to pre-fill the sample data into the view to get a more accurate sense of the interface. To achieve this, you need to override the prepareForInterfaceBuilder method. In addition, we can also use # if TARGET_INTERFACE_BUILDER to add or remove the selected code from the rendering effect view of the final Interface Builder.

Preview Editor

The Preview Editor allows you to view multiple previews on Different Simulated devices one by one. In addition to directly observing the Running Effect of applications on different devices, you can also change the vertical or horizontal display mode of each device by setting. With the help of this new feature, we can more easily preview the user interface of the application on different devices and their display modes without having to actually pay for the operation.

3. Game Development

Apple added new game technologies in Xcode 6 and iOS 8, named SceneKit and Metal respectively. SceneKit has previously played a role on the OS X platform. Its essence is a set of 3D Scene Rendering tools. Metal is a framework that can be used to create highly optimized graphics rendering and computing tasks-this is because it can be connected to A7 and A8 GPUs in a low-loss manner.

SpriteKit has also been improved in multiple layers, including physical balance per pixel, physical area, general motion and restriction, material, illumination and shadow.

Another important new feature in SpriteKit is the SpriteKit Level Editor, which allows us to build scenarios in an intuitive way. Just as you can create a user Interface in Interface Builder without writing any code, SpriteKit Level Editor can help us easily create a SpriteKit game in the same way.

4. Develop Storyboard for OS X

Storyboard is now introduced into the OS X development process. As in the iOS development environment, Storyboard allows us to build our own view layout and combine these views with various types of transition animations. However, as of the writing date, some features, including Storyboard, cannot be used for OS x development in Xocde6.0.1. We believe that the situation will be improved when the OS X Yosemite version is released.

Gesture Recognition

The gesture recognition function is now available for AppKit and is used in exactly the same way as the iOS app development process. You can view available gesture operation types in the Object Library of Interface Builder.

5. Localization

The operating mode of the localization function in Xcode 6 differs greatly from that in the previous version. Now, you can export all your local content to XLIFF. This is a set of industry standards and is implemented through a large number of translation services. After obtaining the translation result, we can import it, while Xcode will merge the new content into the original project. By the way, you should create an XLIFF file for each language supported by your application.

Now, you can preview all the localized content without changing the local options of the device or simulator. To achieve this, choose Product> Scheme> Edit Scheme, select Run, and click the Options tab. In this case, you can select your desired Language project from the Application Language menu. Xcode also provides the Double Length pseudo language project, so that even if you have not added any other languages, you can still perform the test. After running the application, we can view the local content.

In addition, we can directly view the localized content without actually running our own applications. To achieve this, you need to use Preview Editor to switch between different languages supported by the application. The default language is displayed in the lower-right corner of the editor. When you click on it, you will see a list of available languages. Again, if you want to test without adding a language, you need to use the Double Length pseudo language mechanism.

6. iOS simulator named Device

Xcode 6 now provides the simulator naming function so that developers can distinguish specific devices by the name "iPhone 5s, instead of using a general name like in the past-for example, a 64-bit iPhone Retina.

Adjustable simulator size

Now you can select the desired device type from the adjustable iPhone and iPad. The two solutions allow us to specify the width, height, and screen size of the simulator. In this way, you can more easily test the running performance of your applications on existing Apple devices and devices that may be released in the future, instead of downloading different simulators for each device.

Simulator custom configuration

In the new iOS simulator, you can combine data with configuration settings. Specifically, a configuration scheme and related data are run for a specific version of an application, and another configuration scheme and related data are run for other versions. This means that you can simulate the usage of multiple users on the device. Each user has its own independent data and configuration scheme.

7. HomeKit attachment Simulator

The HomeKit framework allows applications to communicate with and control other access attachments in the user's home. In the current Xcode 6 beta version, the HomeKit attachment simulator has existed as an inherent component, but is still one of the functions of Xcode's Hardware I/O Tools. You can click here to download the framework from iOS Dev Center.

8. debugging view debugging tool

The Real-time View debugging function provided by Xcode 6 can greatly simplify the debugging process on the application user interface. Now developers can pause running applications and parse the current interface in 3D view mode. The view debugging tool displays the current view level and Auto Layout settings. When you select a view, you can check its attributes in the check tool or jump to the corresponding code in the auxiliary editor. With this powerful support, you can solve many headaches in the past-for example, the Auto Layout conflict, and how to hide or collapse a set of views.

To start the Real-Time View debugging tool, you must first start your own application, and then click the Debug View Hierarchy Debug View level on the debugging toolbar.

At this time, our applications will be paused, and the entire user interface will be displayed in 3D visualization. We can drag any position in the canvas to rotate the view.

You can use the buttons below the canvas to switch between multiple view states.

The buttons from left to right are as follows:

  • Show collapsed content: This option is used to hide or display the collapsed content in the selected view.
  • Display constraint: This option displays the Auto Layout constraint mechanism in the selected view.
  • Reset view area: This option resets canvas to its default status.
  • Adjust view mode: This mode allows you to view the view by yourself. You can choose to view only the view border, View content, or both.
  • Zoom out, actual size, and zoom in: allows you to adjust the size of the view.
Quick Look

Quick Look Quick view) was first introduced in Xcode 5. Its function is to help you view the content of a specific object during debugging. Quick Look supports a variety of common object types, including images, besell curves, and map locations.

In Xcode 6, this feature supports two new object types: View UIView and NSView. To enable Quick Look to recognize custom objects, you need to add the debugQuickLookObject Method to the custom class.

Enhanced queue debugging Mechanism

The debugging wizard records and displays the recently executed blocks and queue blocks. You can use it to view where your queue block is located and check the specific settings in execution. You can choose Debug> Debug Workflow> Always Show Pending Blocks in Queues to enable block debugging.

Debug the Metering Device

The purpose of the metering device debugging is to provide various information related to the Application resource usage during the debugging process. Xcode 6 has upgraded the metering tool. Now it is able to graphically analyze the new Metal framework and the iCloud that supports Cloud and CloudKit documents.

In addition to the above improvements, Xcode 6 also introduced two new debugging metering devices for network and disk activities.

The network activity meter is designed to display the amount of data sent and received by our applications, and provides an open connection list. You can view historical time records to monitor network usage and find out when and why network usage peaks or network faults occur.

The disk activity meter is used to display the real-time information of application disk read and write operations. It also provides information about all open files. Disk I/O activities are delivered in the form of a historical schedule. You can use this to achieve monitoring.

9. Asset directory

The asset catalog now supports dimension classes. This means that you have been able to easily provide special image materials for different sizes, so as to ensure that your user interface has a general and compact height and width design effect.

The original asset directory only supports PNG images, but in Xcode 6, the new version supports two new formats: JPEG and PDF vector images.

10. Start the image

You can use XIB or storyboard as your app to start images. The operating system will generate necessary startup images for our applications. With this feature, you no longer have to provide independent assets for starting images, but you can also design them in Interface Builder.

To set the XIB or storyboard as your application startup image, we need to select the corresponding Project in the Project Navigator and select the target from the target list. Under the General tab, select the App Icons and Launch Images option and select the correct File from the menu tag Launch Screen File.

11. Test asynchronous Testing

Multiple new APIs are added to the XCTest framework to test asynchronous code. This function is implemented through the expected object, namely XCTestExpectation. Its role is to describe the expected event. XCTestCase contains a new type of API, which always waits for the expected conditions to be met and sets the timeout time for it. When all events are executed or the timeout time is reached, the processing program is called. It should be emphasized that this API can be used for multiple asynchronous events at the same time. Now, you can more easily test the interaction between systems in asynchronous mode, such as file I/O and network requests.

Performance Detection

The enhanced XCTest framework can now quantify the performance of each component in the application. Xcode is responsible for running performance tests and allows you to define a set of benchmark performance indicators. Each subsequent test compares the benchmark performance and displays the changes that may occur over time, the problem area is highlighted to remind you of the performance degradation caused by the submitted code. If the average performance indicator differs significantly from the benchmark level, the performance test fails. For developers, it is an ideal solution for Detecting Performance Degradation of applications.

Profile Test

With the introduction of the performance testing mechanism, we now have the ability to perform profile testing in Instruments. You can select one or more test kits for the Section to further investigate and analyze the Instruments to find out why the test fails, and finally find the root cause of the performance decline.

12. Instruments

The Instruments user interface has also been updated. In the new template selection scheme, you can select your own device, target, and starting point of the profile analysis process.

We can see a brand new Counters template, which can be combined with Events to deeply explore and examine each independent CPU event. You can even specify the formulas used to measure event aggregation, ratio, and other objects.

In Xcode 6, Instruments also provides Swift support and can be used to configure Application Extensions. Instruments also provides support for simulator configuration and processes the configuration scheme as the device itself, which greatly simplifies the process startup or additional mechanism in the simulator.

Summary

Apple is constantly improving its developer tools, and this is what Xcode is committed to in every major version. Compared with the previous generation solution, Xcode 6 strives to provide developers with tools that can improve their workflows and make the entire development process smoother.

Http://code.tutsplus.com/articles/getting-up-to-speed-with-xcode-6--cms-22287

Original article title: Getting Up to Speed With Xcode 6

Nuclear cola Translation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.