{"id":13659464,"url":"https://github.com/Skeptick/libres","last_synced_at":"2025-04-24T14:33:21.370Z","repository":{"id":65657131,"uuid":"596690489","full_name":"Skeptick/libres","owner":"Skeptick","description":"Resources generation in Kotlin Multiplatform","archived":false,"fork":false,"pushed_at":"2025-04-09T12:36:59.000Z","size":175,"stargazers_count":218,"open_issues_count":36,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T13:36:28.954Z","etag":null,"topics":["android","ios","js","jvm","macos","tvos"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Skeptick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-02T18:21:02.000Z","updated_at":"2025-04-09T12:36:46.000Z","dependencies_parsed_at":"2023-02-17T23:15:26.016Z","dependency_job_id":"fd435930-8018-4ed4-b97f-d62b1baa1a60","html_url":"https://github.com/Skeptick/libres","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skeptick%2Flibres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skeptick%2Flibres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skeptick%2Flibres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skeptick%2Flibres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Skeptick","download_url":"https://codeload.github.com/Skeptick/libres/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250643741,"owners_count":21464228,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ios","js","jvm","macos","tvos"],"created_at":"2024-08-02T05:01:09.035Z","updated_at":"2025-04-24T14:33:21.364Z","avatar_url":"https://github.com/Skeptick.png","language":"Kotlin","readme":"# Libres\n\nResources generation in Kotlin Multiplatform.\n\n## Setup\n\n```kotlin\n// build.gradle.kts (project)\n\nbuildscript {\n    dependencies {\n        classpath(\"io.github.skeptick.libres:gradle-plugin:1.2.4\")\n    }\n}\n```\n\n```kotlin\n// build.gradle.kts (module)\n\nplugins {\n    id(\"io.github.skeptick.libres\")\n}\n\nlibres {\n    generatedClassName = \"MainRes\" // \"Res\" by default\n    generateNamedArguments = true // false by default\n    baseLocaleLanguageCode = \"ru\" // \"en\" by default\n    camelCaseNamesForAppleFramework = false // false by default\n}\n```\n\n## Jetpack Compose\n\n```kotlin\n// build.gradle.kts (module)\n\nkotlin {\n    commonMain {\n        dependencies {\n            implementation(\"io.github.skeptick.libres:libres-compose:1.2.4\")\n        }\n    }\n}\n```\n\nThis artifact provides `painterResource` function that can be used\nto get `Painter` from `io.github.skeptick.libres.Image` in common code.\n\n## Supported platforms\n\n- **Android**, **JVM**, **iOS**, **MacOS** and **JS** in Kotlin Multiplatform projects.  \n- Pure Android or JVM projects with Kotlin.\n\n## Requirements\n\n|                       |                               |\n|-----------------------|-------------------------------|\n| Kotlin                | 1.6.20+                       |\n| Android               | 4.1+ (API level 16)           |\n| Android Gradle Plugin | 7.0+                          |\n| iOS                   | 13+ (when using vector icons) |\n\n\\\n:bangbang: Also you need to use [CocoaPods](https://cocoapods.org/) and \n[CocoaPods Gradle plugin](https://kotlinlang.org/docs/native-cocoapods-dsl-reference.html) \nto export images to iOS application.  \nIf you aren't reusing images in iOS then this condition is optional.\n\n## Known issues\n\n### iOS\n:warning: Cocoapods caches list of resource directories when `pod install` is called,\nso bundles directory must exist at this time.\nYou won't see this issue if your `.podspec` is in `.gitignore`\nin any case it's best to be safe with this hook in your Podfile.\n\nSuppose your Kotlin Framework is added like this:\n```ruby\npod 'umbrella', :path =\u003e '../common/umbrella/umbrella.podspec'\n```\n\nThen this hook will look like this:\n```ruby\npre_install do |installer|\n  FileUtils.mkdir_p(installer.sandbox.root.to_s + '/../../common/umbrella/build/generated/libres/apple/libres-bundles')\nend\n```\n\n## Usage\n\nResources must be stored in `{yourSourceSetName}/libres`\n\nMultiplatform:\n```\n├── commonMain\n│   ├── kotlin\n│   └── libres\n│       ├── images\n│       │   ├── vector_image.svg\n│       │   └── raster_image.png\n│       └── strings\n│           ├── strings_en.xml\n│           └── strings_ru.xml\n```\n\nAndroid or JVM:\n```\n├── main\n│   ├── java\n│   └── libres\n│       ├── images\n│       │   ├── vector_image.svg\n│       │   └── raster_image.png\n│       └── strings\n│           ├── strings_en.xml\n│           └── strings_ru.xml\n```\n\n### Strings\nStrings are stored in usual for Android form in `xml` files.  \nThe file postfix must contain language code for which these strings are intended. E.g.: `my_app_strings_en.xml`  \nFor each of languages you can create several files and they will be merged during compilation.\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cresources\u003e\n    \u003cstring name=\"simple_string\"\u003eHello!\u003c/string\u003e\n    \u003cstring name=\"string_with_arguments\"\u003eHello ${name}!\u003c/string\u003e\n    \u003cplurals name=\"plural_string\"\u003e\n        \u003citem quantity=\"one\"\u003eresource\u003c/item\u003e\n        \u003citem quantity=\"other\"\u003eresources\u003c/item\u003e\n    \u003c/plurals\u003e\n\u003c/resources\u003e\n```\n\nKotlin:\n```kotlin\nMainRes.string.simple_string\nMainRes.string.string_with_arguments.format(name = \"John\")\nMainRes.string.plural_string.format(5)\n```\nSwift:\n```swift\nMainRes.shared.string.simple_string\n// or MainRes.shared.string.simpleString if `camelCaseNamesForAppleFramework` enabled\n```\n***\n\u003e **Note**\n\u003e In this example `MainRes.string.simple_string` will return a string, \n\u003e so for better localization support it's not recommended to store the value. \n\u003e Get it directly at the place where it's displayed in UI. \n\u003e This seems familiar but ability to work directly with strings instead of resource IDs can be misused.\n***\n#### [More about localization](docs/LOCALIZATION.md)\n\n### Images\n\nSupported formats:\n- PNG\n- JPG\n- WEBP (Android 4.3+, iOS 14+)\n- SVG (iOS 13+)\n\nFor Android SVGs are converted to \n[vector drawable](https://developer.android.com/develop/ui/views/graphics/vector-drawable-resources), \nfor other platforms they copied as is.\n\n#### Image modifiers\nThe image filename can contain modifiers in parentheses listed through underscores.\n\n\u003e **orig**\n\u003e \n\u003e Used for iOS. Marks image as `Original` (similar to `Render As: Original Image` in XCode Assets Manager). \nRecommended for multicolor images.\n\n\u003e **size**\n\u003e \n\u003e Applies to bitmaps. Reduces image resolution to specified size.\n\u003e - For Android generate images from mdpi to xxxhdpi (where mdpi is 1:1 in pixels to specified size)\n\u003e - For iOS generate images from @1x to @3x (where @1x is 1:1 in pixels to specified size)\n\u003e - For JVM and JS a single image of specified size is generated.\n\nFilename examples:\n```\nsome_hd_image_(100).jpg\napp_logo_(orig).svg\nmy_colorful_bitmap_(orig)_(150).png\n```\nKotlin:\n```kotlin\nMainRes.image.some_hd_image\nMainRes.image.app_logo\nMainRes.image.my_colorful_bitmap\n```\nSwift:\n```swift\nMainRes.shared.image.some_hd_image\n// or MainRes.shared.image.someHdImage if `camelCaseNamesForAppleFramework` enabled\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ch3\u003eWhy do I see a black/blue box instead of my picture?\u003c/h3\u003e\u003c/summary\u003e\n\nI'm pretty sure your picture is multicolor JPG/SVG with opaque background.  \nThis happens because UIKit recolors this image with accent color.\n\nSolution: add (orig) modifier to image filename, e.g.: `my_image_(orig).png`\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ch3\u003eHow to export bitmap from Figma?\u003c/h3\u003e\u003c/summary\u003e\n\nTo obtain bundle of PNG images with different resolutions (mdpi-xxxhdpi for Android and @1x-@3x for iOS) do following steps:\n1. Export image from Figma with x4 scale (it matches to the biggest used size — xxxhdpi on Android)\n2. Put it to `libres/images` package\n3. Remember the biggest side value of image represented in Figma\n4. Rename image with the value of the biggest side:  \n**pic.png** -\u003e **pic_(orig)_({side_value}).png** or **pic_({side_value}).png**\n\nSample:\nImage size in Figma is **240x89**. Final image name is **pic_(orig)_(240).png**\n\u003c/details\u003e\n","funding_links":[],"categories":["Libraries"],"sub_categories":["🛢 Resources"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSkeptick%2Flibres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSkeptick%2Flibres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSkeptick%2Flibres/lists"}