Xcode creates multiple projects for collaborative development, while xcode creates multiple projects for collaborative development.

Source: Internet
Author: User

Xcode creates multiple projects for collaborative development, while xcode creates multiple projects for collaborative development.

Today, I have studied how to create multiple projects in Xcode to achieve modularization and achieve coordinated development of multiple similar projects. The most important thing is that multiple projects can be connected and edited. The project effect is as follows:

Next, create a project and communication between them.

1. Create a folder MyProject (this is my folder)

2. Create a workspace MyWorkSpace in the MyProject folder.

3. Create a project MyApp01 in MyWorkSpace and add it to MyWorkSpace.

4. Create a static library, MyAccountSDK, and add it to the MyWorkSpace workspace for joint editing.

1. Create a workspace MyWorkSpace

In Xcode, create a Workspace MyWorkSpace and put it under the MyProject folder (name it as needed), as shown in the following code: File-> New-> Workspace

,

The project after creating the workspace MyWorkSpace is as follows:

In this way, the workspace is created. Next, add the project and static library in the MyWorkSpace workspace.

2. Add the project MyApp01 under MyWorkSpace In the workspace.

In the Xcode folder of the Workspace, File-> New-> Project, and specify the Workspace for the MyWorkSpace Workspace you created, so that the MyApp01 Project is added to MyWorkSpace.

Select Single View App and enter the project name

Enter the project name. This project uses MyApp01 (the name is random), as shown in figure

Add the project to the MyWorkSpace workspace, for example:

3. you can continue to add other projects to MyWorkSpace in step 1. I will not go into details below. MyWorkSpace creates a MyApp02 project in the workspace. In this way, Xcode manages two projects, MyApp01 and MyApp02 at the same time, the effect is as follows:

 

4. Create a static library. a and add it to the MyWorkSpace workspace to implement concatenation.

The purpose of using multiple projects is not to create multiple projects, but to establish connections between multiple projects. Next we will create a static. a library named MyAccountSDK and add it to the workspace MyWorkSpace.

Select Cocoa Touch Static Library

The procedure is similar to step 1, which is not detailed here

The created project structure is as follows:

Next, create a class method in the MyAccountSDK class in MyAccountSDK

+ (Void) sayHelloWorldFromProjectName :( NSString *) projectName;

And then call this method in the MyApp01 and MyApp02 projects respectively.

In this case, import the MyAccountSDK class in ViewController of MyApp01, and call the class method + (void) sayHelloWorldFromProjectName :( NSString *) projectName. When compiling, you will find an error, prompting that the MyAccountSDK file does not exist

Solution:

At this time, you will find that an error is reported, prompting that the sayHelloWorldFromProjectName method is not found.

,

The solution is as follows:

Select the static library. a file added to the MyWorkSpace workspace, that is, libMyAccountSDK..

 

Note (you must compile a static library before running the project. a) No error will be reported, prompting xxxx. file a cannot be found. At this time, you compile the file again and run it in a miraculous way. The following is the time to witness the miracle. The running result is as follows:

 

 

Summary:

Call the class methods in the MyAccountSDK classWhen sayHelloWorldFromProjectName is used, you will find that you have forgotten to pass the parameter. If you forget the parameter, you will not be able to pass it here. Sorry, please be careful. Otherwise, you will always report an error, if the Framework is used in the project, you must configure the static library in the Framework in Build Setting-> Framework Search Path in the project. path a, for example:

 

The layout is not very beautiful. Don't like it!

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.