<IOS>How a project references another project in Xcode

How to reference the code of another project in one project, to view and edit the code of another project in the project, like the following structure:

First, right-click under the project you want to add to the project, select "Add Files To "the main project A you want to add to", find the "B.xcodeproj" file in the directory of the project B to be referenced, and directly confirm the import.

Notice:

The first time I introduced and used, I found that there was only one "B.xcodeproj" file introduced, not a structure similar to the following: The B.xcodeproj directory is the project

Since I am using the newly updated xcode9.0, I don't know if it is a version bug, and I have been unable to succeed. The final solution is to restart xcode and re-reference it, and it will be ok.

 

Introducing the project successfully The two projects are not actually related, we still need to do some additional work to help the two projects to be related:

1. The compiled file "Ba" or "B.framework" of the main project associated project B

As above, first find the targets of the main project A, and then find the link binary with libraries under the build phase

Then drag the compiled file "Ba" or "B.framework" of the imported project B (which can be found directly from the product directory under project b through Show in Finder, remember to compile project B first! Otherwise, it will be red.) Drag Drag it to the "link binary with libraries" directory.

It is ok to add dependencies in this way. Here is a note. If project B compiles the ".a" library, remember to add "header search paths" to project A to add the header file of project B. If project B It is not necessary to compile it as ".framework", because there are already header files in it

2. In this case, it seems that every time you change project B, you need to compile project B separately, and then compile project A, which is too troublesome. You can add the target dependency of project B to project A, so that every time you compile project A, by the way It is compiled with the first phase of project B, as follows

As above, first find the targets of the main project A, and then find the Target Dependencies under the build phase

Click +, find project B and add it, so that every time you compile project A, project B will also be automatically compiled

 

 

 

ok gg

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324980074&siteId=291194637