On the first dry

Create remote private libraries

Go to GitLab to create a remote private library, this process is not described, if you need to create a sample project later, there is no need to create a Readme file. It is recommended to create an example file and fix the problem first after configuration and compilation, otherwise pod Spec Lint will cause a lot of problems later

Add a local REPO

Pod repo add XXXCopy the code

Add the XXX remote library to the local repo and you can see the official specs:trunk and the newly added specs: XXX in the /.cocoapods/repos/ directory

Creating a local repository

Pod lib create XXX (local project name)Copy the code

I download a sample code from Cocoapods. There are a few steps to answer:

IOS (development platform) /Objc (code language) /Yes (whether to create demo project,advice) /None (whether to add test frameworks) /No (whether to add view-based tests)/the prefix of the project

Create completed will automatically open the project, in the project directory will appear demo project code

Change the folder name (important!!)

Here change the name of the XXX (project name) folder (which contains Classes files, etc.) in your project aligned with the podSpec location to something else! This is important, otherwise you’ll end up with endless no-clean or Classes errors. Here I have changed the original NRBaseSpecs folder to Pod:And the reason is that if you don’t change the name here, it’s going to look like this in your private library folder under.cocoapods after you finally send pod repo push, because the system will automatically generate the version folder, and if you don’t change the name it’s going to be put together, You need to delete those Classes and Assets. You need to delete them every time you ship a version to get the pod install right.After changing the name, the private library under Cocoapods looks like this. Pod is the modified name, which contains our source code, and NRBaseSpecs is the folder automatically generated by the system, which contains the version number we sent

Replace the source code

Then delete the ReplaceMe file from the Classes folder below the Pod file and add it to our source code.

Edit the xxx.podspec file

S.name Project name s.Sion Project version s.ource The address after git is the address of the remote repository {h,m}, and the matching rules can be changed as needed, so that the podspec position is equal to that of the.h,.m file. You can start from this path and write s.flat works, UIKit, Foundation, any libraries that use s.dependency. If you rely on multiple libraries, To add s.dependency 'AFNetworking' s.dependency 'SDWebImage' multiple libraries must be added line feed, S. endored_libraries rely on third-party static libraries, such as: S. endored_libraries='xxxx.a',' nnn.a 'S.endored_frameworks = 'Pod/Classes/**/*. Framework 'dependency frameworkCopy the code

Add the source address of the Pods repository (important!)

Add it at the top of the Demo project Podfile

The source 'XXXX (the first step of remote warehouse address)' source 'https://github.com/Cocoapods/Specs.git' (Cocoapods engine library) # CDN truck, The source is modified to source 'https://cdn.cocoapods.org/'Copy the code

The supported version in Pofile needs to be the same as the supported version in podSpec

pod install

Pod Install will copy the Classes code and podspecs to Pods. You can call the Pods library in the test project, compile it, and go back to the directory containing Git in the previous step on the terminal

Pod lib Lint checks local libraries

Pod lib Lint --allow-warnings Pod lib lint --allow-warnings pod if you want to ignore warning errors add --use-libraries pod Lib lint --allow-warnings --use-libraries If the dependent third-party libraries are also private libraries, specify --source pod lib lint --use-libraries --allow-warnings - sources = XXX (the name of the private libraries can), https://cdn.cocoapods.org/Copy the code

Push local code to remote

Git add. Git commit -m 'XXX' git push origin master git tag -a '0.0.1' -m 'XXX (tag description)' git push --tagsCopy the code

Pod Spec Lint checks remote libraries (to upload code before doing this, tag it)

Pod Spec Lint If warnings are ignored, Add --allow-warnings pod spec lint --allow-warnings if referencing other third-party libraries add --use-libraries pod spec lint --allow-warnings --use-libraries If the referenced third-party libraries are private, Need to add - source pod spec lint - use - libraries - allow - warnings - sources = XXX (the name of the private libraries can), https://cdn.cocoapods.org/Copy the code

pod repo push

After the remote repository validation is successful, you need to commit the XXx. podspec file to Cocoapods’ private library

Pod repo push XXX (the name of the remote library).podSpec --allow-warnings for the local project if the reference to the third-party library is private, Add --source pod repo push XXX XXX. Podspec --use-libraries --allow-warnings - sources = XXX (the name of the private libraries can), https://cdn.cocoapods.org/Copy the code

Release completion use

If other projects need to rely on this module, you can use Pod Install to reference this module. To reference this module, add the source address of the Pods repository to the top of your podfile

