Fattaneh Talebi
Fattaneh Talebi

Reputation: 767

How to add frameworks into the Swift project?

I want to add a library to my Swift project. I found 3 different places to add.
I want to know the correct way to do this and the purpose of each one.

General tab

select the target -> general

Build phase

select the target -> build phase

New copy file phase

select the target -> click on + button -> select "New copy file phase"

Questions

  1. When do I need to "Embed binaries" and "Linked frameworks and libraries"? and when do I need to do the build phase one?
  2. Do I need to do multiple of these things to add a framework?
  3. What is the difference between them?

Upvotes: 7

Views: 15176

Answers (2)

Ghous Ansari
Ghous Ansari

Reputation: 59

"Binary" means: compiled code — as opposed to "source code", which is what you are working with when you write code as text.

They could have given you source code and let you compile it, but they didn't; they are keeping the source code secret, so they've given it all to you after compilation, so that you can't read it.

"Embedded" means: to be included inside your app bundle, by copying them into it at build time.

So, they are handing you some compiled code (frameworks) and telling you how to include them inside your app bundle. These frameworks, unlike Cocoa's frameworks, do not already exist on the device, so if you don't include them inside the app, they won't be present and your app would be unable to call into them.

Contrast this to Cocoa's frameworks. They, too, are compiled code. But they do already exist on the device. Therefore they are not embedded inside your app; they are merely linked (and, if they appeared, would appear in the next group, Linked Frameworks and Libraries). What are Embedded Binaries in Xcode?

Upvotes: 4

Rohit
Rohit

Reputation: 2326

1.Select the project file from the project navigator on the left side of the project window.

2.Select the target for where you want to add frameworks in the project settings editor.

3.Select the “Build Phases” tab, and click the small triangle next to “Link Binary With Libraries” to view all of the frameworks in your application.

4.To Add frameworks, click the “+” below the list of frameworks.

5.To select multiple frameworks, press and hold the command key while using the mouse to click the desired frameworks.

enter image description here

Upvotes: 5

Related Questions