【问题标题】:Building apps with Fastlane and Phonegap使用 Fastlane 和 Phonegap 构建应用程序
【发布时间】:2016-11-11 15:14:24
【问题描述】:

将 Fastlane 与 phonegap 应用构建集成的最简单方法是什么?在过去的两年里,我们一直只使用 phonegap 来手动构建我们的应用程序,这可能是一个乏味的过程。现在我们正在成长并且需要开始能够重新发布应用程序,我们正在寻找一种可以简化整个过程的快速/简单的解决方案。我在网络和 fastlane 存储库上进行了搜索,但我没有看到太多关于与 phonegap 集成的信息。任何信息或资源将不胜感激。

【问题讨论】:

    标签: cordova phonegap-build fastlane


    【解决方案1】:

    我们从一开始就使用 fastlane(从深圳等地迁移过来)和 Cordova(与 Phonegap 不太一样,但足够接近),并且发现它非常节省时间。我认为主要区别在于使用 phonegap 构建服务,理论上您可以使用 shell 命令通过 fastlane 调用该服务,尽管我建议在本地构建。

    我还建议使用他们的 brew 包安装 Fastlane。 (假设您使用的是 Mac)

    brew cask install fastlane

    在项目的根目录中运行:

    fastlane init

    这将设置一个主 fastlane 目录,您将在其中管理 Android 和 iOS。

    我们的目录结构如下:

    ── fastlane │   ├── Appfile │   ├── Deliverfile │   ├── Fastfile │   ├── Gymfile │   ├── Matchfile │   ├── Supplyfile │   └── metadata

    我们的快速文件看起来像这样:

    fastlane_version "2.1.1"
    
    default_platform :ios
    
    app_name = "REDACTED"
    app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
    
    platform :ios do
    
      lane :development_profiles do
        match(type: 'development', app_identifier: "#{app_identifier}")
        match(type: 'development', app_identifier: "#{app_identifier}.MessagesExtension")
      end
    
      lane :appstore_profiles do
        match(type: 'appstore', app_identifier: "#{app_identifier}")
        match(type: 'appstore', app_identifier: "#{app_identifier}.MessagesExtension")
      end
    
      lane :profiles do
        development_profiles
        appstore_profiles
      end
    
      lane :build_development do
        development_profiles
        gym(
          configuration: "Debug",
          output_name: "#{app_name}-development.ipa"
        )
      end
    
      lane :build_release do
        appstore_profiles
        gym(
          configuration: "Release",
          output_name: "#{app_name}-release.ipa"
        )
      end
    
      lane :hockeyapp do |options|
        hockey(
          ipa: "REDACTED",
          dsym: "REDACTED",
          api_token: "REDACTED",
          notes: "Build " + (ENV["BUILD_NUMBER"] ? ENV["BUILD_NUMBER"] + " " : "") + "From " + git_branch + " branch on " + Time.now.strftime('%F') + " at " + Time.now.strftime('%T'),
          notify: "0"
        )
      end
    
      lane :ci do
        build_development
        hockeyapp
      end
    
      lane :beta do
        build_release
        pilot
      end
    
      lane :release do
        deliver(
          ipa: "REDACTED",
          force: true,
          skip_metadata: true,
          skip_screenshots: true
        )
      end
    
      lane :screenshots do
        deliver(
          skip_binary_upload: true
        )
      end
    
      after_all do |lane|
      end
    
      error do |lane, exception|
      end
    end
    
    platform :android do
    
      lane :build_development do
        Dir.chdir ".." do
          sh("platforms/android/cordova/clean")
        end
        gradle(
          task: "cdvBuildDebug",
          project_dir: "platforms/android/",
          properties: {
            'android.useDeprecatedNdk' => true
          }
        )
        Dir.chdir ".." do
          sh("mkdir -p REDACTED/")
          sh("cp -f platforms/android/build/outputs/apk/android-armv7-debug.apk REDACTED/")
          sh("cp -f platforms/android/build/outputs/apk/android-x86-debug.apk REDACTED/")
        end
      end
    
      lane :build_release do
        Dir.chdir ".." do
          sh("platforms/android/cordova/clean")
        end
        gradle(
          task: "cdvBuildRelease",
          project_dir: "platforms/android/",
          properties: {
            'android.useDeprecatedNdk' => true
          }
        )
        Dir.chdir ".." do
          sh("mkdir -p REDACTED/")
          sh("cp -f platforms/android/build/outputs/apk/android-armv7-release.apk REDACTED/")
          sh("cp -f platforms/android/build/outputs/apk/android-x86-release.apk REDACTED/")
        end
      end
    
      lane :hockeyapp do |options|
        hockey(
          apk: "REDACTED",
          notes: "Build " + (ENV["BUILD_NUMBER"] ? ENV["BUILD_NUMBER"] + " " : "") + "From " + git_branch + " branch on " + Time.now.strftime('%F') + " at " + Time.now.strftime('%T'),
          notify: "0"
        )
      end
    
      lane :release do |options|
        supply(
          track: options[:track],
          apk_paths: ["REDACTED", "REDACTED"],
          skip_upload_metadata: true,
          skip_upload_images: true,
          skip_upload_screenshots: true
        )
      end
    
      lane :ci do
        build_development
        hockeyapp
      end
    
      after_all do |lane|
      end
    
      error do |lane, exception|
      end
    end
    

    关键在于,您将项目视为普通的原生项目,并以这种方式构建它。效果很好。

    【讨论】:

    • 在科尔多瓦根目录中运行 fastlane init 时,我收到一条错误消息,说明如何在子目录中找到 xcode 项目并在子目录中运行 fastlane init。我认为可以忽略错误? fastlane 目录确实创建了,虽然返回了这个错误但是文件夹是空的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    • 2016-01-10
    • 2011-11-09
    • 1970-01-01
    • 1970-01-01
    • 2016-06-23
    • 2013-07-16
    相关资源
    最近更新 更多