preface

See a lot of private library creation, after a lot of meandering commands, will end up with this problem ([!] An unexpected version Directory Classes). So write this article to record.

Create a remote repository

A large warehouse can choose one of them, this paper takes the code cloud as an example

Precautions for warehouse creation:

1. Before creating a warehouse, check whether the warehouse name is occupied

pod search XCTest
Copy the code

As shown above, the related library is not found, indicating that the library is not occupied, we can use this library name.

2. Create a warehouse by filling in the name and description of the warehouse

3, through the tool SourceTree in the local, if there is a branch after pulling, you can create a main branch, and enter the code cloud warehouse management page to set the default branch as main branch. If you can’t create a branch, go to step 6. (I didn’t select the branch template, so I put the branch creation in step 6. If you select the branch template, the default branch is master, you can create a main branch here.) The main branch serves as your private library index, so make it the default branch.

2. Create engineering projects

The project name is the same as the warehouse name

pod lib create XCTest
Cloning `https://github.com/CocoaPods/pod-template.git` into `XCTest`.
Configuring project template.
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

------------------------------

To get you started we need to ask a few questions, this should only take a minute.

If this is your first time we recommend running through with the guide:
 - https://guides.cocoapods.org/making/using-pod-lib-create.html
 ( hold cmd and click links to open in a browser. )
What platform do you want to use?? [ iOS / macOS ]
 >
ios
What language do you want to use?? [ Swift / ObjC ]
 >
swift
Would you like to include a demo application with your library? [ Yes / No ]
 >
yes
Which testing frameworks will you use? [ Quick / None ]
 >None

Would you like to do view based testing? [ Yes / No ]
 > No
Copy the code

After executing the above command, XCode will automatically open the project. After creating the project, do not care, close the project, copy the project to the library folder, note: if there is a hidden folder, do not copy. Git folder

Configure podSpec files

Go to the folder you just copied and open the Example project as follows

Important configurations are as follows

Epage = remote repository s.source = remote repository git address s.wift_version = '4.0'Copy the code

Modify other configurations based on actual requirements

Four, validation,

Open the terminal CD to the repository directory.

Pod lib lint - allow - warnings - > XCTest (1.0.0) - WARN | The summary: The summary is not meaningful. - WARN | url: There was a problem validating the URL https://gitee.com/xxxx/xxxx. - WARN | [iOS] swift: The validator used Swift '4.0' by default because no Swift version was specified. To specify a Swift version during validation, add the `swift_versions` attribute in your podspec. Note that usage of a `.swift-version` file is now deprecated. - NOTE  | xcodebuild: note: Using new build system - NOTE | xcodebuild: note: Building targets in parallel - NOTE | xcodebuild: note: Using codesigning identity override: - - NOTE | [iOS] xcodebuild: note: Planning build - NOTE | [iOS] xcodebuild: note: Constructing build description - NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App') XCTest passed validation.Copy the code

Authentication is successful

Upload the code to the warehouse

1, Here is not much description, focus on the tag, focus on the tag, important dozen things say three pieces. The tag is consistent with the version of the configuration file

2. Remote authentication

Pod spec lint - allow - warnings - > XCTest (1.0.0) - WARN | The summary: The summary is not meaningful. - NOTE | url: The URL (https://gitee.com/xxxx/xxxx) is not reachable. - WARN | [iOS] swift: The validator used Swift '4.0' by default because no Swift version was specified. To specify a Swift version during validation, add the `swift_versions` attribute in your podspec. Note that usage of a `.swift-version` file is now deprecated. - NOTE  | xcodebuild: note: Using new build system - NOTE | xcodebuild: note: Building targets in parallel - NOTE | xcodebuild: note: Using codesigning identity override: - - NOTE | [iOS] xcodebuild: note: Planning build - NOTE | [iOS] xcodebuild: note: Constructing build description - NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App') Analyzed 1 podspec. XCTest.podspec passed validation.Copy the code

Create a branch

1. Since I created the warehouse differently, there was no branch when I pulled down the library, so only the README file was kept inside the main branch, and the rest were deleted. Submit to codebase, do not merge to master, do not merge to master, submit to codebase, do not merge to master, three important things. And then you don’t have to deal with the main branch.

2, enter the code cloud warehouse management page to set the default branch as the main branch, the default branch is very important, the default branch is very important, the default branch is very important say three pieces

Add the remote private index library (Repo) to the local

pod repo add XCTest https://gitee.com/xxxx/xxxx.git
Copy the code

After the command is executed, access ~/. Cocoapods /repos and view the following file structure

Commit to remote private index library

Pod repo push XCTest XCTest. Podspec -- -- allow - warnings Validating the spec - > XCTest (1.0.0) - WARN | the summary: The summary is not meaningful. - NOTE | url: The URL (https://gitee.com/xxxx/xxxx) is not reachable. - WARN | [iOS] swift: The validator used Swift '4.0' by default because no Swift version was specified. To specify a Swift version during validation, add the `swift_versions` attribute in your podspec. Note that usage of a `.swift-version` file is now deprecated. - NOTE  | xcodebuild: note: Using new build system - NOTE | xcodebuild: note: Building targets in parallel - NOTE | xcodebuild: note: Using codesigning identity override: - - NOTE | [iOS] xcodebuild: note: Planning build - NOTE | [iOS] xcodebuild: note: Constructing build description - NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App') Updating the `XCTest' repo Adding the spec to the `XCTest' repo - [Add] XCTest (1.0.0) Pushing the 'XCTest' repoCopy the code

Nine. The last miracle moment

Search the library name again

Pod search XCTest -> XCTest (1.0.0) A short description of xctest. pod 'XCTest', '~> 1.0.0' - Homepage: https://gitee.com/xxxx/xxx - the Source: https://gitee.com/xxxx/xxx.git - Versions: 1.0.0 [XCTest repo]Copy the code

Now that your desired private library has been created, configure any project in your Podfile as follows:

The source 'https://gitee.com/xxxx/xxx.git' platform: ios, '9.0' target 'Test' do pod 'XCTest' endCopy the code

Enter the project and execute the command

Pod install or pod install --repo-updateCopy the code

You are ready to use your private library in your project. The next article will learn about files, the use of resource files, and version updates