iOS的开发工具介绍

 

本文目录:

  • 一、前期的准备
  • 二、Xcode
  • 三、Interface Builder
  • 四、Instruments

     说明:这个专题是苹果官方文档的翻译。直接学习官方的文档要比看一些开

发的书籍要快很多。特别是苹果最新的技术,都是官网首先进行介绍的。

 

 

一、前期的准备                                                                                       

 

To develop applications for iPhone OS, you need a Mac OS X computer running the Xcode tools. Xcode is Apple's suite of development tools that provide support for project management, code editing, building executables, source-level debugging, source-code repository management, performance tuning, and much more. At the center of this suite is the Xcode application itself, which provides the basic source-code development environment. Xcode is not the only tool you use though, and the following sections provide an introduction to the applications you use to create iPhone applications.


(为了开发基于iPhone OS的应用程序,您需要一台Mac OS X操作系统的计算机,并且安装了Xcode tools开发工具。Xcode是Apple开发工具套件中的一个,它提供了项目管理,代码编辑,编译可执行文件,源代码调试,代码库管理,性能查看等工具。工具套件的中心是Xcode这个应用程序,它提供了基本的源代码开发环境,Xcode不是您唯一使用的开发工具,下面介绍一些其它的应用程序用来创建iPhone应用程序。)

二、Xcode                               


 

The focus of your development experiences is the Xcode application. Xcode is an integrated development environment (IDE) that provides all of the tools you need to create and manage your iPhone projects and source files, build your code into an executable, and run and debug your code either in iPhone simulator or on a device.


(首先要关注的是Xcode应用程序,Xcode是一个集成开发环境【IDE】它提供了您开发iPhone项目的所有源代码的创建和管理,编译您的代码为可执行文件,运行调试您的代码,还有在在iPhone模拟器上运行或者是直接在设备上运行。)


To create a new iPhone application, you start by creating a new project in Xcode. A project manages all of the information associated with your application, including the source files, build settings, and rules needed to put all of the pieces together. The heart of every Xcode project is the project window, shown in Figure 1.This window provides quick access to all of the key elements of your application. The Groups and Files list is where you manage the files in your project, including your source files and the build targets that are created from those source files. The toolbar provides access to commonly used tools and commands while the details pane provides a configurable space for working on your project. Other aspects of the project window provide you with contextual information about your project.

 

(创建一个新的iPhone应用程序,您可以从Xcode的创建新项目开始。一个项目管理了应用程序所有的信息,包含源代码,工程设置,和把所有整合到一起的(编译)规则。每一个Xcode项目的核心是项目窗口,在下面的图1中展现了。这个窗口可以让您快速访问所有应用程序的关键元素。Groups和Files列表是用来管理您的项目文件,包括了您的源代码文件,还有根据源文件编译成的目标文件。工具栏提供了常用的工具和命令,详细资料面板用来设置您的项目的工作区域。其它的一些项目窗口为您提供项目的前後关系。)


Figure 1 An Xcode project window


(图1 一个Xcode项目窗口)

 

project_window.png

 

 

Xcode comes with an advanced text editor, which supports features such as code completion, syntax coloring, code folding (to hide code blocks temporarily), and inline annotations for errors, warnings, and notes. The build system in Xcode provides both appropriate default settings and the ability to configure the environment to your heart's content. And if you need documentation, the Research Assistant provides context-sensitive documentation while the Xcode documentation window lets you browse and search for information.


(Xcode有一个先进的文本编辑器,它提供了入代码补全,语法高亮,代码折叠【临时的影隐藏代码】,还有内置注释的错误,警告和说明。在Xcode环境中提供了一些默认的设置您可以根据您心中想要的环境进行设置。并且如果您需要文档,Xcode的搜索助手(此处补上快捷键)提供了上下文敏感的文件,同时您可以在帮助文档(此处补上快捷键)的窗口中浏览和搜索信息。)


When you build your application in Xcode, you have a choice of building it for iPhone simulator or for a device. The simulator provides a local environment for testing your applications to make sure they behave essentially the way you want. After you are satisfied with your application's basic behavior, you can tell Xcode to build it and run it on an iPhone or iPod touch connected to your computer. Running on a device provides the ultimate test environment, and Xcode lets you attach the built-in debugger to the code running on the device.


(当您在Xcode中创建您的应用程序的时候,您可以在编译的时候选择为iPhone模拟器还是为设备。模拟器提供了一个本地的环境测试您的应用程序,以确保它们的行为基本上是您想要的方式。当您基本满意後可以用Xcode编译并运行到与您计算机相链接的iPhone或者iPod touch上。在真机上的运行提供了最全面的测试环境,Xcode让您可以在真机测试时用内置的调试器跟进代码。)


Figure 2 Running a project from Xcode


(图2 在Xcode中运行项目)

simulator.jpg

 

For details on how to build and run your project on iPhone OS, see Development Environment in iPhone OS Programming Guide


(有关如何在iPhone OS上运行和创建您的项目请看iPhone OS Programming Guide。)

 

三、Interface Builder                                                                           


