Excluding code from coverage stats in Xcode 7

Xcode7 and later (based on some forum posts), the coverage system uses LLVM’s coverage generation and reporting mechanisms, the format for which is detailed at http://llvm.org/docs/CoverageMappingFormat.html. As of Xcode 9, this format does not support any means of exclusion of lines (or other structures). The resulting mapping is exported into a consumable format (txt or … Read more

Compile Time Incredibly Slow

Update 1: I created a new project without running the Swift 3 conversion, imported my Swift 3 files, but the build time remains the same. Update 2: I’ve tried SWIFT_WHOLE_MODULE_OPTIMIZATION = YES, but as soon as you make changes to more than 1 file, the incremental build fails and it triggers a re-build which lasts … Read more

Get Weekday from Date – Swift 3

Presumably you have a Date already? let weekday = Calendar.current.component(.weekday, from: myDate) Maybe you want the name of the weekday? let f = DateFormatter() f.weekdaySymbols[Calendar.current.component(.weekday, from: Date()) – 1] The -1 is added at the end because Calendar.current.component(.weekday, from: Date()) returns values from 1-7 but weekdaySymbols expects array indices. Investigate the NSCalendar/DateComponents api or edit … Read more

Showing ‘UIActivityViewController’ in SwiftUI

The basic implementation of UIActivityViewController in SwiftUI is import UIKit import SwiftUI struct ActivityViewController: UIViewControllerRepresentable { var activityItems: [Any] var applicationActivities: [UIActivity]? = nil func makeUIViewController(context: UIViewControllerRepresentableContext<ActivityViewController>) -> UIActivityViewController { let controller = UIActivityViewController(activityItems: activityItems, applicationActivities: applicationActivities) return controller } func updateUIViewController(_ uiViewController: UIActivityViewController, context: UIViewControllerRepresentableContext<ActivityViewController>) {} } And here is how to use it. … Read more