Three Layers Of Packages, With All Static Libraries
Here is the GitHub link to the PackageConsumer
project Version 7.0.0. You can check out that version, and reproduce the results here.
Here is the source code for the Package_D.swift
file, Version 3.0.0:
import Foundation import Package_A import Package_C public struct Package_D: PackageProtocol { public let indent: Int public let text: String public init(indent inIndent: Int = 0) { indent = inIndent let prefix = String(repeating: "\t", count: inIndent) text = "\(prefix)Package_D, Version: 3.0.0\n" + Package_C(indent: inIndent + 1).text + "\n" + Package_A(indent: inIndent + 1).text } }
Here is the source for the Package_D
, Version 3.0.0 Package.swift
file:
import PackageDescription let package = Package( name: "Package_D", platforms: [ .iOS(.v11), .tvOS(.v11), .macOS(.v10_14), .watchOS(.v5) ], products: [ .library(name: "Package-D", targets: ["Package_D"]) ], dependencies: [ .package(name: "Package_C", url: "git@github.com:LittleGreenViper/SMPArticle-Package_C.git", from: "3.0.0") ], targets: [ .target( name: "Package_D", dependencies: [ .product(name: "Package-C", package: "Package_C") ] ), .testTarget( name: "Package_DTests", dependencies: [ "Package_D" ] ) ] )
Here is the source code for the Package_C.swift
file, Version 3.0.0:
import Foundation import Package_A public struct Package_C: PackageProtocol { public let indent: Int public let text: String public init(indent inIndent: Int = 0) { indent = inIndent let prefix = String(repeating: "\t", count: inIndent) text = "\(prefix)Package_C, Version: 3.0.0\n" + Package_A(indent: inIndent + 1).text } }
Here is the source code for Package_A
, version 2.0.0:
import Foundation public protocol PackageProtocol { var text: String { get } var indent: Int { get } } public struct Package_A: PackageProtocol { public let indent: Int public let text: String public init(indent inIndent: Int = 0) { indent = inIndent let prefix = String(repeating: "\t", count: inIndent) text = "\(prefix)Package_A, Version: 2.0.0" } }
Here is the source for PackageConsumer.swift
, Version 7.0.0:
import Foundation import Package_D struct PackageConsumer { let text: String init(text intext: String = "PackageConsumer, Version 7.0.0") { text = intext + "\n" + Package_D(indent: 1).text } }
When we run that, we get something like this:
PackageConsumer, Version 7.0.0 Package_D, Version: 3.0.0 Package_C, Version: 3.0.0 Package_A, Version: 2.0.0 Package_A, Version: 2.0.0
In this case, we do not need to disable Hardened Runtime, in order to run this in Xcode. Since all the libraries are static, they are integrated into the main executable.