If you're doing app development under OS X or IOS , I believe Xcode Development tools http://www.maiziedu.com/course/234/ We are familiar with the IDE , there is a sentence to say: 工欲善其事, its prerequisite. Well, I think it is necessary to understand Xcode 's project management thinking throughout the project development process, but in the actual work process, I find that many people neglect this piece.
Therefore, this article with everyone's most familiar object-oriented thinking to analyze the project management of Xcode, hope to let everyone know it, better know its why, and can apply it to their own actual project management.
Abstract level
As a programmer, what do you think you are best at? Logic? Algorithm? Or a data structure? It's definitely not cooking anyway. I think even if you are not good at what I said, you can still be a good programmer if you have enough "abstract" ability.
Everything can be used to abstract the object-oriented thinking, Xcode nature is no exception, we are only from the perspective of project management to extract its abstraction, in addition, from the UI level can also extract a set of abstractions, but this is not the focus of this article. Here is the abstract class diagram we extracted:
This kind of diagram is believed to be familiar to everyone at one glance, all of which we often encounter when using Xcode, just to get their relationship together. Now that we have extracted it into a class, each class should have its responsibilities, and here's how it's divided:
Workspace
This is the topmost class and can be designed as a singleton, as there will only be one in the entire Xcode life cycle. Workspace, as the name implies, is the workspace, which aggregates multiple project Internals tomanage dependencies between project and project .
Project
A single project, as a project, has a certain degree of independence, such as two app items that can be placed in a workspace . Project is primarily an abstraction at the item level, where the critical point is the reuse level,and project and project are generally not reusable to the source file hierarchy.
Configuration
Each project can correspond to multipleconfigurations, which are configuration information used in the process of pre-processing, compiling, linking, and so on.
Scheme
Each project can also correspond to multiple scheme, different from the configuration Focus,scheme focuses on project in the final compilation, run, Some option configuration information for testing, archiving, and so on, it can decide what configuration to use at each link .
Target
< Span style= "FONT-FAMILY:CALIBRI;" > each project can also have a plurality of target target target represents the final output of a project, which inherits the project configuration information. target and target project and project target and target
In the actual operation, we often need to clearly define when to create new project, when to create a target, because most of the time, they are still relatively similar. However, consider the role of target, considering that it is inheriting projectand considering its reuse level, it should still be well-divided.
Dependency Management
Here's an abstraction of Xcode project management, and then we'll look at Xcode 's management of dependencies between them. Here I think there are two kinds of dependence: strong dependence , weak dependence . Strong dependency refers to the dependency between target and target, and weak dependency refers to the dependency of Project and project ( haha, I created two more nouns). In the project configuration interface, select the target in a project andselect Build Phases , we can see the following interface:
There are two red arrows especially eye-catching, the first arrow pointing to Target Dependencies , is what I call a strong dependency, here you can select a target as the current target dependency, which will ensure that the dependent Target must be compiled before the current target .
< Span style= "FONT-FAMILY:CALIBRI;" > So what is the weak dependency? You guessed right, is the second Red Arrow refers to the place: link Binary with Libraries Here we can choose to go to other project framework project target Xcode project target at current target before compiling.
What is the use of reliance? Dependencies are useful when you maintain a project hierarchically, such as a data access layer library, a logical layer library, a public auxiliary library, and a final application. The order of compilation between them may need to be very explicit, which requires a focus on dependencies.
operation Principle of Cocoa Pods
Slightly larger items, or we want to easily use the third-party open Source Library, may choose Cocoapods, with the basic knowledge of the groundwork, and then look at The cocoapods operation principle is not so complicated.
First Cocoapodsin theWorkspacethe new set up aProjectcalledPods, whenever we introduce a third-party library, thisProjectthere will be one more.Target, the type is a static library. ThisProjectthere is a fixedTargetcalledPods, the type is also a static library, which can be seen asPodsthisProjectthe defaultTarget, it relies strongly on all otherTarget, but it does not link otherTarget, in order to make thisTargetto compile normally, there is only one empty class implementation inside it:Pods-dummy.
< Span style= "FONT-FAMILY:CALIBRI;" > So if you want to compile pods this target target
configuraion written in a different .xcconfig configuration podfile Target main application pods this target< Span style= "font-family: the song Body;" > that is, a file called libpods.a pods-dummy .xcconfig Other_ldflags This key configuration information.
The above describes the core operating principles of cocoapods, and some of the details are based on such a model, do not make too much detailed explanation. Therefore,Cocoapods can ultimately provide such project management capabilities:
Different project can specify links to different or identical third-party libraries
Different target can specify links to different or identical third-party libraries
Different target can specify different configuration
Different configuration( Debug,Release,Custom ) can specify links to different or identical third-party libraries
From the project management point of view, Cocoapods is still very good to keep Xcode project management flexibility, and mostly through the. Xcconfig file to achieve, not intrusive, or very worthwhile to use.
Do it yourself.
This article is almost here, so let's leave a little experiment:
1. build two project in one workspace, one appand one static library.
2.Theapp creates a new configuration called inhouse.
3. require the app to link and use the static library only under the inhouse configuration.
Hint: the static library project also needs to build a inhouse configuration Oh, otherwise if the dependency is not built up.
Well, whether you want to try it yourself or not, you should be happy to play with the Xcode configuration item.
Original from: Sun.makee
How to easily understand Xcode project management