12

I'm trying to learn about frameworks and how to use them in my Swift app. I'm a beginner at Swift, I understand OOP concepts but am completely new to handling libraries and frameworks.

I want to use frameworks like SwiftyJSON, Alamofire, and plenty more but want to use them in the simplest way possible. I found out that Carthage is the easiest way to update these into your project. However I haven't found a single user-friendly guide or tutorial on using this! I read the documentation here (https://github.com/Carthage/Carthage/blob/master/README.md) but it was very confusing for me. I am completely stuck at creating a Cartfile.

How do you create a Cartfile? Where should it be located?

After that I understand the commands to put in it, but I'm stuck at creating it and understanding the fundementals.

trixmasta
  • 233
  • 3
  • 14
  • 1
    If you really want the simplest way possible, then make use of `CocoaPods` instead of `Carthage`. In the `README` for `Carthage` it's even written: `CocoaPods’ approach is easier to use, while Carthage’s is flexible and unintrusive`. – Kumuluzz Jul 31 '15 at 06:40
  • Oh I didn't notice that, I'm worried not all frameworks will work with CocoaPods. Is it used widely enough for me to easily integrate the best and most popular frameworks that manipulate location, facebook, and animations? – trixmasta Jul 31 '15 at 06:43
  • 1
    Both `SwiftyJSON` and `Alamofire` supports `CocoaPods`. The `Facebook SDK` as well. Even more, Google has announced that from now on they will only use `CocoaPods` to distribute their iOS frameworks – Kumuluzz Jul 31 '15 at 06:45
  • That is wonderful. I will try CocoaPods now. You're great, thank you Kumuluzz! – trixmasta Jul 31 '15 at 06:46
  • Carthage is more easiest solution and it not change your project file. Is decentralised, quick and reliable. – Deny Aug 07 '15 at 13:26
  • For beginners, I think CocoaPods is easier. I've been using it now for over a week and its awesome -- except for when I need to run and test it on iOS7 – trixmasta Aug 09 '15 at 06:23
  • Possible duplicate of [How to correctly create carthage cartfile?](http://stackoverflow.com/questions/30401465/how-to-correctly-create-carthage-cartfile) – Suragch Jul 21 '16 at 04:13

1 Answers1

23

Cartfile is simple plain-text file, that should be located in the same folder as your *.xcodeproj file.

One way of creating it is via terminal:

$ cd <Path_to_the_project_folder>
$ touch Cartfile
$ open Cartfile -a Xcode
Jakub Vano
  • 3,833
  • 15
  • 29
  • Sweet, thanks Jakub! That doesn't look too difficult. But I read somewhere else on StackOverflow that the Cartfile has to be executable. Is this true? – trixmasta Jul 31 '15 at 06:47
  • 1
    No, it does not have to be executable. Think of it as configuration file - you don't execute it directly, it is just read by some application (`carthage ` in this case). – Jakub Vano Jul 31 '15 at 06:58
  • Oh okay, but then when I run "update carthage" how do I do it so it knows to execute it on the project folder that has the cartfile? – trixmasta Jul 31 '15 at 07:55
  • 1
    You need to run in "in" the folder containing your `Cartfile`, i.e. `$ cd `, `$ carthage update`. – Jakub Vano Jul 31 '15 at 09:24
  • 2
    @trixmasta would recommend accepting this answer if it worked out for you. (It did for me :) ) – Lukesivi Nov 24 '15 at 13:18
  • @lukesIvi actually I ended up using CocoaPods as someone above recommended, turned out to be a lot easier and is widely used in different libraries! – trixmasta Nov 26 '15 at 04:48
  • note that you can type **nano Cartfile** to edit that file fairly easily inside Terminal. (You have to be familiar with "shell-style" editors - worth learning!) – Fattie Dec 12 '16 at 12:20