简体   繁体   中英

Basic Mechanics of iOS Frameworks and Xcode (and Swift)

I think I just must be stupid.

I'm having a lot trouble understanding very basic things concerning frameworks in Xcode/iOs/Swift. While I've certainly gotten some things to work, I've gotten more and more confused about what I'm actually doing. And the documentation on the web just confuses me more.

When I see discussions about how to import particular frameworks (eg https://github.com/danielgindi/Charts is the library I'm playing with, but I've seen this pattern repeated in other libraries) they seem to always tell me include the Xcode project file as a child project of my project, in addition to linking things as an embedded binary. This confuses me. Is it not possible to link an already compiled framework to my project without including all the source code of the project?

That is, can't I just take a library.framework file, and add it to my embedded libraries list and be done with it?

In the frameworks I've played with (again https://github.com/danielgindi/Charts is my primary example, but this is true in many others I've played with) I can't seem to use the framework without Carthage or CocoaPods. For me at this stage, that is just confusing... I accept that they are useful tools to automate a difficult process, but I'd really like to understand what that process actually is before I let a tool automate it for me. As I search the web I just seem to always be led back to these tools as being the correct way to do things.

So here are my questions.

  1. If I find a framework library on the web... do I need its source code or can I somehow just link to a compiled version of the framework?

  2. In my reading, it seems that libraries made with Swift are somehow second-class citizens because Swift is a newer thing. Is that still the case? (The articles I read about this seems to date from 2014-2015).

  3. Is there are good place to understand how Apple expects me to add a framework to a project, without using CocoaPods or Carthage?

  1. No need to add source code. Just add the framework to Target ->
    General -> Linked Framework and Libraries -> Tap on + and select your framework.
  2. In my opinion, many new libraries are being written is Swift. So you won't be left behind for using swift.
  3. Apple has documentation about adding frameworks to XCode . But I would suggest to use Cocoapods , as its easy to manage libraries.

Cheers :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM