iOS Project--project development Environment Building Summary

Source: Internet
Author: User
Tags home screen

iOS Project--Construction of project development environment 

Before we develop the project, we need to do some preparatory work to understand that iOS extension--OBJECTIVE-C Development Programming specification is a necessary foundation for development, Learning iOS learning--xcode9 uploading projects to GitHub is one of our options for versioning and code management, understanding iOS Learning --ios Project and targets configuration details are more conducive to our full project development environment today, which in the previous blog has been some summary and steps, detailed information can be stamped links to view.

Develop a complete app that is different from what we usually do when we are learning and practicing, and then writing our sample code is done. To develop a complete app. There is a certain development process, and generally, in the development process we are multi-person cooperation, each person is responsible for a part of the development of functional modules, the final merger, commissioning, testing, on-line and other processes. Then at the beginning of the project development, we need to build the development environment of our app, at the start of an app development, the environment construction mainly includes the following parts.

1 Modify the app name that appears after the app is installed

When we initially created the project, the name of the app is the same as our project name by default, in general, our project naming is not Chinese, so basically the app name and our project name is different, so at the beginning of the project, the name of the app needs to be modified to determine good. There are currently three places to directly modify the app display name, the three local modifier in one, the other two will be automatically modified, the specific operation as shown.

2 Setting the prefix of the class name

In the project development process, we generally need to add a prefix to all classes in the project to distinguish whether we create or third-party or the system comes with the class, the prefix is custom, generally set to the initials or initials of the company name, personal development can be set, set the interface as shown.

In addition to setting our class name prefix, there are additional two options for setting up:

    • One is the text setting option in the lower right corner, as we mentioned in the iOS extension--OBJECTIVE-C Development Programming specification, iOS development recommends using spaces for indentation and segmentation, instead of using tab indentation, which is what the TAB key represents, and indents 4 of spaces. Indent indicates that the amount of indentation in the next line is also 4 spaces.

    • The other is the setting of the Organization (organization), the effect of this setting is to indicate that the software copyright belongs to, in our project each class has a class description comment, as shown, here the organization's setting shows that the program's copyright belongs to. In general, this is set to the company name, can be Chinese, of course, can also be customized, this default is the name of their own computer.

3 Adjusting App Orientation

Generally speaking, the direction of our application software is vertical screen (except the game, the general game is horizontal screen), so we can start the project before the development of the device type, the direction of the screen to determine, which is also convenient for us to apply the icon and start the image of the cut and settings, screen direction of the setting interface as shown.

This section contains some of the details of the iOS Learning--ios project and targets configuration, mainly by setting the target's deployment properties to set the app to some status on the phone. From what we can see:

    • The equipment direction has four direction to choose, generally speaking, we choose the vertical screen to be possible, except special function app.

    • We can also set whether our device type is iphone or ipad or both universal.

    • The style of the status bar has two styles to choose from, depending on the situation. Of course, if you need to hide the status bar, we can also set it up in code as needed in the development process.

    • You can set whether you want to hide the status bar, or if you need full screen settings.

For example, in the development of a game like King Glory here are several options should be the device type selection universal, device direction is Zoo + right horizontal screen, check the hidden status bar, colleagues also check the need for full screen.

4 Set app icon and start picture

How to set the Y8ingyong icon and launch image we've talked about it in detail in the iOS Learning--ios project and targets configuration. Setting the interface as shown, this section of the main Settings app icon and launch interface, where the boot interface has two settings: by setting the boot image or by setting the boot screen file to start, the boot icon and the start interface to face different models of the device needs to be different sizes, The specific application icon and the size of the launch page are described in the official website: Human Interface guidelines.

App icon Source: The icon in AppIcon that corresponds to the file resource Assets.xcassets directory, as shown in. The right-most panel can choose which device or devices you want to add, and the size of the icons on each device is different, depending on the size of the icon, see Human Interface guidelines. In the middle there are a small lattice, we will all the cut icon directly to drag, they will automatically find themselves should be placed in the grid. These small squares are divided into four main categories:

    • Notification: When the notification icon, similar to the app-related push message, sometimes need to display the app's icon will show this size

    • Spotlight: Search for small icons, when the app name is entered in the Spotlight, the icon for the app appears in the search results is this size, and the icon in the settings is also this size.

    • App: This is the normal app icon, which is displayed on the desktop after it is installed, or the app that is displayed when you share the recommendation is also the icon of this size

    • App Store: Icons displayed in the App Store

Luanch image Source (boot image) and Luanch screen file (startup page files) are all used to set up our start-up interface. First of all, you might be wondering why it's annoying to have some startup pictures or ads or graphics on every app launch? But it is necessary to start a picture for two reasons.

    • First, through the launch of the image set up the application of our app at the start of the interface to display information, if not set the launch screen, our app will be opened after the black screen of the development of the app is not working properly. If the start picture is a iPhone6 screen-sized picture, only the IPhone6 screen size area is displayed on iphone x, and there are two black edges up and down. Therefore, when we set the start-up interface, it is usually necessary to adapt to the various screen size of the boot image. As shown in the interface you can see that setting Luanch image Source (boot picture) is available in multiple sizes.

    • Secondly, when we launch the app by clicking on the app icon, it takes some time for the app to start, and during startup, you should provide a boot image to enhance the user experience when the application starts. The boot image looks very similar to the application's first screen. When the user taps your app icon on the home screen, IPhone OS immediately displays the boot image. Once you're ready, your application will display its first screen to replace the boot placeholder image. It is important to emphasize that the boot image is provided to improve the user experience and not to provide: An application entry experience, such as starting an animation.

