Skip to content

Instantly share code, notes, and snippets.

@asciimike
Last active July 11, 2022 13:28
Show Gist options
  • Save asciimike/1f0799e38d1e96a993319da4645fa0b4 to your computer and use it in GitHub Desktop.
Save asciimike/1f0799e38d1e96a993319da4645fa0b4 to your computer and use it in GitHub Desktop.
Example of how to reference a CocoaPod in Bazel
ios_app(
name = "App",
hdrs = ["src/*.h"],
srcs = ["src/*.m"],
deps = [
"@SDWebImage//:latest_library",
],
)
ios_test(
name = "Test",
hdrs = ["test/*.h"],
srcs = ["test/*.m"],
deps = [
"@SDWebImage//:latest_library",
],
xctest = 1,
)
objc_xcodeproj(
name = "Project",
deps = [
":App",
":Tests",
],
)
# bazel build :Project builds the app and unit tests
# Based on https://github.com/rs/SDWebImage/blob/master/SDWebImage.podspec
new_git_repository(
name = "SDWebImage",
remote = "https://github.com/rs/SDWebImage.git",
build_file_content = """
objc_library(
name = "latest_library",
hdrs = glob(
["SDWebImage/{NS,SD,UI}*.h"],
exclude = ["SDWebImage/UIImage+WebP.h"],
),
srcs = glob(
["SDWebImage/{NS,SD,UI}*.m"],
exclude = ["SDWebImage/UIImage+WebP.m"],
),
sdk_frameworks = "ImageIO",
visibility = ["//visibility:public"],
)""",
)
{
"name": "SDWebImage",
"version": "3.7.1",
"platforms": {
"ios": "5.0"
},
"license": "MIT",
"summary": "Asynchronous image downloader with cache support with an UIImageView category.",
"homepage": "https://github.com/rs/SDWebImage",
"authors": {
"Olivier Poitrey": "[email protected]"
},
"source": {
"git": "https://github.com/rs/SDWebImage.git",
"tag": "3.7.1"
},
"description": "This library provides a category for UIImageView with support for remote images coming from the web. It provides an UIImageView category adding web image and cache management to the Cocoa Touch framework, an asynchronous image downloader, an asynchronous memory + disk image caching with automatic cache expiration handling, a guarantee that the same URL won't be downloaded several times, a guarantee that bogus URLs won't be retried again and again, and performances!",
"requires_arc": true,
"frameworks": "ImageIO",
"default_subspecs": "Core",
"subspecs": [
{
"name": "Core",
"source_files": "SDWebImage/{NS,SD,UI}*.{h,m}",
"exclude_files": "SDWebImage/UIImage+WebP.{h,m}"
},
{
"name": "MapKit",
"source_files": "SDWebImage/MKAnnotationView+WebCache.*",
"frameworks": "MapKit",
"dependencies": {
"SDWebImage/Core": [
]
}
},
{
"name": "WebP",
"source_files": "SDWebImage/UIImage+WebP.{h,m}",
"xcconfig": {
"GCC_PREPROCESSOR_DEFINITIONS": "$(inherited) SD_WEBP=1"
},
"dependencies": {
"SDWebImage/Core": [
],
"libwebp": [
]
}
}
]
}
@keith
Copy link

keith commented Sep 20, 2019

Yea we use this file with http_archive but git_repository would work just as well

@rockwotj
Copy link

For anyone who stumbles upon this again (hi Mike 👋) here's an updated BUILD file for the latest SDWebImage library

objc_library(
    name = "SDWebImage",
    srcs = glob(
        [
            "SDWebImage/Core/*.m",
            "SDWebImage/Private/*.m",
            "SDWebImage/Private/*.h",
        ],
        exclude = [],
    ),
    hdrs = glob(
        [
            "SDWebImage/Core/*.h",
        ],
        exclude = [],
    ),
    module_name = "SDWebImage",
    sdk_frameworks = [
        "ImageIO",
    ],
    includes = [
        "SDWebImage/Core",
        "SDWebImage/Private",
    ],
    visibility = ["//visibility:public"],
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment