Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apple_framework_packing with link_dynamic=true will cause error #702

Open
wendyliga opened this issue May 3, 2023 · 7 comments
Open

apple_framework_packing with link_dynamic=true will cause error #702

wendyliga opened this issue May 3, 2023 · 7 comments

Comments

@wendyliga
Copy link

wendyliga commented May 3, 2023

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
@mattrobmattrob
Copy link
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?

@thiagohmcruz
Copy link
Contributor

+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!

@wendyliga
Copy link
Author

wendyliga commented May 4, 2023

@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

@mattrobmattrob
Copy link
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")

@mattrobmattrob
Copy link
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"],
)

@wendyliga
Copy link
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.

@acecilia
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants