I. Main contents

  • 1.1. Illustrate the process diagram of using the framework with CocoaPods
  • 1.2. Creation of development framework projects
  • 1.3. Create a framework description spec
  • 1.4. Upload the spec to gitHub’s remote index library
  • 1.5. Check your registration information in CocoaPods
  • 1.7. Use your own framework
  • 1.8 Subspec branch function

Illustrate the process diagram for using the framework with CocoaPods


Illustrate the process diagram for using the framework with CocoaPods

Iii. Creation of development framework projects

  • 3.1. Create a repository on gitHub and name it by yourselfJKGCDTimerAnd generate ithttpsLinks:Github.com/JoanKing/JK…

    New warehouse entrance

    Frame information filling

    Creating a successful
  • 3.2 CD Enter the desktop and clone the project in the terminal

    git clone https://github.com/JoanKing/JKGCDTimer.git
    Copy the code
  • Create a clone project in the JKGCDTimer folder. Clone the folder name must be the same as the project name

    Create the project JKGCDTimer in the clone generated JKGCDTimer

  • 3.4 create a folder JKGCDTimer in the JKGCDTimer project

    WechatIMG233.jpeg

  • 3.5. Upload the JKGCDTimer local file to the local repository

    Git add. // Commit the code to a local repository // If there is no local git set up, Git commit -m 'commit'Copy the code
  • 3.6. Submit local code to github repository

    / / to check the warehouse name git remote / / adding associated warehouse git remote add origin HTTP: / / https://github.com/JoanKing/JKRichText.git / / push to making the git push warehouse origin masterCopy the code
  • Git remote add origin —- fatal: remote origin already exists. Fatal: remote origin already exists

    • $git remote rm origin
    • $git remote add origin github.com/JoanKing/JK There will be no error!
    • $git remote rm origin error: Could not remove config section ‘remote. Origin’ We need to modify the contents of the gitConfig file
    • 4, Go to your Github installation directory, find a file called gitConfig, open it and delete the [remote “Origin “] line from it.
  • 3.8, 3.5, and 3.6 can be submitted using Xcode

    3.5 and 3.6 can be submitted using Xcode

    • Tip: The first lift pop-up asks you to enter yourMaking a namewithpassword

Create a framework description spec file

  • 4.1. Check out CocoaPods Guides for spCE documentation

    CocoaPods Guides

  • 4.2 create a spec file (the name after create is usually the name of your repository)

    CD Go to the desktop JKRichText folder // Create a spec file pod spec create JKRichTextCopy the code


Creating a Spec file

  • 4.3 modify the spec file I just created. I created jkgcdtimer.podSpec

    Modify the ‘spec’ file you just created

  • 4.4 For details on specs, you can also visit podSpec at guides.cocoapods

    The details of the spec

    Pod: : Spec. New do | Spec | Spec. The name = 'Reachability' Spec. Version = '3.1.0' Spec. The license = {: type = > 'BSD'} spec.homepage = 'https://github.com/tonymillion/Reachability' spec.authors = { 'Tony Million' => '[email protected]'} spec.summary = 'ARC and GCD Compatible Reachability Class for iOS and OS X.' spec.source = { :git => 'https://github.com/tonymillion/Reachability.git', Source_files = 'Reachability.{h,m}' spec.framework = 'SystemConfiguration' :tag => 'v3.1.0'} spec.source_files = 'Reachability. S.i OS. Deployment_target = "8.0" endCopy the code
    • Self. name name = ‘JKGCDTimer’

    • Self. version version = ‘0.0.1’ (this will be explained later)

    • Self. summary = “JKGCDTimer.”

    • S. description = “JKGCDTimer, this is a description, the content must be longer than summary, otherwise it will report an error”

    • S.homepage (the first page of the framework) = “github.com/JoanKing/JK…”

      The home page address of the frame

    • S.license = “MIT”

    • S. thor(author) = {“JoanKingWC” => “[email protected]”}

    • S.i OS. Deployment_target = “8.0”

    • $git => $git => $git => $git => $git => $git => $git => $git => $git => $git => $git => $git => $git And then I’m going to put the version tag, which is going into Releases, so I have to have it

      Release stores the tag

    • {h,m}”, JKGCDTimer/**/*.{h,m}”, JKGCDTimer is the downloaded folder,** matches the directory,*.{h,m} is all matched files, {h,m}” JKGCDTimer/*/.{h,m}” JKGCDTimer must be in the same directory as the spec.

      s.source_files  = "JKGCDTimer", "JKGCDTimer/JKGCDTimer/JKGCDTimer/**/*.{h,m}"
      Copy the code

      The interpretation of the s.s ource_files

      Description:The framework for importing the project in Pod Install is just the image above3folder, it follows thats.source_filesConfiguration matters

  • 4.5 Tip: We have finished all the above content, but the most important step is still needed. There is no tag(tag is another name for version) in github repository release. Tag is as follows:

    Git tag git tag git tag git tag Git remote rm origin git remote add Origin git remote add origin git remote add origin https://github.com/JoanKing/JKGCDTimer.git / / submit the specified tag git push origin 0.0.1 / / submit all tags git push - tagsCopy the code

    Tip: Remove the tag

    • Local delete:Git tag - d 0.0.1
    • Remote delete:Git push origin: 0.0.1

    Set the tag and submit the tag

    GitHub releases a 0.0.1 tag in the JKRichText repository

    Tip:Pod install imports the JKGCDTimer folder in the release tag

