- 104: Whats new in Xcode
- 106: Whats new in swift
- 401: Swift and Objective-C Interoperability
- 403: Improving your Existing Apps with Swift
- 404: App Thinning in Xcode
- 406: UI Testing in Xcode
- 407: Implementing UI Designs in Interface Builder
- 414: Building Better Apps with Value Types in Swift
- 718: Building Responsive and Efficient Apps with GCD
104: Whats new in Xcode
- App Thinning
- Bitcode
- Slicing
- On Demand Resources
- Debugging and Profiling Tools
- Location Instrument
- Metal System Trace
- Address Sanitizer
106: Whats new in swift
-
Recursive enum can marked ‘indirect’
-
Error Handling
401: Swift and Objective-C Interoperability
403: Improving your Existing Apps with Swift
404: App Thinning in Xcode
App Slicing
- Executable Code(armv7, armv7s, arm64)
- Resources(image, Metal, OpenGL, Audio, Other Data)
- Named Data
- Store arbitrary file content
- Classify according to hardware capabilities
- Use NSDataAsset class to retrieve content in your application
On Demand Resources
- Asset packs are built by Xcode
- Can contain any non-executable assets Hosted by the App Store
- Downloaded when needed
- Reclaimed as appropriate
- Device-thinned just like the other content
Build Workflow
- Build
- Xcode Build and Run automatically thins resources for the active run destination.
- Supported for all simulator and device run destinations.
- ENABLE_ONLY_ACTIVE_RESOURCES target build setting
- Distributing Thinned Applications
- App Store Purchase
- TestFlight
- Ad-hoc/Enterprise Distribution
- Xcode Server
- Ad-hoc/Enterprise Distribution
- Export thinned variants for all compatible devices
- Save for Ad-Hoc/Enterprise with distribution manifest option
Note:
移动网络不能下载大于150M App的官方定义: over-the-air size limits
406: UI Testing in Xcode
- UI testing
- Find and interact with UI elements
- Validate UI properties and state
- UI recording
- Test reports
- Core Technologies
- XCTest
- Accessibility
XCUIApplication
- Proxy for the tested application
- Tests run in a separate process
- Always spawns a new process
407: Implementing UI Designs in Interface Builder
- Design Time
- Stack Views, Dynamic Type(Font body, headline…), Advanced Navigation(option+shift+click),
- Build Time
- XML Documents Build to Nib Files.
- Loading Storyboards At Run Time.
- Performance. Nib files loaded on demand.
- Reuse. Nib files enable reuse.
- Life cycle. Know when objects are created.
- Run Time
414: Building Better Apps with Value Types in Swift
Reference Semantics
Copy When You Need It
- Manual Copying
- Defensive Copying in Cocoa and Objective-C
- NSDictionary calls -copy on its keys
- Property copy attribute provides defensive copying on assignment
Immutability: Cocoa[Touch] has a number of immutable classes
- NSDate, NSURL, UIImage, NSNumber, etc.
- Improved safety (no need to use copy)
Value Semantics
- Variables Are Logically Distinct
- Mutating one variable of some value type will never affect a different variable
- Value types should implement Equatable
Copies Are Cheap
- Copying a low-level, fundamental type is constant time.
- Int, Double, etc
- Copying a struct, enum, or tuple of value types is constant time.
- CGPoint, etc.
- Extensible data structures use copy-on-write
- Copying involves a fixed number of reference-counting operations
- String, Array, Set, Dictionary, etc.
A Value Type Can Contain a Reference
- Immutable References
- Use deep equality comparisons(
isEqual
)
- Use deep equality comparisons(
- References to Mutable Objects
- Copy-on-Write
Copy-on-Write
// Mutable Object; NSobject
struct BezierPath {
private var _path = UIBezierPath()
var pathForReading: UIBezierPath {
return _path
}
var pathForWriting: UIBezierPath {
mutating get {
_path = _path.copy() as! UIBezierPath
return _path
}
}
}
extension BezierPath {
var isEmpty: Bool {
return pathForReading.isEmpty
}
mutating func addLineToPoint(point: CGPoint) {
self.pathForWriting.addLineToPoint(point: point)
}
}
// Uniquely Referenced Swift Objects
// The isKnownUniquelyReferenced(_:) function is useful for implementing the copy-on-write optimization for the deep storage of value types:
class Box<T> {
let unbox: T
init(_ value: T) {
unbox = value
}
}
class Foo: NSObject {
var count: Int = 0
}
struct Counter {
private var _counter = Box(Foo())
mutating func increment() {
// copy the reference only if necessary
if !isKnownUniquelyReferenced(&_counter) {
let old = _counter
_counter = Box(Foo())
_counter.unbox.count = old.unbox.count
}
_counter.unbox.count += 1
}
var value: Int {
return _counter.unbox.count
}
}
718: Building Responsive and Efficient Apps with GCD
- Quality of Service Introduction
- QoS can be specified on Blocks and on queues
- dispatch_async() automatically propagates QoS
- Some priority inversions are resolved automatically
-
在串行队列中添加高优先级的任务,如果当前队列还有低优先级的任务,则会提高队列的整体优先级,直到该任务到达。
- GCD Design Patterns with QoS
- Threads, Queues, and Run Loops
- GCD and Crash Reports