Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add frameworks into the Swift project?

Tags:

ios

swift

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

  • Embed binaries
  • Linked frameworks and libraries

Build phase

select the target -> build phase

  • Embed frameworks
  • link binary with libraries

New copy file phase

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

  • choose the destination as a framework
  • select the framework

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?
like image 593
Fattaneh Talebi Avatar asked Jul 03 '18 10:07

Fattaneh Talebi


People also ask

How do I add a framework to a project in Xcode?

To include a framework in your Xcode project, choose Project > Add to Project and select the framework directory. Alternatively, you can control-click your project group and choose Add Files > Existing Frameworks from the contextual menu.

What are the frameworks available in Swift?

Swift is a multipurpose, multi-paradigm compiled language created by Apple Inc. It is used for macOS, iPadOS, iOS, watchOS, Linux, and tvOS. The team that developed it makes use of an open-source LLVM compiler framework.


2 Answers

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

like image 57
Wings Avatar answered Sep 30 '22 01:09

Wings


"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?

like image 39
Ghous Ansari Avatar answered Sep 30 '22 00:09

Ghous Ansari