Much of the information on existing networks are the main private warehouse into escrow platform, such as gitee and so on. Many users may not want to talk about private warehouse custodian to third parties. This paper attempts to do his will into the private warehouse private git server.
Process as substantially
- Set up git server
- cocoapods create a private library
- Creating a remote repository components
- Create a local component repository
- Local component to the remote component associated warehouse warehouse
- Submit local component to the remote component Warehouse Code Warehouse
- Submission component podspec files to a private warehouse
- use
Note: Step 5 non-essential, we can first establish a remote repository to a local clone and then create a local warehouse, thus better direct access to the associated local warehouse, but there may be a problem mentioned below.
Set up git server
Git server to build a lot of tutorials, you can refer to the following article.
Git server is set up
to use Smart HTTP and Gitweb set up makeshift personal git server
Note: After the installation are generally used git ssh protocol git pull and server push, if necessary using the http protocol is used, an additional container and a http configuration. Nginx, etc. can be used as an http container.
cocoapods create a private library
Git can make use of third-party platform is completed, create a private warehouse here on our own git server built.
First of all server-side implementation
sudo git init --bare repos.git
repos.git private library name --bare (bare Chinese means: bare, bare) initialization of the repository (for the time being called a bare repository) will generate a class file: used to record the history of the repository .git directory the following documents; and not contain a copy of the actual project source files; --bare benefits can prevent conflicts.
Will create a complete remote private warehouse added to the local cocoapod go.
Executed locally
pod repo add repos http://10.10.1.1/git/repos.git
After machining, cocoapods will repos clone in ~ / .cocoapods / repos directory.
The main effect of this step is to allow us to find the code from our need to import from our warehouse in the private Bank of China pod install or pod search time.
First, there is no corresponding pod looking for from our local warehouse cocoapods official repository, if not then look for the corresponding components from our local private warehouse. If neither is failure. (Old version cocoapods might want to perform first pod update update the local warehouse, the new version will need to manually invoke pod update).
You can also view a list of local repository with the following command, master is cocoapods official warehouse, repos to create our own private warehouse.
pod repo list
Creating a remote repository components
The server side
sudo git init --bare FchKit.git
FchKit.git name for the component warehouse
Create a local component repository
It can be divided into two basic ways
- pod lib create FchKit created directly
- Existing project file is configured to generate podpec
The following is a way to create a process
pod lib create FchKit
Answer a few questions
Creating success
The class files in the component code components onto the folder name, file back to the next to the next Example
pod install
Each time you add files need to re-pod install. After the implementation of projects under the pod file taget files will be added, can be modified.
Note that, the local file structure, imported after we import the folder structure, the file structure when we use it, and all three may not be the same,
Development file structure.
Local file structure.
By pod FchKit import file structure.
To set the incoming pod folder directory structure needs to be set in the sub podspec file, reference may be sub podsepc AFNetworking the set. (More complex)
AFNetworking
Modify podspec submit documents to facilitate follow-up to a private library
If you can not find the home page address s.homepage dispensable when added to the formation of a private warehouse warning will pop up
s.source remote warehouse address
pod from a remote trousers s.source_files use components pull files
" " means match All files
" . {H, m}" indicates matches all .h files ending .m and
"**" means match all subdirectories
s.dependency dependent components other libraries can write a plurality
s.swift_version variation may be provided version prevent the compiler to compile a version mismatch caused by the problem that others can not import.
Local component to the remote component associated warehouse warehouse
Set Associations
git remote add origin http://10.10.1.1/git/FchKit.git
Unlinked
git remote remove origin
View related
git remote show origin
origin for the name
Above-mentioned problems
Mentioned above, we can remote component repository by clone down, and then in the warehouse common local repository to avoid local warehouse and associated remote warehouse this step. However, the actual operation may be problematic.
For example if we create a remote repository component test. Then git clone to the local Executive pod lib create test locally created components warehouse code. In this case the following directory structure
So when should submit code after we finish how to modify the code under test catalog or test-test it in the directory?
Ruoguo warning git add appear in the test directory.
git repository conflict, test is a git repository. test-test is a git repository.
If the test - test directory. git add git commit no problem, but git push origin master has encountered a problem.
This is because we did not test the remote repository test inside the warehouse, so there will not be test-test at the origin.
In this case we can test-test the entire contents copied to the test directory during the git push to.
Submit local component to the remote component Warehouse Code Warehouse
git push origin master
Enter the correct user name and password will be a success
common problem
1.unable to access 'xxx': The requested URL returned error: 500
The server is not configured correctly, you need to configure the user name and password on the server side.
First check http server configuration information
vi /etc/apache2/sites-enabled/000-default.conf
Adding information about the configuration file
SetEnv GIT_PROJECT_ROOT /var/www/html/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
RewriteEngine On
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
RewriteCond %{REQUEST_URI} /git-receive-pack$
RewriteRule ^/git/ - [E=AUTHREQUIRED]
<Files "git-http-backend">
AuthType Basic
AuthName "Git Access"
AuthUserFile /var/www/html/.htpasswd
Require valid-user
Order deny,allow
Deny from env=AUTHREQUIRED
Satisfy any
</Files>
Arrowhead portion may be modified as needed, address represents the repository and user profiles address.
Secondly side configuration file .htpasswd username and password below
sudo htpasswd -c /var/www/html/.htpasswd 用户名
2. error: RPC failed; curl 52 Empty reply from server
The reason may be because the file is too large to be submitted, enter the following command
git config --global http.postBuffer 524288000
It may also be because the network reasons, or git server problems without the http server users write access to the need to increase the permissions on the server.
chmod u=rwx /var/www/html/git -r
It represents an increase file owner read and write execute permissions. / Var / www / html / git stored address as a remote.
Submission component podspec files to a private warehouse
On the server side component code will be submitted before playing tag and tag the version number to be consistent with podspec file.
Executed on the server side
git tag 0.1.0
Or playing tag at the local and then submit the corresponding tag version to the server.
Local execution
git tag 0.1.0
git push origin 0.1.1
Then verify the spec
pod spec lint
Problems mentioned above can be added --allow-warnings parameter is ignored warnings
pod lib lint --allow-warnings
It appears xxx passed validation represents the validation by
After verification by using the pod repo push command file to be submitted podsepc private warehouse, repos are private warehouse name FchKit.podspec warehouse spec file.
pod repo push repos FchKit.podspec
common problem
1. Authentication failed for 'xxx'
Prompt the user to verify because you did not pass, because s.source here is wrong, pointing to github, and I was not a local terminal to log github account.
Log in to view the user by the following command
git config user.name
Modify User
git config --global user.name "Your_username"
git config --global user.email "Your_email"
2.Remote branch 0.1.0 not found in upstream origin
No remote repository of tag 0.1.0. You need to play tag in the remote repository. Of course, before that you have to have associated with the local warehouse remote repository. And the local repository of code push to a remote repository.
Referring to the tag to be solved.
Server-side execution
git tag 0.1.0
Or local execution
git tag 0.1.0
git push origin 0.1.1
The following command to view all tag warehouse
git tag
3. xxx did not pass validation, due to 6 errors and 3 warnings.
Libraries are not compiled by the need to modify the errors in the library
4. remote:error:insufficient permission fo adding an object to repository database ./object
Server permissions problems, generally related to most of permission errors for server-side permissions issue, you need to set appropriate permissions on the server. www-data is FchSpecs.git owner user name.
chown www-data FchSpecs.git -R
chgrp www-data FchSpecs.git -R
Here FchSpecs.git private warehouse name, with more than repos.git same.
After the success can be searched through the pod search.
pod search FchKit
Components for the update process
- Modify and component code
- Modifying the local podspec file version
- Submission component code.
- Server-side play tag, must be consistent with podspec file version.
- Resubmit the file to the private warehouse component podspec
Using Components
Adding to the local private warehouse. If in the creation of a private warehouse has been added there is no need to add again.
pod repo add repos http://10.10.1.1/git/repos.git
Adding Podfile documents referenced assembly
source 'http://10.10.1.1/git/repos.git'
source 'https://github.com/CocoaPods/Specs.git'
Find components from the local repos.git and official specs.git inside.
Join our library
pod 'FchKit'
Then execute
pod install