私有库

2019-07-29  本文已影响0人  张_何

git.oschina.net 上创建两个私有库
ZJWFoundatinZJWFoundatinSpec,不选择语言,选择swift忽略文件,不要创建readme

终端操作

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

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

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

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

Would you like to do view based testing? [ Yes / No ]
 > yes
...
Analyzing dependencies
····
[!] Automatically assigning platform `ios` with version `9.3` on target `ZJWFoundation_Example` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
 -> ZJWFoundation (0.1.0)
···
ZJWFoundation passed validation.
To https://gitee.com/***/ZJWFoundation.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/***/ZJWFoundation.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://gitee.com/***/ZJWFoundation
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
fatal: refusing to merge unrelated histories
ZJWFoundation$ git pull origin master --allow-unrelated-histories
From https://gitee.com/***/ZJWFoundation
 * branch            master     -> FETCH_HEAD
Auto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignore
Automatic merge failed; fix conflicts and then commit the result.
 -> ZJWFoundation (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.
`ZJWFoundation.podspec passed validation.`
Validating spec
 -> ZJWFoundation (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 `ZJWFoundationSpec' repo
Adding the spec to the `ZJWFoundationSpec' repo
 - [Add] ZJWFoundation (0.1.0)
Pushing the `ZJWFoundationSpec' repo
master
- Type: git (master)
- URL:  https://github.com/CocoaPods/Specs.git
- Path: /Users/***/.cocoapods/repos/master

ZJWFoundationSpec
- Type: git (master)
- URL:  https://gitee.com/***/ZJWFoundationSpec.git
- Path: /Users/***/.cocoapods/repos/ZJWFoundationSpec

ZJWUIKitSpec
- Type: git (master)
- URL:  https://gitee.com/***/ZJWUIKitSpec.git
- Path: /Users/***/.cocoapods/repos/ZJWUIKitSpec

使用

遇到的坑一

-> SJLoginModule (0.1.3)
    - ERROR | [iOS] unknown: Encountered an unknown error (CocoaPods could not find compatible versions for pod "SJTools":
  In Podfile:
    SJLoginModule (from `/Users/***/Desktop/SJLoginModule`) was resolved to 0.1.3, which depends on
      SJTools (~> 0.1.9.4)

None of your spec sources contain a spec satisfying the dependency: `SJTools (~> 0.1.9.4)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.) during validation.

[!] SJLoginModule did not pass validation, due to 1 error.
You can use the `--no-clean` option to inspect any issue.

这是在提示我找不到SJTools这个库,pod 在验证的时候默认是去公有库去找的,如果公有库找不到有没有添加私有库的源,就会提示找不到。所以这个时候我们再pod lib lint 的时候需要把私有库的spec仓库地址给加上
pod lib lint --sources=git@git.corp.***.cn:***iosgroup/***iospodspec.git,https://github.com/CocoaPods/Specs.git
如果你的库依赖多个私有库,那么就需要将所有私有库的地址都加上,每个地址之间用逗号分隔开,就像这样的形式
pod lib lint --sources=REPO_NAME1,REPO_NAME2,REPO_NAME3,https://github.com/CocoaPods/Specs.git --allow-warnings
其中https://github.com/CocoaPods/Specs.git是公有库repo的地址

遇到的坑二

制作的私有库中有一个第三方的SDK,这个sdk依赖系统的libresolv.9.tbd库,当时不知道,所以编译直接报错如下:

Snip20190823_7.png
然后百度得知需要添加libresolv.9.tbd库,然后便在demo中的target中添加了该库,可以编译还以报错,看到网上说的都是这个原因,以为自己添加错了。 Snip20190823_8.png
经过一番折腾之后才发现原来是要在SJLoginModule TARGET下添加,因为是在编译这个target的时候出现错误的
Snip20190823_9.png

注意: 每次pod install 后添加的依赖库都需要再重新添加

遇到的坑三

[!] The 'Pods-SJLoginModule_Example' target has transitive dependencies that include statically linked binaries: (LZNetwork and CleanJSON)

遇到的坑四

error: linker command failed with exit code 1 (use -v to see invocation)
原因是在swift项目中依赖了一个oc 第三方库,导致链接的时候失败。
pod lib lint --sources=https://github.com/CocoaPods/Specs.git,git@git.***.cn:***iosgroup/***iospodspec.git --allow-warnings --skip-import-validation
在解决完上面的问题后,把本地的podspec文件推送到远程的时候同样会提示链接的错误

 SJLoginModule$ pod repo push plu-***iospodspec SJLoginModule.podspec --allow-warnings

Validating spec
 -> SJLoginModule (0.1.4)
    - WARN  | source: Git SSH URLs will NOT work for people behind firewalls configured to only allow HTTP, therefore HTTPS is preferred.
  ······
    - NOTE  | [iOS] xcodebuild:  clang: error: linker command failed with exit code 1 (use -v to see invocation)

这个时候我们同样需要加上 -skip-import-validation 命令
pod repo push ***-***iospodspec SJLoginModule.podspec --allow-warnings --skip-import-validation

上一篇 下一篇

猜你喜欢

热点阅读