Migration of a project on SwiftPM with 3 in-house frameworks

Hi,
I am trying to migrate a iOS project to SwiftPM using Xcode 12.
In this project I have several in-house frameworks.
These frameworks are also shared with other projects.

The project I'm migrating looks like these:

  • An helper framework (named THelpers)
  • An UI framework (named TUIComponents) which depends on the helper framework
  • A business framework (nammed TBusiness) which depends on the helper framework and the UI framework. This framework have also some Storyboards and xcassets.
  • The application (nammed TApp) which has the 3 frameworks in dependency

The THelpers Package.swift file is defined as follows

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "THelpers",
    platforms: [.iOS(.v11)],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "THelpers",
            type: .dynamic,
            targets: ["THelpers"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "THelpers",
            dependencies: []),
        .testTarget(
            name: "THelpersTests",
            dependencies: ["THelpers"]),
    ]
)

The TUIComponents Package.swift file is defined as follows

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "TUIComponents",
    platforms: [.iOS(.v11)],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "TUIComponents",
            type: .dynamic,
            targets: ["TUIComponents"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://gitlab.mycompagny.com/THelpers.git", .branch("migration_to_swiftpm")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "TUIComponents",
            dependencies: [
                .product(name: "THelpers", package: "THelpers")
            ]),
        .testTarget(
            name: "TUIComponentsTests",
            dependencies: ["TUIComponents"]),
    ]
)

The TBusiness Package.swift file is defined as follows

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "TBusiness",
    platforms: [.iOS(.v11)],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "TBusiness",
            type: .dynamic,
            targets: ["TBusiness"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://gitlab.mycompagny.com/THelpers.git", .branch("migration_to_swiftpm")),
        .package(url: "https://gitlab.mycompagny.com/TUIComponents.git", .branch("migration_to_swiftpm")),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "TBusiness",
            dependencies: [
                .product(name: "THelpers", package: "THelpers")
                .product(name: "TUIComponents", package: "TUIComponents")
            ]),
        .testTarget(
            name: "TBusinessTests",
            dependencies: ["TBusiness"]),
    ]
)

The TApp is defined as an xcodeproj and in the "Swift Packages" section I just put

Name: TBusiness, Version Rules: migration_to_swiftpm, Location https://gitlab.mycompagny.com/TBusiness

In the "Swift Packages Dependencies" I can see:

THelpers      migration_to_swiftpm
TUIComponents migration_to_swiftpm
TBusiness     migration_to_swiftpm

At the SwiftPM level all looks good. I see my different packages.

Where it is less good is when I look in the TApp/Frameworks folder of the application binary because I only see TBusiness.framework when I thought I had THelpers.framework, TUIComponents.framework and TBusiness.framework.

I ran the command nm TBusiness.framework/TBusiness and I found the symbols for THelpers, TUIComponents and TBusiness there.

My questions:
Are my Packages.swift correct?
Does TBusiness.framework contain also the binary for THelpers and TUIComponents?
Do I also need to add TUIComponents and THelpers in the "Swift Packages" section of xcodeproj?
If I add TUIComponents in the "Swift Packages" section of xcodeproj I'll have 2 times the binary of TUIComponents and THelpers?

Knowing that personally I want to have 3 separate frameworks each with its own binary and especially NOT a big framework with all in it

Thank you in advance for your answers

Terms of Service

Privacy Policy

Cookie Policy