美文网首页iOS开发
Mac 安装Carthage

Mac 安装Carthage

作者: Else丶 | 来源:发表于2019-02-14 17:08 被阅读0次

    之前一直使用cocoaPods, 最近发现swift使用carthage更方便, 所以抽时间研究一下, 在此记录过程:

    PS: carthage和cocoaPods可以同时使用

    1. 安装Homebrew

    电脑之前没安装过homebrew,所以先安装一下
    打开终端,直接输入

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    return 执行
    等待就行,中间会提示按return并输入电脑密码


    image.png

    2.安装Homebrew完成后, 开始安装Carthage

    1.先更新一下Homebrew, 防止有新的更新
    运行
    brew update
    

    我这提示
    Already up-to-date.

    2.开始安装carthage
    brew install carthage
    
    3.安装完成后检查一下是否安装成功
    carthage version
    

    打印出版本号即表示安装成功

    3.安装完carthage后,开始使用

    1.此处同cocoaPods基本相同
    先进入项目所在路径
    cd /Users/XXX/Desktop/Demo
    
    验证当前位置
    pwd
    
    创建一个carthage文件
    touch Cartfile (此处与cocoaPods有所不同,cocoaPods一般使用 pod init创建podfile)
    
    此时到项目路径下找到创建的Cartfile文件, 用Xcode打开
    
    image.png
    在其中输入 github "SnapKit/SnapKit" ~> 4.0.0
    保存并退出
    
    执行
    carthage update
    
    image.png

    结束后
    路径下多出


    image.png

    (下载时应该指定平台)

    关闭Xcode,重新打开
    在下图标识中添加SnapKit.framework


    image.png

    搜索不出来时, 点击Add Other...

    image.png
    在该路径下选择SnapKit.framework即可
    image.png

    command+B编译通过即可

    Over

    相关文章

      网友评论

        本文标题:Mac 安装Carthage

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