Componentization scheme

A: Static Library

Xcode, File -> new -> projest -> Static Library, I named HBTest

2. Run command + B to compile the command.
3. Close the current window and add hbtest. xcodeProj to the add File folder in the original project.

4. Introduction does not mean the project will be ready for use immediately. Add the corresponding. A file to target -> Build Phases -> Link Binary With Libraries

5. In HBTest project, add test code.
@interface HBTest: NSObject +(void)sayHello; @ the end -- -- -- -- -- -- -- -- -- -- -- -- - / / HBTest. M file @ implementation HBTest + (void) sayHello {NSLog (@"hello");
}
@end

Copy the code
6. Find a place in the original project#import <HBTest/HBTest.h>callsayHello
#import "ViewController.h"
#import <HBTest/HBTest.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor lightGrayColor];
    // Do any additional setup after loading the view.
    
    [HBTest sayHello];
}

@end

Copy the code
command + RLook at the console print

2019-10-30 22:40:09.535082+0800 componentized implementation [2660:112991] Hello

Second, the CocoaPods

1. Log in to Github to create a repository

2. Open the terminalpod lib create HBPodTest, fill in the corresponding content as prompted

What platform do you want to use?? [ iOS / macOS ]
 > ios

What language do you want to use?? [ Swift / ObjC ]
 > objc

Would you like to include a demo application with your library? [ Yes / No ]
 > yes 

Which testing frameworks will you use? [ Specta / Kiwi / None ]
 > none

Would you like to do view based testing? [ Yes / No ]
 > no

What is your class prefix?
 > HB
Copy the code

When the input is complete, a project containing a demo is automatically created and opened, as shown below

HBPodTest

3HBPodTest.podspecFiles are authenticated in the folder

3.1 CD HBpodtest 3.2 POD lib Lint HBpodtest. podspec

There are two warnings: 1) this submission is meaningless and 2) GitHub didn’t find my address (because I forgot to click create)

Warning solution < 1 > about WARN | The summary: The summary is not meaningful. Warning handling scheme.

The summary and description in hbPodTest. podspec files need to be edited, and the contents must be different.

<2> GitHub didn’t find my address

Go back to GitHub and set up the warehouse.

3.3 POD lib lint HBPodTest. Podspec –allow-warnings Validates HBPodTest passed Validation after a period of time. I read other people’s blogs without this meaningless warning. It’s really weird.

4. Back to the project

4.1 There is a configuration file in the project, which contains some information about our POD library. At present, we don’t need to modify it, just leave it. Of course, if your GitHub address does not match your S. homepage, you will need to synchronize.

The save path must be in the Classes folder
ReplaceMe.m

git add .

git commit -m 'first commit'// Can be in the. Podspec file address, for example I am: https://github.com/GitHubYhb/HBPodTest git remote add origin (fill dead simple user name here)/https://github.com/ (your public library name). The git git push -u  origin masterCopy the code

At this point, our GitHub repository will have the files we created.

Can see, he above pod support or not found that our revolution is not over. Pod Pod lib Lint hbPodtest. podspec –allow-warnings ####6 Submitting the POD 6.1 Specs repository is the file that houses the index of all the common pods on GitHub, and the way to do that is to have local pods link up at Specs. To do this, we need to tag our improved project code and synchronize it to the server

Git tag 0.1.0 // Git push Origin 0.1.0Copy the code

The finished prompt is shown below

6.2 Using specs to Verify Tags and ignoring warnings… pod spec lint HBPodTest.podspec –allow-warnings

  1. pod trunk push HBPod.podspecIf it’s the first time, it’s going to get an error, which means it needs to be used firstpod trunk registerGo to register

2) POD Trunk register email address ‘your name’ – after a verbose output, I typed pod Trunk push HBPod. Podspec again and then prompted me with that meaningless warning

pod trunk push HBPod.podspec --allow-warnings

5) Enter POD Trunk me, you can see our registration information

pod trunk push HBPod.podspec --allow-warnings

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 🎉 Congrats 🚀 HBPod (0.1.0 from) Successfully published 📅 October 31 st, 02:23 🌎 https://cocoapods.org/pods/HBPod 👍 Tell your friends! --------------------------------------------------------------------------------Copy the code

7) Back on GitHub we can see that pod support has changed to V0.1.0

####7. Insert pod ‘HBPodTest’ 7.2 pod install into your PodFile.

pod repo update
pod install

If not, do what I did.

Pod repo remove master 2. pod setup 3. pod repo update 4. pod installCopy the code

The installation succeeds after the preceding instructions are executed

7.3 debugging

conclusion

  1. GitHub creates a new repository

  2. Pod lib create Name

  3. Modify the name. Podspec

    1. summaryIntroduction to the
    2. descriptiondescribe
    3. SwiftYou need to specify theSwiftVersion. Such as:S.s wift_version = '5.0'
  4. Pod Lib Lint validation

  5. Add the code file to the Classes folder

  6. Submit the git.

    1. git add .
    2. git commit -m 'first commit'
    3. Git remote add origin https://github.com/(
    4. git push -u origin master
    5. Git tag 0.1.0 from
    6. Git push origin 0.1.0 from
  7. The spec verification. Pod Spec Specifies the name of lint

  8. Pod Trunk Push name podSpec. Success means completion

    1. trunkThe registration process
    2. Pod Trunk register Email address 'Your name' --verbose
    3. Verify by email
    4. pod trunk meCheck the information
    5. Pod Trunk Push name podSpec
  9. If there is a lot to see, have pod | 0.1.0 from mark.

  10. Project integration with our self-built POD project.

    1. Update it if you make a mistakepod.pod repo update
    2. pod install
    3. Try it if it’s slow.pod install --no-repo-update