最新消息:VPS服务器又从fzhost.net换回Linode了,主题仍用朋友推荐的大前端D8

【总结】iOS第三方库管理工具Carthage的使用心得

iOS crifan 1031浏览 0评论

1.如果github上面的库是没有tag的:

比如:

https://github.com/edekhayser/Timeline

 

github lib edekhayser Timeline no tag

 

则是没法使用Carthage去管理(下载,编译)该库的

会报错:

licrifandeMacBook-Pro:QorosSales crifan$ carthage update
*** Fetching Timeline
No tagged versions found for github "edekhayser/Timeline"

详见:

【记录】试用iOS中的时间轴控件:Timeline

 

2.如果github上面的库,自己已经提供了编译好的二进制库(xxx.framework)的话,则carthage去下载的时候,就会自动下载已经编译好的库:

Downloading xxx.framework binary at

而不会再去下载源码,再去编译生成xxx.framework

下载到了build下面对应的位置:

Carthage/Build/PLATFORM/xxx.framework

比如,对于:

https://github.com/danielgindi/Charts

网页中有介绍:

Charts now include Carthage prebuilt binaries.

github “danielgindi/Charts” == 2.2.4

github “danielgindi/Charts” ~> 2.2.4

然后去安装的时候,输出是:

licrifandeMacBook-Pro:QorosSales crifan$ carthage update Charts
*** Fetching Charts
*** Downloading Charts.framework binary at "New features, Swift 2.2/3.0, and bugfixes"
*** xcodebuild output can be found in /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/carthage-xcodebuild.CSzNOD.log

对应下载的Charts.framework在:

  • Carthage/Build/iOS/Charts.framework
  • Carthage/Build/Mac/Charts.framework
  • Carthage/Build/tvOS/Charts.framework

详见:

【记录】用Carthage去安装库Charts

-》这样调试的时候,就没有该库的源码供调试了

-》不过多数时候的调试,其实也无需源码

 

注:

不过后来看到:

carthage update

有个参数:

[–no-use-binaries]

check out dependency repositories even when prebuilt frameworks exist, disabled if –use-submodules option is present (ignored if –no-build option is present)

好像可以实现:

即使有二进制framework文件,也还是下载源码并编译

抽空去试试

 

3.通过carthage update删除某个库后,对应的Build/平台下面对应的库文件xxx.framework是没有被删除的

-》想要彻底清除掉的话,可以手动去删除

比如:

自己手动去删除

Carthage/Build/iOS/Charts.framework

详见:

【记录】用Carthage添加第三方库

 

4.carthage的命令的语法是:

licrifandeMacBook-Pro:QorosSales crifan$ carthage help 
Available commands: 
   archive           Archives built frameworks into a zip that Carthage can use 
   bootstrap         Check out and build the project's dependencies 
   build             Build the project's dependencies 
   checkout          Check out the project's dependencies 
   copy-frameworks   In a Run Script build phase, copies each framework specified by a SCRIPT_INPUT_FILE environment variable into the built app bundle 
   fetch             Clones or fetches a Git repository ahead of time 
   help              Display general or command-specific help 
   outdated          Check for compatible updates to the project's dependencies 
   update            Update and rebuild the project's dependencies
   version           Display the current version of Carthage

想要了解每个子命令的详细语法,可以用:

carthage help sub_command

 

比如:

carthage help build

输出是:

licrifandeMacBook-Pro:QorosSales crifan$ carthage help build 
Build the project's dependencies 
[--configuration (string)] 
the Xcode configuration to build 
[--platform (platform)] 
the platforms to build for (one of ‘all’, ‘Mac’, ‘iOS’, ‘watchOS’, 'tvOS', or comma-separated values of the formers except for ‘all’) 
[--derived-data (string)] 
path to the custom derived data folder 
[--no-skip-current] 
don't skip building the Carthage project (in addition to its dependencies) 
[--color (color)] 
whether to apply color and terminal formatting (one of ‘auto’, ‘always’, or ‘never’) 
[--verbose] 
print xcodebuild output inline 
[--project-directory (string)] 
the directory containing the Carthage project 
[[]]
the dependency names to build
licrifandeMacBook-Pro:QorosSales crifan$ carthage help update 
Update and rebuild the project's dependencies 
[--configuration (string)] 
the Xcode configuration to build (ignored if --no-build option is present) 
[--platform (platform)] 
the platforms to build for (one of ‘all’, ‘Mac’, ‘iOS’, ‘watchOS’, 'tvOS', or comma-separated values of the formers except for ‘all’) 
(ignored if --no-build option is present) 
[--derived-data (string)] 
path to the custom derived data folder 
[--verbose] 
print xcodebuild output inline (ignored if --no-build option is present) 
[--no-checkout] 
skip the checking out of dependencies after updating 
[--no-build] 
skip the building of dependencies after updating (ignored if --no-checkout option is present) 
[--use-ssh] 
use SSH for downloading GitHub repositories 
[--use-submodules] 
add dependencies as Git submodules 
[--no-use-binaries] 
check out dependency repositories even when prebuilt frameworks exist, disabled if --use-submodules option is present (ignored if --no-build option is present) 
[--color (color)] 
whether to apply color and terminal formatting (one of ‘auto’, ‘always’, or ‘never’) 
[--project-directory (string)] 
the directory containing the Carthage project 
[[]]
the dependency names to update, checkout and build

5.

后来用了

carthage update --no-use-binaries
去单独更新某个库
-》即使有编译好的二进制,也去下载源码并编译:
licrifandeMacBook-Pro:QorosSales crifan$ carthage update --no-use-binaries XCGLogger
*** Cloning XCGLogger
*** Fetching realm-cocoa
*** Fetching ios-filter-control
*** Fetching Charts
*** Fetching Cartography
*** Checking out XCGLogger at "Version_3.3"
*** xcodebuild output can be found in /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/carthage-xcodebuild.FkcnoP.log
*** Building scheme "XCGLogger (OS X)" in XCGLogger.xcodeproj
*** Building scheme "XCGLogger (iOS)" in XCGLogger.xcodeproj
*** Building scheme "XCGLogger (tvOS)" in XCGLogger.xcodeproj
*** Building scheme "XCGLogger (watchOS)" in XCGLogger.xcodeproj

6.carthage单独更新某个库

carthage update xxx
-》除了会更新对应的库之外
-》也会额外的去获取其他的库
-》估计是判断其他库是否有更新?
-》反正觉得好像fetch 其他库,有点多余啊

比如:

licrifandeMacBook-Pro:QorosSales crifan$ carthage update Alamofire
*** Cloning Alamofire
*** Fetching XCGLogger
*** Fetching realm-cocoa
*** Fetching Charts
*** Fetching Cartography
*** Checking out Alamofire at "3.4.0"
*** xcodebuild output can be found in /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/carthage-xcodebuild.QdeN2y.log
*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace
*** Building scheme "Alamofire watchOS" in Alamofire.xcworkspace
*** Building scheme "Alamofire tvOS" in Alamofire.xcworkspace
*** Building scheme "Alamofire OSX" in Alamofire.xcworkspace

7.在得到framework库文件后,要加入到项目中时:

对于iOS的话,注意不是Embedded Binaries而是Linked Frameworks and Libraries:

详见官网:
Carthage/Carthage: A simple, decentralized dependency manager for Cocoa
的解释:
“for OS X,  in the “Embedded Binaries” section
for iOS, tvOS, or watchOS, in the “Linked Frameworks and Libraries” section”

8.有些github的项目,即使有tag,但是本身不支持,输出

Dependency xxx has no shared framework schemes
比如:
https://github.com/johnlui/SwiftNotice/

有tag:

但是由于不支持,所以出错:

licrifandeMacBook-Pro:QorosSales crifan$ carthage update SwiftNotice
*** Cloning SwiftNotice
*** Fetching SwiftKeychainWrapper
*** Fetching Alamofire
*** Fetching XCGLogger
*** Fetching realm-cocoa
*** Fetching Charts
*** Fetching Cartography
*** Checking out SwiftNotice at "v3.4"
*** xcodebuild output can be found in /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/carthage-xcodebuild.gD2Vsz.log
*** Skipped building SwiftNotice due to the error:
Dependency "SwiftNotice" has no shared framework schemes

If you believe this to be an error, please file an issue with the maintainers at https://github.com/johnlui/SwiftNotice/issues/new

转载请注明:在路上 » 【总结】iOS第三方库管理工具Carthage的使用心得

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
15 queries in 0.301 seconds, using 10.34MB memory