Swift Package는 원래 소스코드 자체를 배포할 수 있는 상황에서만 사용 가능했다.
XCFramework?
사용시 고려사항
XCFramework 만들기
Build Libraries for distribution 키기
원본
import UIKit
public class Spaceship {
public let name: String
private var currentLocation: Location
public init(name: String) {
self.name = name
currentLocation = .launchpad
}
public func fly(
to destination: Location,
speed: Speed) {
currentLocation = destination
}
}
public enum Speed {
case leisurely
case fast
}
public struct Location {
public var coordinated: Coordinates
}
swift module interface
// swift-interface-format-version: 1.0
// swift-compiler-version: Swift version 5.1
// swift-module-flags: -target arm64-apple-ios13.0 -enable-library-evolution -swift-version 5 -O -module-name FlightKit
import Swift
import UIKit
public class Spaceship {
public let name: Swift.String
public init(name: Swift.String)
public func fly(
to destination: FlightKit.Location,
speed: FlightKit.Speed)
@objc deinit
}
// 연관값이 없을 경우 Hashable이 자동으로 추가됨
public enum Speed: Swift.Hashable {
case leisurely
case fast
public static func ==(
a: FlightKit.Speed,
b: FlightKit.Speed) -> Swift.Bool
public func hash(into hasher: inout Swift.Hasher)
}
public struct Location {
public var coordinated: FlightKit.Coordinates
}
아카이브 하기
릴리즈 모드로 빌드한다.
Xcode Organizer에서 찾을 수 있다.
dSYM 정보를 가지고 있게 된다.
CLI로 빌드하기
xcodebuild archive \\
-scheme FlightKit \\
-destination "..." \\
-destination "..." \\
...
SKIP_INSTALL=NO \\ # 이게 있어야 아카이브 안에 framework가 존재한다.
xcframework로 엮어내기
xcodebuild -create-xcframework \\
-framework [path] \\
-framework [path] \\
...
-output FlightKit.xcframework
프레임워크 작성시 고려사항