As we've just said, Luanch image Source (boot image) and Luanch screen file (Launch page files) are all used to set up our start-up interface, so what's the difference between them?

    • Luanch Image Source (start picture): Also corresponds to the file resources Assets.xcassets directory in the luanchimage in the picture, set the various circumstances of the start picture, the specific interface as shown, and AppIcon, we will all cut the icon directly, they will automatically find themselves should be placed in the lattice You can also select the device and the start diagram in different directions.

    • Luanch screen file (startup pagefile): is a Luanchscreen.storyboard file that is used as the start-up interface.

The main difference between the two methods is that the boot file priority is higher than the boot image, that is, if two are set, then the Start page to start the file, if not set, the app will be black screen.

In the general development of the project, we generally only use the startup image to set the start-up interface (now because the storyboard application is more, there are a lot of ways to set up the startup file to set the start-up interface, you can set according to their own needs and habits), Since the boot file has a higher priority than the boot image, we need to delete the file name after the start-up. In addition, we also need to delete the Luanchscreen.storyboard file in the project, because the app will automatically find the Luanchscreen.storyboard file to load when it starts up, so we need to do these two steps, as shown in.

5 Setting the main interface (obsolete storyboard)

When you create a new project, Xcode defaults to the main interface of the app via Main.storyboard, and the way to set up the main interface is another way to set it up in code. So how does the system determine how we set up the main interface? This problem involves a part of the startup process.

We all know that the start of the project is the main function, in our iOS project is no exception, we can see that there is a MAIN.M main function in the project, there is only one method is our main method, the code is as follows, very simple.

12345 # import  # import   "AppDelegate.h" int  main ( int  argc, char * argv[])  {      @autoreleasepool  {          return  uiapplicationmain (argc, argv,  Nil, nsstringfromclass ([appdelegate  class     

}

The main function is the following four points, the last point tells us how the system chose us to set the main interface.

    • Create a Application Object

    • Creates a Appdelegate object and sets the Proxy property to be the Application object

    • Open the main loop to keep the program running.

    • Load Info.plist file, determine if there is main.storyboard in the Info.plist file, if there is, to load main.storyboard, if there is no main.storyboard, then determine whether the project itself created the main interface, if they do not create their own If the controller is built, the program cannot start.

In the actual project development process, generally we are using a pure code framework, and will not use storyboard to build our app, because the project inevitably involves a lot of interfaces and jumps between each other, with storyboard control logic will appear very chaotic, And we are generally multi-person cooperation in the development of a project, with storyboard can not be a multi-person collaboration way. Therefore, the manual setting of the main interface needs to be divided into two steps:

    • One is abandoned storyboard, this step is divided into two small steps: Delete the Main.storyboard file, delete the Info.plist in the main interface setting options, as shown in.

    • Create your own main interface, this needs to be done in our appdelegate, the code is as follows:

1234567891011 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    //初始化当前window并设置其大小    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    ViewController *viewController = [[ViewController alloc] init];      //设置当前window的主控制器    self.window.rootViewController = viewController;      //设置主界面并显示    [self.window makeKeyAndVisible];      returnYES;}

6 Building the directory structure

For a more complex project, we will certainly not be able to put all the files in a folder directory directly in the development process, we need to set up a directory structure for its hierarchical and structured management, so that we can quickly locate a problem in the function module. For the project directory structure, there is no unified specification, is mainly convenient for our team to differentiate our project module.

Here are the two recommended ways to build a directory:

    • One is to completely separate the model and Viewcontroller, see: iOS Development Summary-project directory structure, the framework is as follows:

Project directory

├──thirdlib (three-party library)

│├──sdwebimage

│└──afnetworking

├──framework (self-encapsulated class library)

├──general (General class directory)

│├──class (generic classes, such as custom parent classes)

│└──helper (General helper method)

├──main (Single entry of the program, only appdelegate distinguish other files)

│├──appdelegate.h

│└──appdelegate.m

├──model (Data Model class directory)

│├──MACRO (macro definition directory)

│├──BLL (Business Logic Layer directory)

│├──dal (Data Access layer directory)

│├──entity (custom entity directory)

│├──request (Network request class directory)

│├──location (Location service class directory)

│└──socket (Socket class directory)

├──module (Functional module catalog)

││

│├───modulea

││├──viewcontrollera.h (View controller header file)

││└──VIEWCONTROLLERA.M (View controller m file)

│├──moduleb

│├──modulec

│├──moduled

│└──modulee

└──view (view class directory)

└──mytestview

    • Second, according to the functional module, see Iosapp Development project construction, for example, personal comparison recommended this one, and then in modules each function module can be divided into (model, resource, view, controller), so the distinction is more complete, The public model or view can be placed inside the base.

iOS Project--project development Environment Building Summary

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.