1. Create a private library
Under normal circumstances, the company will build its own source code hosting server, which is mainly created in gitlab.
1. Open the gitlab address, select "Project" to open and create a private library:
To create a private library, you need to select the specified Group and the Visibility Level needs to be selected as Private.
2. After the private library is created in gitlab, you need to add the private library locally. Open the terminal and run the following command:
pod repo add WZSpecRepo https://gitlab.***.com/v_wuzz/WZSpecRepo.git
2. Create a source code library
1. Open the gitlab address, select "Project" to open and create a source code library:
2. Create a standard CocoaPods Xcode project
Execute the following command in the terminal to automatically generate a standard CocoaPods Xcode project.
pod lib create WZUIKitModule
3. Create podspec file
Execute the following command in the terminal to automatically generate the podspec file in the project directory. If it is a standard CocoaPods Xcode project created through a command, there is no need to create a podsepc file through the command.
pod spec create WZUIKitModule
After the podspec is created, the corresponding configuration data needs to be modified. The following is an example. Please refer to the modification for details.
在这里插Pod::Spec.new do |spec|@[TOC](这里写自定义目录标题)
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
spec.name = "WZUIKitModule"
spec.version = "0.0.1"
spec.summary = "A short description of WZUIKitModule."
spec.description = <<-DESC
DESC
spec.homepage = "https://gitlab.***.com/v_wuzz/WZUIKitModule.git"
# spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# spec.license = "MIT (example)"
spec.license = { :type => "MIT", :file => "FILE_LICENSE" }
# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
spec.author = { "wzz" => "***@163.com" }
# ――― 源码路径 ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
spec.source = { :git => "https://gitlab.***.com/v_wuzz/WZUIKitModule.git", :tag => spec.version.to_s }
# ――― 源码目录 ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
spec.source_files = "WZUIKitModule/Classes", "Classes/**/*.{h,m}"
# ――― 资源文件 ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# spec.resource = "icon.png"
# spec.resources = "Resources/*.png"
# ――― 依赖库 ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
spec.dependency "JSONKit", "~> 1.4"
end入代码片
4. Locally check whether the podspec meets the specifications
In order to ensure that podspce complies with the writing specifications, a preliminary verification needs to be done locally before uploading.
pod lib lint --verbose --use-libraries --allow-warnings
5. Upload the project and create a formal tag
Upload the project to the source code library you just created. And create a formal tag.
// 将工程上传到刚刚创建的源码库
git remote add origin "https://gitlab.***.com/v_wuzz/WZUIKitModule.git"
git add .
git commit -m "Initial commit"
git push -u origin master
// 生成一个初始的正式tag,方便将源码库推到私有库
git tag 0.0.1
git push --tags
6. Verify remote podspec
Note: If the private library depends on the private library, add source 'https://gitlab.***.com/v_wuzz/WZSpecRepo.git' during verification
pod spec lint WZUIKitModule.podspec --verbose --allow-warnings --use-libraries
3. Push the source code library to the private library
Upload the podspec that has just been remotely verified to the private library.
pod repo push WZSpecRepo WZUIKitModule.podspec --verbose --allow-warnings --use-libraries
4. Podfile binding source
After the podspec is uploaded, if you need to rely on a certain source code library in the project, you need to add the private library pointed to by the source code library in the Podfile file. details as follows:
source 'https://gitlab.***.com/v_wuzz/WZSpecRepo.git'
Description of relevant options when linting:
–allow-warnings: indicates that warnings are allowed
–verbose: View the detailed verification process to help locate errors
–use-libraries: indicates the use of static libraries or frameworks