美文网首页
创建私有库并关联(未整理)

创建私有库并关联(未整理)

作者: 小如99 | 来源:发表于2019-04-04 16:58 被阅读0次

    创建私有库

    首先需要在自己的gitlab/CSDN/码云等账号上,创建两个项目,一个是specs的,一个是自己要封装的,如下图所示


    image.png

    第一步创建仓库


    image.png
    image.png

    第二步创建lib文件 2.1 选择lib文件需要保存的路径

    2.2 打开终端进入lib文件路径

    2.3 终端输入pod lib create MyLibrary命令,根据问题依次输入自己项目的需求,如下:

    ~/Lib » pod lib create NWFDraggableView

    Cloning https://github.com/CocoaPods/pod-template.git into NWFDraggableView.

    Configuring NWFDraggableView template.


    To get you started we need to ask a few questions, this should only take a minute.

    If this is your first time we recommend running through with the guide:

    ( hold cmd and double click links to open in a browser. )

    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 ] > Yes

    What is your class prefix? > NWF

    Running pod install on your new library.

    Analyzing dependencies

    Fetching podspec for NWFDraggableView from ../

    Downloading dependencies

    Installing FBSnapshotTestCase (2.1.4)

    Installing NWFDraggableView (0.1.0)

    Generating Pods project

    Integrating client project

    [!] Please close any current Xcode sessions and use NWFDraggableView.xcworkspace for this project from now on.

    Sending stats

    Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.

    Ace! you're ready to go!

    We will start you off by opening your project in Xcode

    open 'NWFDraggableView/Example/NWFDraggableView.xcworkspace'

    To learn more about the template see https://github.com/CocoaPods/pod-template.git.

    To learn more about creating a new pod, see http://guides.cocoapods.org/making/making-a-cocoapod.

    一个lib文件创建了,可以参考官网 [Using Pod Lib Create

    ](https://guides.cocoapods.org/making/using-pod-lib-create.html)

    2.4 lib文件创建后,导入自己封装好的文件

    2.4.1 拷贝自己封装的文件到MyLibrary/MyLibrary/Classes/文件夹下,并且删除ReplaceMe.m文件


    image.png

    2.4.2 终端进入到MyLibrary/Example/ 路径,执行pod install 命令,这样你添加的封装文件就安装到测试项目里了

    ~/Lib » cd NWFDraggableView/Example


    ~/Lib/NWFDraggableView/Example(master*) » pod install

    Analyzing dependencies

    Fetching podspec for NWFDraggableView from ../

    Downloading dependencies

    Using FBSnapshotTestCase (2.1.4)

    Using NWFDraggableView (0.1.0)

    Generating Pods project

    Integrating client project

    Sending stats

    Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.

    2.4.3 在ViewController文件中写测试代码

    关联码云和本地的项目

    关联好了本地项目和码云的项目之后,修改NWFBannerView.podspec文件,添加tag

    Spec文件校验

    先添加pod repo pod repo add NWFGiteeSpecs https://gitee.com/xiaoru/Specs.git

    ~/Lib/NWFDraggableView(master) » pod repo add NWFGiteeSpecs https://gitee.com/xiaoru/Specs.git

    Cloning spec repo NWFGiteeSpecs from https://gitee.com/xiaoru/Specs.git

    [!] /usr/bin/git clone https://gitee.com/xiaoru/Specs.git NWFGiteeSpecs

    Cloning into 'NWFGiteeSpecs'...

    fatal: unable to access 'https://gitee.com/xiaoru/Specs.git/': The requested URL returned error: 403


    ~/Lib/NWFDraggableView(master) » pod repo add NWFGiteeSpecs git@gitee.com:xiaoru/Specs.git

    Cloning spec repo NWFGiteeSpecs from git@gitee.com:xiaoru/Specs.git

    The authenticity of host 'gitee.com (120.55.226.24)' can't be established.

    ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.

    Are you sure you want to continue connecting (yes/no)? yes

    [!] /usr/bin/git clone git@gitee.com:xiaoru/Specs.git NWFGiteeSpecs

    Cloning into 'NWFGiteeSpecs'...

    Warning: Permanently added 'gitee.com,120.55.226.24' (ECDSA) to the list of known hosts.

    git@gitee.com: Permission denied (publickey).

    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights

    and the repository exists.

    添加公钥后

    ~/Lib/NWFDraggableView(master) » pod repo add NWFGiteeSpecs git@gitee.com:xiaoru/Specs.git

    Cloning spec repo NWFGiteeSpecs from git@gitee.com:xiaoru/Specs.git

    ~/Lib/NWFDraggableView(master) » pod repo

    master

    NWFGiteeSpecs

    • Type: git (master)

    • URL: git@gitee.com:xiaoru/Specs.git

    • Path: /Users/judith/.cocoapods/repos/NWFGiteeSpecs

    2 repos


    ~/Lib/NWFDraggableView(master) » pod spec lint

    -> NWFDraggableView (0.1.0)

    • WARN | url: The URL (https://gitee.com/xiaoru/NWFDraggableView) is not reachable.

    • NOTE | xcodebuild: note: Using new build system

    • NOTE | [iOS] xcodebuild: note: Planning build

    • NOTE | [iOS] xcodebuild: note: Constructing build description

    • NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')

    Analyzed 1 podspec.

    [!] The spec did not pass validation, due to 1 warning (but you can use --allow-warnings to ignore it).

    因为我这个项目是私有的,只能访问到https://gitee.com/xiaoru 这个路径,所以修改 NWFDraggableView.podspec s.homepage = 'https://gitee.com/xiaoru'


    ~/Lib/NWFDraggableView(master) » pod spec lint

    -> NWFDraggableView (0.1.0)

    • NOTE | xcodebuild: note: Using new build system

    • NOTE | [iOS] xcodebuild: note: Planning build

    • NOTE | [iOS] xcodebuild: note: Constructing build description

    • NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')

    Analyzed 1 podspec.

    NWFDraggableView.podspec passed validation.


    ~/Lib/NWFDraggableView(master) » pod repo push NWFGiteeSpecs NWFDraggableView.podspec

    Validating spec

    -> NWFDraggableView (0.1.0)

    • NOTE | xcodebuild: note: Using new build system

    • NOTE | [iOS] xcodebuild: note: Planning build

    • NOTE | [iOS] xcodebuild: note: Constructing build description

    • NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')

    Updating the `NWFGiteeSpecs' repo

    Already up to date.

    Adding the spec to the `NWFGiteeSpecs' repo

    • [Add] NWFDraggableView (0.1.0)

    Pushing the `NWFGiteeSpecs' repo


    至此,spec文件和封装的组件化代码都上传至码云了,现在我们通过远程的方式来获取到码云上的组件化代码

    ~/Lib/NWFDraggableView/Example(master) » git push origin master

    fatal: unable to access 'https://gitee.com/xiaoru/NWFDraggableView.git/': Could not resolve host: gitee.com


    ~/Lib/NWFDraggableView/Example(master) » git remote

    origin


    ~/Lib/NWFDraggableView/Example(master) » git remote add origin git@gitee.com:xiaoru/NWFDraggableView.git

    fatal: remote origin already exists.


    ~/Lib/NWFDraggableView/Example(master) » git config --global http.proxy


    ~/Lib/NWFDraggableView/Example(master) » git config --global https.proxy


    ~/Lib/NWFDraggableView/Example(master) » git push origin master

    Counting objects: 15, done.

    Delta compression using up to 4 threads.

    Compressing objects: 100% (14/14), done.

    Writing objects: 100% (15/15), 5.86 KiB | 2.93 MiB/s, done.

    Total 15 (delta 7), reused 0 (delta 0)

    remote: Powered By Gitee.com

    To https://gitee.com/xiaoru/NWFDraggableView.git

    d3e18fe..33318d9 master -> master


    相关文章

      网友评论

          本文标题:创建私有库并关联(未整理)

          本文链接:https://www.haomeiwen.com/subject/hysqiqtx.html