8

I want to read a .csv data in Swift, so I have informed me how to make this. Finally I got into this: https://github.com/Flinesoft/CSVImporter The CSVImporter.

But it says: "You can of course also just include this framework manually into your project by downloading it".

That would be OK, but there are several folders and as I have never importer a library into Swift before, I don't know what to download and where I should include it into my project.

I hope, anybody can help me. Thanks.

1
  • You can refer to this tutorial to successfully include (i.e import) library (i.e framework) into a project. Obviously you will be able to have the updated framework every time you run carthage update command in terminal Commented Mar 16, 2017 at 21:02

2 Answers 2

10

The best way to import third-party dependencies is via dependency managers: CocoaPods/Carthage/SPM, you will be able to update a lib without headache.

1. CocoaPods [Offical Guide]

This is by far the easiest way to go...

Open terminal

Install CocoaPods (type in terminal):

sudo gem install cocoapods

Sudo means "super user do", it will require your password. Enter when requested.

Next, you need to setup the cocoapods master repo. Type in terminal:

pod setup --verbose // verbose option logs the setup progress

then create a pod file in your project directory (you can type "cd " and drag the project folder to the terminal window if your not comfortable with writing the path):

cd User/Projects/YourProject // make way to your project dir

pod init 

then inside the Podfile (find it in project directory) insert:

platform :ios, '8.0'
use_frameworks!

target 'YouAppTarget' do
    pod 'CSVImporter', '~> 1.7'
end

(Uncomment platform :ios, '8.0' Uncomment user_frameworks! if you're using Swift)

Run (while in your project dir):

pod install

Xcode .xcworkspace file will be generated, thats it, you can open it and use the framework ;]

later on you can update lib with:

pod update

2. Carthage [Offical Guide]

Steps to install a framework via Carthage are pretty similar to CocoaPods, follow the 'Offical Guide' link to see what's the differences are. A downside about this dependency manager is that not all libs are available. Some are only available for CocoaPods, but majority of new ones are supporting Carthage. P.S. Here's a good article on the differences.

3. Swift Package Manager [Offical Overview/Guide]

SPM is a native dependency manager, it's cross-platform, officaly-supported by Apple, decentralized and open-source.

It was planned as a replacement for CocoaPods and Carthage so I'd give it a try too.

Sign up to request clarification or add additional context in comments.

22 Comments

bu wheres the advantage against download "it" and include it in the swift project?
@Blub tons of advantages: 1. Periodical improvements/bugfixes from creator and community 2. Language changes and if you migrate to a new version and the lib will not be updated you will have to download it again, drag to the project etc. 3. Once you'll get used to pods and terminal you'll be adding frameworks to your project in a few minutes and this will exclude lots of error that may occur while you're adding the library manually. 4. Via pod file you can easily manage versions of all your libraries, remove unwanted etc. There's more but I advise you to discover it on your own ;]
but I have a few questions: 1. what is a pod file? 2. should i write all the code you have written in the terminal?
1. Basically a text file named Podfile, generated after you do the "pod init" command in terminal. 2. Almost, I've updated the answer a bit so that it's more simple to understand. It's just a few lines of code in terminal ;)
but when i type sudo gem install cocoapods in terminal it wants a passwort
|
0

You can drag the CSVImporter.xcodeproj and drop it into your project, also include CSVImporter in the embedded binaries.

3 Comments

What do Zoe mean with drop it in the project? I don't know where to do this!
1. *you 2. what do you mean with include CSVImporter in the embedded binaries? Could you explain it for me?
Are you using XCode?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.