< I > Preparations:

Make sure you have Github desktop installed on your client and log in, using your Github account from the web. Prepare the SDK files you need to upload. Open terminal ready to start.

< II > Detailed process:

The purpose of the 1.0 SDK is to meet the needs of others to help others or their own development projects can be improved better and faster through effective third parties. Therefore, after completing the compilation of the core code, in accordance with the more reasonable way of operation, it is necessary for you to write a Demo to show the core of your SDK, the main role, to help others better understand and learn it. So, if you have completed this step at this point, the skeleton structure of the Demo file should look like the following:




Create a Demo

2.0 can put the files away for a while and move on to the actual creation of the Github repository and the association with Cocoapods. The initial process was more of a repetition of uploading and managing your own projects on Github. Go to the Github homepage, click Repositories and then click New to enter the Repository creation interface:




The edit page for the warehouse is displayed

※ For convenience and general structure, you need to ensure that the Repository name is consistent with the.podspec file name and the name of your core file:




Edit the warehouse

Click Clone or Download “Open in Desktop” on the upper right to download the entire repository to Github Desktop and Open it:




The initial state

5.0 As shown in the figure below, you have two files,1️ discount on the Demo you put on before; 2️ discount you are newly created and downloaded, and will be the final submission of YourSDK. Next, you need to merge the two files, essentially dragging the theme part of the Demo file manually into the new YourSDK file:




Download to your desktop and open it

In the original Demo, the core folder was called YourSDKFiles. When I dragged it to YourSDK, I changed it to YourSDK YourSDKFiles still exist, but the contents are not displayed, so in this case, reopen the Demo file and re-import the core YourSDK file.




2 for one

7.0 Now that you are ready, upload your new SDK to Github and asynchronously update it. On the uncommitted screen, please note that either Summary or Description must be written. After clicking Commit, click Sync Asynchronous update:




Submit and update

8.0 After submission, return to the web page and refresh to obtain the latest warehouse appearance, as shown in the picture below:




Refresh the page

In fact, the above steps are the steps I described in the previous section to upload and manage your own projects on Github, so the next steps are the key to truly associating your repository with Cocoapods.

A. Podspec file is the key to associating a repository with Cocoapods. The key to associating a repository with Cocoapods is a.Podspec file.

So, everything that follows is basically around the.podspec file:




Discover the core

Take a look at this file and click on it to open someone else’s.podSpec file (I clicked on it in the MJRefresh framework) to see what’s inside.

Notice ->1️ discount, the content in the first line is the same as per PodSpec file, look down, S. name. this is the SDK name I mentioned above to be consistent with the Repository name.

Note ->2️ IN the following operation, I will directly copy someone else’s PodSpec file and modify it appropriately according to my own content. However, from a terminal, you can also create with instructions:

pod spec create YourSDK.podspec

Modify it with the following instructions, which will be mentioned later:

vi  YourSDK.podspec




Know pod spec

11.0 Keep the name of the podSpec consistent with that of the entire file and the core file. CD the file in the terminal, locate it, and perform the following operations to add it to the podSpec file:

vi  YourSDK.podspec




Create podspec

12.0 Once you have entered the main PodSpec screen, click I (INSERT) on the keyboard as shown below to start deleting or typing it. Naming, version number, summary, description, web address, certificate, platform, author information, source address, resource file, ARC selection, etc. Modify and fill in according to the actual situation.

Note that -> if created on a terminal, there are more options available, more content, and a lot of things don’t help much with what we’re looking for, just keep it simple.

After the modification is complete and correct, press Esc, then enter :w to save, :q to exit:




Edit podspec

13.0 After saving and exiting, the first thing to do is tag and push the tag to Github. Through the following four steps:

Git tag ‘0.0.1’

git add *

git commit -m ‘add tag’

Git push origin 0.0.1




tagged

14.0 Next, after you’ve created your PodSpec and tagged Github, you can push the repository to Cocoapods as a branch.

The following operations ->1️ comparison and verification of the label on and podSpec label are carried out by the following instructions:

pod lib lint

If successful, a message with the following structure is returned:

– > YourSDK (0.0.1)

2️ implement pod Trunk push command in the figure below, and really implement branch push operation. When it says it has been pushed, the pushed item has been pushed successfully.

3️ return to webpage interface and refresh the warehouse. Click on Brand: Master, then go to Tags and click, and you’ll find the tag number you typed.




Push the branch

15.0 Return to the TERMINAL and run the following command

pod search YourSDK

As shown below, you have successfully associated your SDK with Cocoapods.




Search visibility

< 3 > Common errors:

In this operation, there are some pits, and these pits are concentrated in the pod Trunk push branch. Next, I will I encountered some common pit to fill in for you, there are not weeks, hope you correct.

1.0 Error 1️ discount: Core file is not properly matched

– ERROR | [iOS] file patterns: The `source_files` pattern did not match any file.

1️ discount: manual import




Manually importing files

2.0 Error 2️ disqualification due to warning

YourSDK did not pass validation ,due to 1 wanrings (but you can use –allow-warnings to ignore them)

Solve 2️ one: re-execute the following instructions

pod trunk push YourSDK.podspec  –allow-warnings

< iv > Supplement:

The whole process is actually relatively easy to understand, just take a copy of Github to Cocoapods hosting, the key and the difficulty is in the connection part. However, this process requires you to have a good understanding of the file structure on Github, and you need to be familiar with the Github Desktop.

At the same time, it must be noted that this process in Cocoapods or Github, as well as terminal operation, the use of things is actually very limited, usually need to accumulate, observation and summary.

If you can use a management tool to effectively manage and guide your work or study results, it will be of great benefit to your later work and study, and many operations will get twice the result with half the effort.

All of you!