Sha256: 1cf387c009f9c50d64ba6b8103c4c5d56315314e3e09c26058c44c12cfa24381

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

class XcconfigGenerator
    def initialize(brand_key)
        @brand_key = brand_key
        @platform = SolaraSettingsManager.instance.platform
    end

    def generate
        Solara.logger.start_step("Generate Brand.xcconfig for iOS")
        destination = IOSFilePathManager.instance.brand_xcconfig
        content = generate_xcconfig_content
        File.write(destination, content)
        Solara.logger.debug("🎉 Generated #{IOSFilePathManager.instance.brand_xcconfig}. Content below ⬇️")
        Solara.logger.debug("--------------\n#{content}--------------")
        Solara.logger.end_step("Generate Brand.xcconfig for iOS")
    end

    private

    def generate_xcconfig_content
        content = <<~XCCONFIG
          ASSETCATALOG_COMPILER_APPICON_NAME = Artifacts/AppIcon
          #{load_config.map { |key, value| "#{key.upcase} = #{value}" }.join("\n")}
        XCCONFIG

        case @platform
        when Platform::Flutter
            # "../Generated.xcconfig" is the config related to Flutter itself, we must include it here.
            <<~XCCONFIG
              #include "../Generated.xcconfig"

              #{content}
            XCCONFIG
        when Platform::IOS
            content
        else
            raise ArgumentError, "Invalid platform: #{@platform}"
        end
    end

    def load_config
        config_path = FilePath.ios_config(@brand_key)
        JSON.parse(File.read(config_path))
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solara-0.2.0 solara/lib/core/scripts/platform/ios/xcconfig_generator.rb
solara-0.1.0 solara/lib/core/scripts/platform/ios/xcconfig_generator.rb