The source 'XXXX (the first step of remote warehouse address)' source 'https://github.com/Cocoapods/Specs.git' (Cocoapods engine library) # CDN truck, The source is modified to source 'https://cdn.cocoapods.org/'Copy the code

Can be referenced successfully

Private library update

  • Modify the source code in the local Classes folder, then modify the podSpec version number, noting the path to source_files and the new source’s dependent libraries.
  • In the example project pod update –no-repo-update
  • Local compile successful, commit code, tag, podSpec consistent
  • Pod Lint Lint or POD Spec Lint validation
  • pod repo push xxx xxx.podspec –allow-warnings
  • Pod update –no-repo-update below the referenced project to see the library updated successfully

Packaging Framework

Pod Package XXXX. podSpec --no-mangle --force If the reference third-party library is private, Need to add - the spec - source pod package XXXX. Podspec - no - mangle - force - the spec - sources = XXX (git) path of private libraries, https://cdn.cocoapods.org/Copy the code

I can’t find commands in POD package

Problems encountered

Could not find remote branch xxx to clone.

The version number of the tag is inconsistent with the PodSpec, or the remote version is inconsistent

The repo… The at… is not clean

The local private repository repository is not clean and the local cache needs to be cleaned. Remove the repository from the local REPO, add it again, and then perform validation, push.

~/.cocoapods/repo # Open your own repository, find your own repository, delete the entire folder, empty the wastebasket pod repo add private repository name private repository remote address pod lib lint... pod repo push ...Copy the code

The private library update was not successful

After the private library is successfully released, you need to pod update the private library code in the Example folder of the private library project, and then pod install in the project that needs to reference the private library. Then you can see that the private library has been updated. If the private library has not been updated, you can see that the private library has been updated. You can comment “pod XXX” in your Podfile and then uncomment it and then pod install.

A library update is simply a function file or resource update. Code updates must be made in the “library name /classes” folder! Do not use Xcode to update the code directly under the name of the Pods/Development Pods/ library in the project. This is not effective, because this is only the code pulled from the local Pods repository after the pod update. Do not write this code, otherwise it will cause an exception to the library. Causing pod Lib Lint to fail after the next update!

If you are updating parts of the code, you need to push the code first and then pod repo push it. After successful release, pod repo update OPS-xGN-ios-xgn is required and then referenced in the project.

An unexpected version directory ‘Assets’ was encountered for the /Users/yanyan/.cocoapods/repos/** Pod in the xxx repository.

The reason is that source ‘XXX (repository address)’ means it wants it to be a canonical repository, but you seem to be trying to combine the canonical repository with the repository in which the code is stored, which is not supported. Instead, you should delete the custom source line and do something like pod ‘XXX ‘, :git =>’ XXX (repository address)’.

git remote: You do not have permission push to this repository

[root@podfile] [root@podfile] [root@podfile]

Making and gitlab

It is slow to open Github, and sometimes I can’t open it. I use GitLab.

Source code contains MRC files

The important thing is to align!! Be sure to align with S.xx above, sNA also needs standard position

non_arc_files = 'xxx/Classes/xxxx/xxx.{h,m}' s.requires_arc = true s.exclude_files = non_arc_files s.subspec 'no-arc' do  |sna| sna.requires_arc = false sna.source_files = non_arc_files endCopy the code

‘source_files’ pattern did not match any file

The path of the source_files file is aligned with podSpec, so write the path from the aligned file.{h,m} of the MRC file is correct.

xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information.

Directly see that line the ERROR below what can be wrong, I can’t find here is the tip. H file, add a. {h, m}

No podspec found for xxx in XXX (git address)

Private libraries in the project reference times wrong, the: the reference path is modified to a source of reference, and then put. Cocoapods/repos/private garage Classes and Assets delete can install pod. This problem can go to the above according to my method, modify the file name will not appear this situation.

target has transitive dependencies that include statically linked binaries

Use_frameworks is used! , and dependent libraries that reference static libraries require S.staatic_framework = true

References to other private libraries cannot be # imported to

The private library is not referenced in S.dependency

Encountered an unknown error (Unable to find a specification for xxxx depended upon by xxxx

Pod Lib Lint or POD Spec Lint adds source, such as the private library NRBaseSpecs

pod lib lint --use-libraries --allow-warnings --sources=NRBaseSpecs,https://cdn.cocoapods.org/
Copy the code

reference

Create a private POD library from Cocoapods