Fastlane, invoke multiple platforms

Viewed 347

I have a React Native project. I am able to build iOS and Android builds like so:

fastlane android build
fastlane ios build

However, here is what I want to do, so both iOS and Android are built.

fastlane all build

Here's what a simplified version of my Fastfile looks like:

default_platform(:android)

platform :android do
  desc "Simply build a release apk"
  lane :build do |options|
    gradle(
        project_dir: "android",
        task: "clean assemble",
        build_type: "Release",
    )
  end
end

platform :ios do
  desc "Simply build a release ipa"
  lane :build do |options|
    build_app(workspace: "ios/myproject.xcworkspace")
  end
end

I'm being told that this is all Ruby code, and I should be able to do whatever I want. So, I want "all" to invoke both Android and iOS. However, I do not know any Ruby, so your help would be much appreciated.

1 Answers

The only way I've found to achieve this is to get rid of platforms altogether and create 3 separate lanes:

desc 'Build iOS and Android'
lane :build do
  build_android
  build_ios
end

desc 'Compiles the Android project'
lane :build_android do
   ....
end

desc 'Compiles the iOS project'
lane :build_ios do
  ....
end

I know this defeats the purpose of having platforms but I've not yet found a neater way of doing this since it does not appear to be possible to call lanes in a platform block from outside that block.

Related