Skip to content

apple_framework_packing with link_dynamic=true will cause error #702

Open

Description

@wendyliga
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("@build_bazel_rules_ios//rules:framework.bzl", "apple_framework_packaging")

swift_library(
    name = 'BarLib',
    module_name = 'Bar',
    srcs = glob(['**/*.swift']),
    visibility = ['//visibility:public'],
)

apple_framework_packaging(
    name = "Bar",
    framework_name = "Bar",
    bundle_id = "com.example.bar",
    infoplists = ["Info.plist"],
    link_dynamic = True,
    deps = [
        ":BarLib",
    ],
    platforms = {"ios": "12.0"},
    transitive_deps = [],
    visibility = ["//visibility:public"],
)

the error

Error in getattr: 'platform_types' value has no field or method ''
Available attributes: catalyst, ios, macos, tvos, watchos

Activity

  1. mattrobmattrob commented on May 3, 2023

    @mattrobmattrob
    Collaborator

    I don't see any reference to platform_types in the rules_ios codebase. Can you give more of the error message or a reproduction in rules_ios for us to debug, @wendyliga?

  2. thiagohmcruz commented on May 3, 2023

    @thiagohmcruz
    Member

    +1 couldn't find any reference to platform_types in rules_ios nor in rules_apple or the Bazel command line 🤔, a repro would be great!

  3. wendyliga commented on May 4, 2023

    @wendyliga
    Author

    @mattrobmattrob @thiagohmcruz sure, i have created a simple project here and run bazel build //src/Bar to reproduce the issue.

    fyi: I could find any test case for this specific configuration; the one available is for static packing.

    this is the full log and the stack trace

    ERROR: /Users/wendy.liga/Developer/simple_bazel/src/Bar/BUILD:11:26: in apple_framework_packaging rule //src/Bar:Bar: 
    Traceback (most recent call last):
            File "/private/var/tmp/_bazel_wendy.liga/8284c4a94ccbbb579b9e33d50d39273c/external/build_bazel_rules_ios/rules/framework.bzl", line 1031, column 48, in _apple_framework_packaging_impl
                    bundle_outs = _bundle_dynamic_framework(ctx, is_extension_safe = is_extension_safe, avoid_deps = avoid_deps)
            File "/private/var/tmp/_bazel_wendy.liga/8284c4a94ccbbb579b9e33d50d39273c/external/build_bazel_rules_ios/rules/framework.bzl", line 635, column 84, in _bundle_dynamic_framework
                    bundle_name, bundle_extension = bundling_support.bundle_full_name_from_rule_ctx(ctx)
            File "/private/var/tmp/_bazel_wendy.liga/8284c4a94ccbbb579b9e33d50d39273c/external/build_bazel_rules_apple/apple/internal/bundling_support.bzl", line 56, column 55, in _bundle_full_name_from_rule_ctx
                    rule_descriptor = rule_support.rule_descriptor(ctx),
            File "/private/var/tmp/_bazel_wendy.liga/8284c4a94ccbbb579b9e33d50d39273c/external/build_bazel_rules_apple/apple/internal/rule_support.bzl", line 867, column 28, in _rule_descriptor
                    platform_type = getattr(apple_common.platform_type, ctx.attr.platform_type)
    Error in getattr: 'platform_types' value has no field or method ''
    Available attributes: catalyst, ios, macos, tvos, watchos
    
  4. mattrobmattrob commented on May 4, 2023

    @mattrobmattrob
    Collaborator

    Why are you using apple_framework_packaging directly instead of this?

    load("@build_bazel_rules_ios//rules:framework.bzl", "apple_framework")
    
    apple_framework(
        name = "Bar",
        srcs = glob(['**/*.swift']),
        bundle_id = "com.example.bar",
        infoplists = ["Info.plist"],
        link_dynamic = True,
        platforms = {"ios": "12.0"},
        visibility = ["//visibility:public"],
    )

    And, similarly, you should be using the rules_ios.ios_application macro if you want to support packaging in rules_ios things:

    load("@build_bazel_rules_ios//rules:app.bzl", "ios_application")
    
  5. mattrobmattrob commented on May 4, 2023

    @mattrobmattrob
    Collaborator

    Additionally, it seems like you're mixing a lot of rules_apple/rules_swift native stuff with rules_ios things. Why are you doing that vs. just using entirely rules_ios? For example, you can swap the RxRelay definition over to something like this:

    apple_framework(
    name = "BasicXCFrameworkDynamic",
    module_name = "BasicXCFrameworkDynamic",
    platforms = {"ios": "10.0"},
    sdk_frameworks = [
    "Foundation",
    "SafariServices",
    "UIKit",
    "WebKit",
    ],
    vendored_xcframeworks = [
    {
    "name": "BasicXCFrameworkDynamic",
    "slices": [
    {
    "identifier": "ios-arm64",
    "platform": "ios",
    "platform_variant": "",
    "supported_archs": ["arm64"],
    "path": "BasicXCFrameworkDynamic.xcframework/ios-arm64/BasicXCFrameworkDynamic.framework",
    "build_type": {
    "linkage": "dynamic",
    "packaging": "framework",
    },
    },
    {
    "identifier": "ios-arm64_x86_64-simulator",
    "platform": "ios",
    "platform_variant": "simulator",
    "supported_archs": [
    "arm64",
    "x86_64",
    ],
    "path": "BasicXCFrameworkDynamic.xcframework/ios-arm64_x86_64-simulator/BasicXCFrameworkDynamic.framework",
    "build_type": {
    "linkage": "dynamic",
    "packaging": "framework",
    },
    },
    ],
    },
    ],
    visibility = ["//visibility:public"],
    )

  6. wendyliga commented on May 9, 2023

    @wendyliga
    Author

    @mattrobmattrob my usecase is to generate a precompiled framework, you should use apple_framework_packing right?
    regarding the mixing of the rules, I think the target //src/Bar is quite isolated. the repo is exist before, i just reuse it for showing this case.

  7. acecilia commented on Jul 26, 2023

    @acecilia
    Contributor

    I am also interested on this: how to generate a precompiled framework for third party distribution

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions