最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[记录]折腾iOS的第三方包管理工具:Carthage

Carthage crifan 3521浏览 0评论

之前已经折腾了Cocoapods:

[记录]使用Cocoapods管理iOS项目的第三方库

但是很明显,有点点复杂的说。不是足够好用。

搜:

ios cocoapods carthage

然后看了:

Carthage 初探:四大优势与四大劣势 | I’m TualatriX

Cocoa 新的依赖管理工具:Carthage – isaced

Carthage:去中心化的Cocoa依赖管理器 – CocoaChina_让移动开发更简单

Carthage和CocoaPods | BAZINGA

更加确定去用:

Carthage

至少也是Carthage和Cocoapods两者共存去管理第三方包

另外,也是因为:

遇到一个自动布局的库:

robb/Cartography: A declarative Auto Layout DSL for Swift

为了能使用:

之前下载的源码,都被我改了一点,才能正常的在Xcode 7.3.1+swift 2.2下面工作

-》但是直接拷贝过来代码,再去改,很是麻烦

-》所以考虑到用,直接编译成.framework的Carthage

Carthage Tutorial: Getting Started

Carthage 包管理工具,另一种敏捷轻快的 iOS & MAC 开发体验 | Swift Cafe | 关于 iOS 开发,Swift,Objective-C 语言,Cocoa 框架的原创精品内容交流

Carthage/Carthage: A simple, decentralized dependency manager for Cocoa

Releases · Carthage/Carthage

我现在是Xcode 7.3.1

[记录]关于Homebrew和brew,并用brew安装Carthage

继续参考官网教程:

Carthage/Carthage: A simple, decentralized dependency manager for Cocoa

此处是用于iOS

去创建对应的Cartfile

Carthage/Artifacts.md at master · Carthage/Carthage

[记录]OGDL, Ordered graph data language

对于:

https://github.com/robb/Cartography

创建并添加内容如下:

licrifandeMacBook-Pro:QorosSales crifan$ touch Cartfile
licrifandeMacBook-Pro:QorosSales crifan$ vi Cartfile
licrifandeMacBook-Pro:QorosSales crifan$ cat Cartfile
github “robb/Cartography”

然后去更新:

licrifandeMacBook-Pro:QorosSales crifan$ carthage update
*** Cloning Cartography
*** Checking out Cartography at “0.6.0”
*** xcodebuild output can be found in /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/carthage-xcodebuild.6d7TLb.log
*** Building scheme “Cartography-Mac” in Cartography.xcodeproj
2016-05-14 15:16:21.610 xcodebuild[24779:2172636] [MT] PluginLoading: Required plug-in compatibility UUID ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C for plug-in at path ‘~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/WCGitTagsPlugin.xcplugin’ not present in DVTPlugInCompatibilityUUIDs
*** Building scheme “Cartography-iOS” in Cartography.xcodeproj
2016-05-14 15:16:37.201 xcodebuild[24847:2173074] [MT] PluginLoading: Required plug-in compatibility UUID ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C for plug-in at path ‘~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/WCGitTagsPlugin.xcplugin’ not present in DVTPlugInCompatibilityUUIDs
2016-05-14 15:16:50.878 xcodebuild[24979:2173500] [MT] PluginLoading: Required plug-in compatibility UUID ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C for plug-in at path ‘~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/WCGitTagsPlugin.xcplugin’ not present in DVTPlugInCompatibilityUUIDs
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
ld: warning: directory not found for option ‘-F/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Carthage/Build/Mac’
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
ld: warning: directory not found for option ‘-F/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Carthage/Build/iOS’
ld: warning: directory not found for option ‘-F/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Carthage/Build/iOS’
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Cartography/ViewUtils.swift:40:16: warning: ‘anyGenerator’ is deprecated: renamed to ‘AnyGenerator’
ld: warning: directory not found for option ‘-F/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Carthage/Build/iOS’
ld: warning: directory not found for option ‘-F/Users/crifan/dev/dev_root/daryun/Projects/Qoros/QorosSales/Sourcecode/QorosSales/Carthage/Checkouts/Cartography/Carthage/Build/iOS’
licrifandeMacBook-Pro:QorosSales crifan$

出现的一堆的找不到选项的警告,不知道是否影响

反正是出现了对应的:

Carthage/Checkouts

下载了源码

Carthage/Build/iOS

中有了对应的:

Cartography.framework

再去:

-》

参考:

Carthage 包管理工具,另一种敏捷轻快的 iOS & MAC 开发体验 | Swift Cafe | 关于 iOS 开发,Swift,Objective-C 语言,Cocoa 框架的原创精品内容交流

去把符号文件dSYM也添加进来:

结果拷贝了个整个文件过来了:

所以好像不应该选择那个:

copy items if needed

然后换用:

结果还是有:

算了,移动过去:

算了,感觉官网的意思好像是:

自动就会在拷贝framework的同时,自动拷贝dSYM文件?

干脆去掉上面的设置

-》希望Carthage会自动做这个事情

-》万一没做,调试第三方的库的时候,不能F7进入源码,再回头添加上述的配置,去拷贝dSYM文件

所以去掉上面的配置:

删除掉那个Cartography.framework.dSYM文件即可:

看了看,我此处的默认是no:

然后去clean后重新编译程序,看看能否正常编译,代码中能否正常使用Cartography这个库

结果还是出错:

想起来了,好像需要手动import:

import Cartography

然后再去试试

就可以自动编译了。

[总结]

使用第三方包管理工具(Cocoapods或Carthage)的话,如果用到第三方库中的函数,则需要手动导入对应的库:

 import xxx

才可以

-》而之前手动拷贝不同的库的源码到项目中后,直接使用对应的函数即可,无需import对应的库的-》Xcode即可自动找到的

然后再去调试代码,看看F7单步进入,能否进入第三方库的源代码:

发现是可以的:

-》

-》

说明不需要上面的设置去拷贝那个dSYM,Xcode或者是Carthage会自动帮忙找到对应的framework所对应的dSYM文件,即可支持第三方库的源码调试了。

另外去看了看:

Cartfile.resolved

内容为:

github “robb/Cartography” “0.6.0”

即:

当前安装的Cartography的版本是0.6.0

只有update才会升级版本,否则是不会变化的

详见:

Carthage/Artifacts.md at master · Carthage/Carthage

参考:

Carthage Tutorial: Getting Started

如果以后只想要更新对应版本(而不是所有平台版本),可以用:

carthage update –platform iOS

如果只想要跟新单个库(而不是所有的库),则用:

carthage update xxx

carthage update xxx yyy

-》

所以只想要更新某个库的某个平台的,估计可以用:

carthage update xxx –platform iOS

另外,再去参考:

Cocoa 新的依赖管理工具:Carthage – isaced

新增:

.gitignore

添加上:

#Carthage
Carthage

以便于之后用git的时候,忽略掉Carthage文件夹(及其下的N多源码,编译好的库等等)

转载请注明:在路上 » [记录]折腾iOS的第三方包管理工具:Carthage

发表我的评论
取消评论

表情

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.177 seconds, using 22.12MB memory