Installation - admiral-team/admiralui-ios GitHub Wiki

Learn how to install AdmiralUI

You can install AdmiralUI by following package managers:

  • SPM
  • CocoaPods

Swift Package Manager

By UI Xcode:

File -> Swift Packages -> Add Package Dependency
Снимок экрана 2023-03-10 в 12 07 43

Package.swift:

dependencies: [
    .package(url: “https://github.com/admiral-team/admiralui-ios.git”, .upToNextMajor(from: “version”))
]

Choice Frameworks:

  • If you need UI components for UIKit, you must add library AdmrialUIKit.
  • If you need UI components for SwiftUI, you must add library AdmiralSwiftUI.
  • If you need resource such as symbols, you must add library AdmiralSymbols.
  • If you need resource such as images, you must add library AdmiralImages.
  • If you need use color themes and service for dynamic change, you must add library AdmiralTheme.
Снимок экрана 2023-03-13 в 10 06 06

CocoaPods

  1. Add to Podfile:
  • UIKit:
pod 'AdmiralTheme', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralImages', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralSymbols', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralUIKit', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralCore', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
  • SwiftUI:
pod 'AdmiralTheme', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralImages', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralSymbols', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralSwiftUI', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
  • SwiftUI and UIKit:
pod 'AdmiralTheme', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralImages', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralSymbols', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralSwiftUI', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
pod 'AdmiralUIKit', :git => 'https://github.com/admiral-team/admiralui-ios.git', :branch => 'main'
  1. Run command in terminal:
pod install

Nexus

1. Add file .netrc to the home directory to store your credentials for private repository in Nexus.

2. Add url, username and password to the .netrc and save:

Снимок экрана 2023-03-17 в 18 11 58

You should ask the admin for a Nexus link.

3. Create package and add it to the project:

Снимок экрана 2023-03-17 в 18 14 56

Снимок экрана 2023-03-17 в 18 16 35

Don't forget to add created package to the FrameWorks, Libraries and Embedded Content in general settings of your target:

Снимок экрана 2023-03-17 в 18 18 22

4. Modify the package.json file of created package:

  import PackageDescription

  let admiralSwiftUI: Target = .binaryTarget(
    name: "AdmiralSwiftUI",
    url: "the url path of the zip archive",
    checksum: "the sha256 hash"
  )

  let admiralTheme: Target = .binaryTarget(
    name: "AdmiralTheme",
    url: "the url path of the zip archive",
    checksum: "the sha256 hash"
  )

  let admiralSymbols: Target = .binaryTarget(
    name: "AdmiralSymbols",
    url: "the url path of the zip archive",
    checksum: "the sha256 hash"
  )

  let admiralUIImages: Target = .binaryTarget(
    name: "AdmiralImages",
    url: "the url path of the zip archive",
    checksum: "the sha256 hash"
  )

  let package = Package(
    name: "Admiral",
    platforms: [
        .iOS(.v13),
    ],
    products: [
        .library(
            name: "Admiral",
            targets: [
                "Admiral",
                "AdmiralSymbols",
                "AdmiralImages",
                "AdmiralTheme",
                "AdmiralSwiftUI"
            ]
        ),
    ],
    dependencies: [
    ],
    targets: [
        .target(
            name: "Admiral"
        ),
        admiralSwiftUI,
        admiralTheme,
        admiralSymbols,
        admiralUIImages
    ]
  )

The checksum of the binaryTarget can be found in package info sha256:

Снимок экрана 2023-03-17 в 18 30 11

5. Build the project and run.

Connect SPM with binaryTarget

  1. Start by creating a new Swift Package Manager project or open an existing one.
  2. In the Package.swift file, add the binaryTarget declaration for each binary framework that you want to include in your project. In the example code provided, there are five binary targets defined: AdmiralSwiftUI, AdmiralTheme, AdmiralUIResources, AdmiralUIKit, and AdmiralCore.
  3. Each binaryTarget declaration should include the following parameters:
  • name: The name of the binary target.
  • url: The URL where the binary framework can be downloaded.
  • checksum: The SHA-256 checksum of the downloaded binary.

You can find the required checksum in the file https://github.com/admiral-team/admiralui-ios/blob/main/checksum.json

  1. After adding the binaryTarget declarations, specify the targets that will use the binary targets. In the example code provided, the Admiral target depends on four other targets, including the five binary targets defined earlier.
  2. Save your changes to the Package.swift file.
  3. Open your Xcode project and select the project file in the project navigator.
  4. In the main pane, select the project or target that you want to add the binary targets to.
  5. In the "General" tab, scroll down to the "Frameworks, Libraries, and Embedded Content" section.
  6. Click the "+" button to add a new framework or library.
  7. Select "Add Other" from the drop-down menu.
  8. Click the "Add Files" button.
  9. Navigate to the directory where your binary frameworks are located.
  10. Select the binary framework that you want to add and click "Open".
Снимок экрана 2023-04-04 в 10 05 20

So you can see an example: https://github.com/admiral-team/admiralui-ios/tree/main/Examples/AdmiralSPMRecource

Finally, build and run your project to make sure everything is working correctly. That's it! You have successfully connected SPM with binaryTarget in your project.

⚠️ **GitHub.com Fallback** ⚠️