Upload specs to gitHub’s remote index repository

  • Guides. cocoapods has a Getting Setup with Trunk that allows you to upload local spec files to gitHub’s remote index repository

    Getting setup with Trunk

    // pod trunk register [email protected] 'Orta Therox' --description='macbook air' // [email protected]: [email protected] 'IronMan' --description=' consult 'Copy the code


Registered trunk

  • 5.2 Finish the above, your mailbox will receive an email! Open the link on the email


    Open the link on the email

    Execute the: spec filename of your library name at the terminal

    Podspec: pod Trunk push jkgcdTimer.podSpec: Pod Trunk push jkgcdtimer.podSpec: pod trunk push JKGCDTimer.podspec –allow-warnings

  • 5.3 Fill out the spec in section 2. The following commands can be executed to check for compliance without any warnings or errors, common errors that occur

    pod spec lint JKRichText.podspec
    Copy the code
    • 5.3.1 The SPEC has been verified


      Spec verification passed

    • 5.3.2. If you have an error, handle it one by one


      error

      The solution is to go to xcode Settings, set the Command Line Tools, go to Xcode> Preferences >Locations, and then run the host


      Solution G

  • 5.4 If the master repO is successfully published, it will update the master repO with information similar to the following:


    Release success Message

  • 5.5. Verify that you have published successfully on CocoaPods (that is, can be found) and if a red error occurs


    I can’t find it

    • Delete the search_index.json file from the local cocoapods library

      Input control + shift + G ~ / Library/Caches/CocoaPods/search_index jsonCopy the code

    Delete the ‘search_index.json’ file from the local Cocoapods

    • When you search again, the local index library, which you just deleted, is automatically recreatedsearch_index.json. Update the POD library if you are searching for a framework and cannot find it:pod setup
    • To search againPod Search framework nameIf yes, the publication is successful

      Release success
  • 5.6. If you want to be able to search your project on other people’s computers, ask them to update the master Repos.

    pod setup
    Copy the code

    Tip: if someone else cocoapods is the latest, you can copy his master, control + shift + G type ~ /. Cocoapods/repos/master, the master copy

  • You can also check the status of your framework on Cocoapods website by typing the name of the framework. It is usually delayed until the next day.

    Check the status of your framework on the Cocoapods website

Check your login information in CocoaPods

pod trunk me
Copy the code


Check out your registration information in CocoaPods

Use your own framework (Cocoapods) and create a new project (JKTest) to use it

  • 7.1. Create project JKTest


    Create the project JKTest

  • Create a Podfile

    Pod 'JKGCDTimer', '~> 0.0.1'Copy the code

    Podfiles are created in the import framework

    # Import pod installCopy the code


The JKGCDTimer was successfully imported

8. Supplement: Subspec branch function

  • 8.1 look at the framework JKOCProjectTool. Our purpose is to create a folder JKUiviewExtension inside the Framework JKOCProjectTool


    Subspec Branch effect

  • 8.2. The following is the structure of my framework


    I frame the structure

  • 8.3 The following is the spec file information

    Pod: : Spec. New do | s | s.n ame = "JKOCProjectTool s.v ersion =" 0.0.7 s.s "ummary =" OCTool. "spyware doctor escription = "This is a nice OC utility class, I will continuously update "Sheldon horowitz omepage =" https://github.com/JoanKing/JKOCProjectTool "s.l icense =" Apache License 2.0 "s.a uthor = { "JoanKingWC" => "[email protected]"} s.iso. Deployment_target = "8.0" s.source = {:git => "https://github.com/JoanKing/JKOCProjectTool.git", :tag => "#{s.version}" } # s.public_header_files = 'JKOCProjectTool/JKOCProjectTool.h' s.source_files = 'JKOCProjectTool/JKOCProjectTool.h' s.subspec 'JKUiviewExtension' do |ss| ss.source_files = 'JKOCProjectTool/JKUiviewExtension/**/*' # ss.public_header_files = 'JKOCProjectTool/JKUiviewExtension/UIView+JKUiviewExtension.h' end endCopy the code


Configuration of the spec content

Tip: The path to s.source_files is based on jkocProjectool. podspec. If the framework is in the same directory as jkocProjectool. podspec, write the name of the framework folder directly. CocoaPods search JKOCProjectTool and see how I write it.

Remote private libraries Local private libraries

Git is a source code that can be downloaded from cocoapods, guides, and subspec. Git is a source code that can be uploaded, updated, deleted, or ignored.