App common dependency management tools

dependency management

As large as the entire App, as small as a function. As long as it can be reused to reduce the workload of repeated development, it can be extracted as a component library and reused in the form of a library or package.

Dependency management tools focus on components or libraries 名称, 版本, 仓库源(local or remote), declare dependent libraries in configuration files, and library versions, and manage the upgrade of dependent libraries.

Main functions of dependency management

  1. Automatic download and update: As the complexity of the project increases and the number of dependencies is huge, automatic download and update of dependencies and installation of dependencies can bring about a huge improvement in development efficiency.
  2. Use visual configuration files for library and version management
  3. Component version conflicts: Integrating multiple components at the same time, there is a possibility of version conflicts between components, and it is necessary to support the automatic conflict resolution function.

The following introduces the dependency management tools commonly used in App development

CocoaPods

image.pngThe most popular dependency manager for iOS/MacOS projects, built with Ruby, supports XCodedevelopment tools.

Official website address: Cocoapods

Install using the following command

sudo gem install cocoapods

Configuration file Podfile

platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
  pod 'AFNetworking', '~> 3.2'
  pod 'FMDB', '~> 2.7'
  pod 'SwiftyJSON', '~> 4.1'
end

Run the following command to install dependencies

pod install

Gradle

image.png

Java、Kotlin C++or in any language of your choice. A package management tool that can be deployed on any platform.

Automate using Gradle's rich API and mature ecosystem of plugins and integrations. Model, integrate and systematize the end-to-end delivery of software

The following development tools are supported:

  • Android Studio
  • I understand the idea
  • Eclipse
  • NetBeans

GoogleIntroduction Documentation: Gradle

configuration file:build.gradle

plugins {
    id 'com.android.application' // Android程序
    id 'org.jetbrains.kotlin.android' // 支持Kotlin
}

android {
    namespace 'com.baidu.gradlex'
    compileSdk 32

    defaultConfig { // App信息
        applicationId "com.baidu.gradlex"
        minSdk 23
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies { // 依赖库
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

pub

image.pngPub is the most commonly used dependency management tool in Flutterand Dartdevelopment. It covers various plug-ins commonly used in Flutter development, making it easy for developers to quickly introduce and reuse them.

Official website address: flutter pub cn

Installation: Flutter plugin comes with

configuration file:pubspec.yaml

name: flutter_luckin_coffee
description: flutter luckin coffee application
version: 1.0.0+1
environment:
  sdk: ">=2.10.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.4
  flutter_swiper: 1.1.6
  pull_to_refresh: ^2.0.0
  json_annotation: ^4.5.0
  dart_mock: ^2.0.0
  get: ^4.6.3

dev_dependencies:
  flutter_test:
    sdk: flutter
  test: any
  build_runner: ^2.1.11
  json_serializable: ^6.2.0
  
flutter:  
  uses-material-design: true

  assets: // 图片资源
    - lib/assets/images/
    - lib/assets/images/home/
    - lib/assets/images/menu/
    - lib/assets/images/mine/
    - lib/assets/images/order/

Download and update the pub repository

flutter pub get
flutter pub upgrade

brew

Homebrew is a free and open source package management system written by Max Howell in Ruby to simplify the software installation process on macOS systems. In the early days, Homebrew was only available for MacOS, and later a Linux version was introduced.

Official website address: github

Install

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Download and install the package

brew search 关键词 // 搜索软件包
brew install 软件名 // 安装

pip

image.png PythonA package management tool that provides functions for finding, downloading, installing, and uninstalling Python packages.

Official website and introduction page

npm

image.png Node.jsThe package management tool, its birth also greatly promoted the development of the front-end, and npm is inseparable from the modern front-end development.

Official website address: npmjs

Installation: download the installation package from the official website

// 查看npm版本
npm -v
// 安装软件包
npm install <package_name>

RubyGems

image.png

RubyA package manager, the packages or dependencies it manages are called gems.

ruby gems

gem install nokogiri

Maven

image.png

Maven – Welcome to Apache Maven

Maven project object model ( POM), a project management tool software that can manage project construction, reporting and documentation through a small piece of description information.

In addition to featuring program building capabilities, Maven also provides advanced project management tools. Due to the high reusability of Maven's default build rules, simple projects can often be built with two or three lines of Maven build scripts.

As a construction tool, Maven can not only help us automate the construction, but also abstract the construction process and provide construction task realization; it is cross-platform and provides a consistent operation interface externally, all of which are enough to make it an excellent and popular construction tool.

Maven is not only a build tool, but also a dependency management tool and project management tool. It provides a central warehouse and can help me download components automatically.

Guess you like

Origin juejin.im/post/7258182427306623035