Upload
naver-d2
View
2.722
Download
5
Embed Size (px)
Citation preview
Swift 도입기
Static Library에서 Dynamic Framework로 전환
WWDC 2014, Swift 등장
iOS 개발자 반응은?
WWDC 2015
대세 언어, Swift!
2014 20162015
대세 언어, Swift 도전!
Objective-C 로 되어 있는 Legacy Code는 어떻게 하지?
Swift 와 Objective-C 함께 사용할 수 있을까?
그리고 열심히 공부하면서 Swift로 개발하기 시작하였습니다.
var width = selected?320:200
NSUInteger width = selected?320:200;# Objective-C
# Swift
var width = selected ? 320:200
var width = selected?320:200
헛, 근데 우리는 Library 잖아.
CocoaPods 로 배포하던 SmartEditor 3.0
Swift 도입 후, 수많은 빨간색 느낌표를 만나게 되다.
Library
• a set of routines, external functions and variables
• static library (statically-linked library)
• dynamic library (shared library)
• frameworks (static, dynamic)
static library
• packaged into the code of the main executable
• linked at compile time
• only code
• images/assets/header files은 따로 배포
• 같은 Library 일지라도 실행파일별로 메모리에 로드
dynamic library
• linked at runtime
• shared amongst multiple processes
• OS X :".dylib"
• Windows : ".dll"
• iOS에서는 일반적으로 지원하지 않는다.
Apple은 왜 dynamic library를 iOS에서 금지시켰을까?
The reason is security.
• malicious code executing by a hacker
• unapproved features to an approved app.
• you could download and load it.
It's not a technical limitation,
but an App Store Policy limitation.
Frameworks
• a collection of code and resources to encapsulate functionality
• Libraries only has executable code
• a framework is a bundle (Directory structure)
• dynamic libraries, headers and other resources.
(static) Frameworks
• Before iOS8, only allowed static libraries for iOS.
• the idea of creating 'static frameworks'.
• static libraries with the convenience of bundling the headers files along.
"iOS developers can now create dynamic frameworks."
- New Features in Xcode 6, by Apple
SmartEditor 3.0 for iOS
CocoaPods 로 배포 중
• static library 로 빌드하여 배포
• 리소스는 Main Bundle 에 복사
Swift를 포함한 코드는 static library 로 빌드가 불가능
• Swift standard runtime libraries 가 iOS에 비포함.
• App 빌드시점에 App Bundle에 runtime library를 복사
• Swift를 포함한 앱은 Objective-C Only 앱보다 용량이 큰 이유
• runtime library가 없거나 버전이 다르면 Swift 를 포함한 Framworks는 문제가 발생
- CocoaPods 0.36 - Framework and Swift Support
"frameworks instead of static libraries by specifying use_frameworks!"
Podfile
use_frameworks! 그후
1. Frameworks 로 전환이 안되는 다른 dependency 가 존재
• 네이버로그인 • ApiGatewayHMAC
2. 리소스가 모두 Framework Bundle에 존재
네이버로그인 라이브러리
• static library를 포함하여 배포 중으로 frameworks로 전환이 불가능
• 서비스앱 (블로그, 포스트) 프로젝트에 수작업으로 static Library와 UI코드/리소스를 추가
• SmartEditor 3.0에서는 delegate를 통해 로그인 모듈 접근
Frameworks Bundle
• SmartEditor 3.0 에 포함되어 있는 리소스는 MainBundle이 아닌 Frameworkd Bundle에 존재
• + (NSBundle *)bundleForClass:(Class)aClass 를 통해 Framework Bundle에 접근
• [UIImage imageNamed:@""] 는 Main Bundle의 리소를 가져오도록 되어 있어 SEImage Class를 새로 만듬.
Static Library Linking
Dynamic Library Linking
감 사 합 니 다.