# Building Libraries for iOS Componentization by using cocoaPods
:::info
:bulb:
**This content discusses the modularization of partial code components, utilizing the CocoaPods method to manage the code separately, gradually solving the issues of CPU loading, code readability etc...**
**By modularizing the project code, not only can we clearly separate code functionalities for a more readability, we can also alleviate CPU load during system initialization process.**
**This helps reduce CPU burden, and the components can be imported as needed to achieve the goal of modularization.**
**The following content is primarily based on GitLab.**
:::
## :book:Before setting up a library, it's necessary to create an index repository.
#### 1.Firstly, check the index repository on the current system.
pod repo
or
pod repo list
if you want to remove repo, you can alse call
pod repo remove (remote index repository)
#### 2. Create a local index repository then link it to the recently created remote index repository. Remote index repository must have a master branch, so you can add a readme file.
cd (local folder)
pod repo add indexRepository(CLThirdTestSpec) gitlab address(https://gitlab.com/chuan800418/clthirdtest.git)


#### 3. Start to created local private repository
pod lib create repository(CLThirdTest)
‼️ This **repository(CLThirdTest)** is the place which stroe the code, don't mess up with **remote index repository(CLThirdTestSpec)**

You can just choose the answer that you want!
Relust of folder:

then you can call pod install once time.
pod install
#### 4. Configure "podspec"
<1> ‼️ s.homepage = 'https://gitlab.com/chuan800418/clthirdtest'
<2> ‼️ s.source = { :git =>
'https://gitlab.com/chuan800418/clthirdtest.git', :tag => s.version.to_s, :branch => "master" }
<3> ‼️ s.version = '0.0.xxx'
Version here need to be set as same as the tag version(next process).

#### 5. Local check
After we push the code we need to make once local check
pod lib lint --private --allow-warnings

#### 6. Push to remote
<1> you can choose the command line:
pod install
git status
git add .
git commit -m "init"
git remote add origin
git push -u origin master
<2> Source Tree


#### 7. Tag
‼️ Tag version here need to as same as "podspec"!!!!!!!
git tag version number-
git push --tags

#### 8. remote check
make remote check one time
pod spec lint --private --allow-warnings

#### 9. release
pod repo push indexRepository(CLThirdTestSpec) repository.xxxpodspec(CLThirdTest.podspec) --allow-warnings

Then excute
pod repo update
pod search repository(CLThirdTest)
#### 10. Ustage
finally we can pod your package into others project like:

And run pod install

‼️ Add Code Here
‼️ One another thing: Any code you want to release in Xcode need keywords "public"

#### 11. public repository
If you want to put yours package to cocoapos public repository
<1> Execute:
pod trunk register Email Address(chuan800418@gmail.com) userName(chuan800418)
<2>Then go to verify


After success execute:
pod trunk push repository.xxxpodspec(CLThirdTest.podspec) --allow-warnings

---
## ErrorHandling
If some project too old and Xcode 1.4.3 doesn't including file 'arc' need to execute the modify below:
1.
<1> System Setting -> privacy And Security -> Full Disk Access

<2>
cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/
sudo mkdir arc
cd arc
sudo git clone https://github.com/kamyarelyasi/Libarclite-Files.git .
2. If command line show error msg below, please excute
pod repo remove (remote index repository)
and
cd (local folder)
pod repo add indexRepository(CLThirdTestSpec) gitlab address(https://gitlab.com/chuan800418/clthirdtest.git)