Interface Builder is the tool you use to assemble your application's user interface visually. Using Interface Builder, you assemble your application's window by dragging and dropping preconfigured components onto it. The components include standard system controls such as switches, text fields, and buttons, and also custom views to represent the views your application provides. After you've placed the components on the window's surface, you can position them by dragging them around, configure their attributes using the inspector, and establish the relationships between those objects and your code. When your interface looks the way you want it, you save the contents to a nib file, which is a custom resource file format.


(Interface Builder 是用来组织创建应用程序的可视部分(用户图形界面)。使用Interface Builder您可以拖放一些定义好的组件到您的应用程序窗口中。这些组件包含了标准的系统控制比如开关,文本框,按钮和其它一些自定的视图,通过它们您可以用来展现您应用程序中的界面。然後您可以把它们放到window对象这个平面中,您可以在窗口中拖放它们,通过Inspector(在IB中快捷键command + 1)设置它们的属性,并且建立它们和您的应用程序对象的连接。当您完成了创建视图後您将会用nib(Mac OS工程为.nib,iPhone工程为.xib)文件的形式保存起来。)


Figure 3 Designing your interface with Interface Builder


(图 3 在Interface Builder中设计您的界面)

 

interface_builder.jpg

 

 

 

The nib files you create in Interface Builder contain all the information that the UI Kit needs to recreate the same objects in your application at runtime. Loading a nib file creates runtime versions of all the objects stored in the file, configuring them exactly as they were in Interface Builder. It also uses the connection information you specified to establish connections between the newly created objects and any existing objects in your application. These connections provide your code with pointers to the nib-file objects and also provide the information the objects themselves need to communicate user actions to your code.


(UIKit需要您在Interface Builder中创建的所有nib文件的信息为其在运行时重建相同的对象。在运行时加载nib文件创建它们的运行时版本,设置它们的属性让它们看起来和您在Interface Builder中一样。它同样使用连接点的方法在您的新建对象和您的应用程序中的其它任何对象之间建立关系。这写连接的对象可以让您的代码和nib文件的对象链接起来,同时也提供了用户命令动作对象的连接。)


Overall, using Interface Builder saves a tremendous amount of time when it comes to creating your application's user interface. Interface Builder eliminates the custom code needed to create, configure, and position the objects that make up your interface. Because it is a visual editor, you get to see exactly what your interface will look like at runtime.


(总的来说,在您创建您的应用程序图形用户界面的时候使用Interface Builder节约了您大量的时间。Interface Builder让您摆脱了自己编写代码去创建,设置,定位那些界面对象。因为它是一个可视的编辑器,您可以在运行时清楚的看到界面效果。)


For information on how to use Interface Builder, see Interface Builder User Guide.


(更多有关如何使用Interface Builder的信息请参考Interface Builder User Guide。)

 

四、Instruments                                                                                  


To ensure that you deliver the best user experience for your software, the Instruments environment lets you analyze the performance of your iPhone applications while running in the simulator or on a device. Instruments gathers data from your running application and presents that data in a graphical display called the timeline. You can gather data about your application's memory usage, disk activity, network activity, and graphics performance. The timeline view can display all of the different types of information side by side, letting you correlate the overall behavior of your application, not just the behavior in one specific area. To get even more detailed information, you can also view the detailed samples that Instruments gathers.


(为了确保您为自己的软件提供最佳的用户体验,Instruments环境可以让您分析当您的iPhone应用程程序在虚拟环境或者真实设备上运行时候的表现。Instruments将会用时间轴图表的形式表现您运行应用程序时的数据,开销。您可以看到您应用程序的内存消耗,磁盘活动,网络活动,和图形表现。时间轴的视图可以一一的展现不同的类型的应用程序系统信息,可以让您方便的收集应用程序的全部行为,而不是在一个特定区域的行为。为了得到更详细的信息,您同时可以查看Instruments详细例子。)

 

Figure 4 Using Instruments to tune your application


(图4 使用Instruments来调试您的应用程序。)

 

Instruments.jpg

 

 

In addition to providing the timeline view, Instruments provides tools to help you analyze your application's behavior over time. For example, the Instruments window lets you store data from multiple runs so that you can see whether your application's behavior is actually improving or whether it still needs work. You can save the data from these runs in an Instruments document and open them at any time.


(除了时间轴视图外,Instruments同样提供了工具来帮助您在运行时候查看应用程序的行为。举个例子,Instruments窗口可以保存多个运行时候的数据,让您看见您的应用程序的行为那些需要改进或者那些需要重新编写,您可以在任何时间打开您保存在Instruments文档中的数据。)


For details on how to use Instruments with iPhone applications, see iPhone Development Guide.For general information on how to use Instruments, see Instruments User Guide.


(查看详细的资料有关使用Instruments您可以查看iPhone Development Guide。一些使用Instruments的普通的方法可以查看Instruments User Guide。)

 

 

 

 

 

 

 

posted @ 2013-07-20 14:26  骑白马的唐僧  阅读(200)  评论(0编辑  收藏  举报