This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
SMF-Fastlane-Commons is a collection of reusable Fastlane lanes and tools for mobile app development across iOS, Android, and Flutter platforms. This repository serves as a shared library that gets cloned into projects as a git submodule.
This is a Ruby-based Fastlane project with no package.json or traditional build system. The primary way to work with this code is through Fastlane lanes:
# Test individual lanes (run from a project that uses these commons)
fastlane <lane_name>
# Example: Test iOS unit tests lane
fastlane smf_ios_unit_tests
# Test platform-specific setup
fastlane smf_setup_dependencies_pr_check-
Setup Files (
setup/): Platform-specific entry points that define the main lanes called by Jenkinsapple_setup.rb- iOS/macOS lanesandroid_setup.rb- Android lanesflutter_setup.rb- Flutter lanesios_framework_setup.rb- iOS framework lanes
-
Commons (
commons/): Reusable lane implementations organized by function- Platform-specific subdirectories (
ios/,android/,macos/) - Shared functionality (
smf_build_app/,smf_git_changelog/, etc.) - Reporting tools (
reporting/)
- Platform-specific subdirectories (
-
Fastlane Core (
fastlane/):Fastfile- Main entry point with platform detection and commons importingutils/- Shared utility functionsAPIs/- External API integrations (GitHub, JIRA)constants/- Global constants and environment variable keys
- Naming Convention: All custom functions/lanes start with
smf_prefix - Private Functions: Functions used only within a file are prefixed with
_smf_ - Platform Detection: Uses
@platformvariable to determine iOS/Android/Flutter context - Configuration: Reads from
Config.jsonin the consuming project via@smf_fastlane_config
The repository uses a dynamic import system based on platform:
smf_import_commonsfunction determines platform from@platformvariable- Clones/updates the commons repo to project-specific location:
- iOS/macOS:
<workspace>/.fastlane-smf-commons - Android/Flutter:
<workspace>/.idea/.fastlane-smf-commons
- iOS/macOS:
- Imports all Ruby files from commons, utils, APIs, and tools directories
- Loads platform-specific setup file
- Projects provide a
Config.jsonfile with build variants and settings - Accessed via
@smf_fastlane_configglobal variable - Helper function
smf_config_get(build_variant, *keys)for nested access - Platform-specific required/optional keys defined in constants
Most lanes follow this structure:
private_lane :smf_example_lane do |options|
# Extract all parameters to variables at the beginning
build_variant = options[:build_variant]
target_value = options[:target_value]
# Lane implementation
UI.message("Processing #{build_variant}")
# ... lane logic
end- Global error handler in
Fastfilesends failures to Slack channels - Platform-specific error channels defined in constants
- Exception handling via
smf_handle_exceptionlane
Since November 2025, Android builds use Git tags as the source of truth for version codes instead of committing Config.json on every build. This eliminates 18-54 commits per week across all client projects.
Location: commons/smf_version_management/smf_get_next_version_code.rb
Functions:
-
smf_get_next_version_code_from_tags(platform)- Queries all Git tags matching
build/*/*pattern - Extracts highest version code
- Returns
highest + 1 - Fallback to Config.json if no tags exist
- Queries all Git tags matching
-
smf_is_ci?()- Detects CI environment (Jenkins, GitHub Actions, etc.)
- Checks for
BUILD_NUMBER,CI,JENKINS_HOMEenvironment variables
-
smf_get_current_version_code_from_apk(apk_path)- Extracts version code from built APK using
aapt - Used for Git tag creation after build
- Extracts version code from built APK using
smf_super_build (setup/android_setup.rb):
# CI: Use Git tags for version code
if smf_is_ci?
version_code = smf_get_next_version_code_from_tags('android')
else
version_code = @smf_fastlane_config[:app_version_code]
end
smf_build_android_app(
build_variant: variant,
keystore_folder: keystore_folder,
version_code: version_code # NEW parameter
)smf_build_android_app (commons/smf_build_app/smf_build_android_app.rb):
- Now accepts optional
version_codeparameter - Passes version code to Gradle as property
- Project must support
project.hasProperty("versionCode")in build.gradle.kts
smf_super_pipeline_increment_build_number (setup/android_setup.rb):
- Now skips Config.json increment for CI builds (no-op)
- Only increments for local builds
- Marked as deprecated for CI use
smf_super_pipeline_create_git_tag (setup/android_setup.rb):
- CI: Extracts version code from built APK (not Config.json)
- Fallback to Git tags if extraction fails
- Local: Uses Config.json (backward compatible)
build.gradle.kts:
versionCode = if (project.hasProperty("versionCode")) {
project.property("versionCode").toString().toInt() // From Fastlane
} else {
(configJson?.get("app_version_code") as? Int) ?: 1 // Fallback
}Jenkins Jobs:
- Can stop calling
smf_pipeline_increment_build_numberlane - Version code is automatically managed via Git tags
- No Config.json commits needed
- Before: 18-54 Config.json commits per week (9 countries × 2-6 builds each)
- After: 0 Config.json commits, only lightweight Git tags
- Backward Compatible: Local builds still use Config.json
- Sequential: Version codes remain sequential and unique
build/android/{variant}/{versionCode}
Examples:
build/android/de_alpha/3549
build/android/tr_beta/3550
build/android/it_live/3551
Version code not incrementing:
- Check Git tags:
git tag -l 'build/*/*' | sort -V | tail -10 - Ensure tags are pushed to remote
- Verify
smf_is_ci?returns true in CI environment
Config.json still being committed:
- Verify SMF-Fastlane-Commons is updated to latest version
- Check that
smf_pipeline_increment_build_numberis not called by Jenkins - CI environment detection should work automatically
- Each lane/tool has its own directory with a README.md explaining usage
- When modifying lanes, update the corresponding README
- Follow the existing naming conventions and code style
- Test changes in a consuming project before committing
- Use single quotes over double quotes for strings
- Assign all lane parameters to variables at the beginning of functions