Where I got stuck with Swift Package Manager support

Introduction

――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

environment

Xcode 12.2
Build version 12B45b
Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8)

OS branch

--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

Calling Bundle

--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

Reference link

Recommended Posts

Where I got stuck with Swift Package Manager support
Where I got stuck in today's "rails tutorial" (2020/10/08)
Where I got stuck in today's "rails tutorial" (2020/10/05)
Where I got stuck in today's "rails tutorial" (2020/10/06)
Where I got stuck in today's "rails tutorial" (2020/10/04)
I got stuck when port forwarding with VBox
Where I got stuck in today's "rails tutorial" (2020/10/07)
I got stuck in File
I got stuck trying to write a where in clause in ActiveRecord
I built a rails environment with docker and mysql, but I got stuck
I tried using Realm with Swift UI
Let's use Swift Package Manager (SwiftPM) ~ Creation ~
Let's use Swift Package Manager (SwiftPM) ~ Introduction ~
I got stuck while studying Java SE 7/8 Bronze
I got stuck trying Volley's synchronization process (Java)