[Swift] DAY16: Public Libraries and modularity

Source: Internet
Author: User
Tags uikit

Common libraries and modular static libraries and dynamic libraries

First, add the knowledge of the static and dynamic libraries. I am not familiar with this part of the content, no development experience, such as the wrong welcome to face.

Static Library

The code of the Static library is appended to the executable file, and multiple copies of it are used to make redundant copy.

The advantage is that the application package itself can run independently, but the downside is that the package is slightly bloated and the library cannot be shared.

The static library in IOS is in the form of. A and. Framework (the. Framework that you create is a static library).

. A

. A files need to provide header files and resource files when they are actually used. This is the way it was provided by default in Xcode. However, compiling a static library only supports a specific hardware architecture, and if you want to generate a Universal static library, you need to combine multiple static libraries with a tool. And the use of the time need to cooperate with the. h file, in contrast to the framework will be a better choice.

Framework

The framework can contain not only binary files, but also header files, resource files, and even multiple versions. However, each application uses its own common library, which ultimately requires the link into the executable file, so it is essentially a static library.

Dynamic Library

Dynamic library code and executable files are separate, the program run by the system dynamically loaded into memory, the system is loaded only once, multiple programs shared memory savings.

The advantages and disadvantages of dynamic libraries in contrast to static libraries, dynamic-link libraries require a library environment, but because they do not integrate library content, they are small and also provide the possibility to use shared libraries with other applications.

The dynamic library in IOS is in the form of. Dylib and. Framework (the system's. Framework is a dynamic library).

Present situation

For security reasons, AppStore does not allow the use of third-party dynamic-link libraries. We can write our own public libraries through the framework. As Xcode6 begins to support the new framework, it is no longer necessary to manually configure it. Ios-universal-framework also announced the discontinuation of the update.

Module

modularity (modules) was presented in the 2012 LLVM developers meeting. Simple is to use the tree-shaped structure of the description to replace the previous flat-type   #include   encapsulates the framework to address the weakness and extensibility of previous methods. (This paragraph I do not quite understand, just translated a bit ...) )

Take UIKit as an example, module.map presumably like this:

Framework module UIKit {Umbrella Header"UIKit.h"     Module * {export *}Link Framework"UIKit"}

use   @import  . It must be a huge project if all the code needs to be rewritten, so Apple has done this part of the work ahead of time. As long as the iOS7 SDK is used, the Enable Modules is turned on and then the original   #import  , the compiler will automatically convert the possible places to modules when compiling.

Writing here, I suddenly forgot what I was thinking ... Go too far, forget why the first set off to rub.

So that's it.

References
  • Module System of Swift
  • How iOS creates and uses static libraries
  • dynamic-link libraries and static-link libraries in iOS development
  • WWDC2014 iOS using dynamic libraries
  • Can you build the dynamic libraries for IOS and the load them at runtime?
  • Xcode6 making dynamic and static framework
  • What ' s new in Xcode 6
  • Talk about OBJC Common library
  • Talk about the development of libraries in iOS
  • Frameworks
  • How to Create Frameworks/modules in Xcode 6 and IOS 8
  • What happened before the iOS program main function
  • Write Swift Module Cont. Static Library
  • Introduction to Objective-c Modules
  • Waht ' s New in Objective-c and Foundation in IOS 7
  • Ray:what ' s New in Objective-c and Foundation in IOS 7
  • WWDC Session Notes-new features for XCODE5 and OBJC

[Swift] DAY16: Public Libraries and modularity

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.