IOS uses. xcworkspace File management code and Engineering Dependencies (implementing Project Modularity)

Source: Internet
Author: User

First, create the Xcworkspace file.

After the cocoapods is installed, there will be one more file in the project file with the suffix. Xcworkspace. Opening this file would quite open up the project that was originally created. Then this file is used to manage the project, which contains the project you created and the Cocoapods project.

If you create a. xcworkspace file manually, it is simple. Open Xcode and click File, new, workspace.

Create workspace Two, add files to. xcworkspace

After the creation, open, and now there is no project, it is necessary to add the project. There are many ways to add, you can drag the previous project file back into the. xcodeproj file directly, or you can right-click Add files to "Xxxx.xcworkspace" and select the file you want to add.

Add Project to Workspace

or create a new project, select the location you just created the. workspace file where you chose the storage path.

Automatically add to workspace file

This allows you to add more than one file to manage multiple projects. The operation is also the direct operation of other projects in the document.

III. Building Engineering Dependencies (modular)

If your project in the previous design pattern is MVC, in a project there must be a lot of files and sub-files to distinguish that file represents that module code. Then modularity is to turn these files into a project where you just run a project to invoke code from other projects. The first step is to create a sub-project and create a framework project file.

Create a framework file

The. xcworkspace file directory is also selected when the path is stored.

Create a good file

Everyone should know that the role of the framework file is to encapsulate the class that can be put into other projects for use. But it cannot be modified directly, and the code inside the framework cannot be seen externally. Building engineering dependencies is the way to implement a modular project framework. Here's how to bring the frame into the project. Click on the project file to enter targets->build phases, Link binary with Libraries to add the framework library file.

Add Framework

In the first folder of the page where the file is added, there is a previously created framework file, which is just a good choice.

Select the Framework file

This adds the creation of the framework file to the first project. Now we add a file in the framework file that inherits from NSObject. Write a "SayHello" method in it.

Creating classes inside the framework

After creating the method is to write the header file of this class into the "header" file. No files generated at run time cannot be referenced. When you open the framework, you will find only one. h file, which is the "header" file that imports the header file of the class you just created.

Write the file you want to refer to in the header file.

Although the header file has been added but can not be referenced, if the project to use this class, at compile time will not find the file, because there is one less step. Click on the Framework engineering selection targets->build phases-Headers opened and found pubilc,pravte,project three items, drag files from project to PUBILC. So it's done. Now go to the first project and refer to the class you just created to execute the "SayHello" method.

Call the ' SayHello ' method

It's all over now. There are two workarounds for information that runs and crashes.

Four, solve the phenomenon of run-time crash.

See if the status option after introducing the framework file in the project is required or optional

If it is required, replace it with optional or set the type of library file in the framework file.

Select the framework type

In this type of selection on the required corresponds to the dynamic Library optional corresponding to the static libary select Good to run on it.

It's all over.

This is for beginners to see, the great God if there is any correction, welcome to comment on the Mi-da!



Out of print know lazy kids
Links: https://www.jianshu.com/p/4a0841618726
Source: Pinterest
The copyright of the book is owned by the author, and any form of reprint should be contacted by the author for authorization and attribution.

IOS uses. xcworkspace files to manage code and engineering dependencies (implementing Project modularity)

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.