――Swift Package Manager is being handled more and more in iOS application development. In the future, I think that the number of existing libraries compatible with Swift Package Manager will increase. I summarized the addictive points in making the library compatible
Xcode 12.2
Build version 12B45b
Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8)
--Since Swift Package Manager supports OS other than iOS, some frameworks do not support it, so branching is essential.
#if os(iOS)
import UIKit
class HogeView: UIView {
}
#endif
--Since Swift 5.3, resource files such as images and xib are supported. --With support, the way Bundles are called in the Swift Package Manager has changed. Calls such as images and Xib require branching. SwiftGen has also been changed for support.
#if SWIFT_PACKAGE && swift(>=5.3)
let bundle = Bundle.module
#else
let bundle = Bundle(for: Hoge.self)
#endif
Recommended Posts