Error Select is not iterable
dwirandyh opened this issue · 4 comments
I try to use apple_framework from rules_ios and my BUILD file is like this
# BUILD file
ios_xcode_framework_lib(
name = "AppboyPushStory",
hdrs = select({
"//Config:iphone-simulator": glob([
"AppboyPushStory/AppboyPushStory.xcframework/arm64_i386_x86_64-simulator/AppboyPushStory.framework/Headers/**/*.h"
]),
"//conditions:default": glob([
"AppboyPushStory/AppboyPushStory.xcframework/ios-arm64_armv7/AppboyPushStory.framework/Headers/**/*.h"
]),
}),
data = [
":AppboyPushStoryResources",
],
enable_modules = True,
deps = [
":AppboyPushStory_VendorFramework",
],
)
# lib.bzl
def ios_xcode_framework_lib(**kwargs):
# remove unsed arguments
kwargs = remove_unused_xcode_framework_args(["enable_modules", "umbrella_header"], **kwargs)
name = kwargs.pop("name", "")
module_name = kwargs.pop("module_name", name)
name = name + XCODE_LIB_SUFFIX
public_headers = kwargs.pop("hdrs", [])
deps = add_deps_suffix(kwargs.pop("deps", []))
# deps = kwargs.pop("deps", [])
print(name + " have deps: " + "*".join([str(item) for item in deps]) + ": end deps")
apple_framework(
name = name,
module_name = module_name,
visibility = ["//visibility:public"],
public_headers = public_headers,
deps = deps,
platforms = {"ios": MINIMUM_OS_VERSION},
**kwargs
)
but when i try to build the library i got error like this, i still don't know how to fix this
ERROR: Traceback (most recent call last):
File "/Users/dwi.herdinanto/ios-product/project/Pods/Appboy-Push-Story/BUILD", line 5, column 13, in <toplevel>
ios_objc_lib(
File "/Users/dwi.herdinanto/ios-product/project/bazel/ios_lib.bzl", line 13, column 28, in ios_objc_lib
ios_xcode_framework_lib(**kwargs_copy)
File "/Users/dwi.herdinanto/ios-product/project/bazel/ios_lib.bzl", line 76, column 20, in ios_xcode_framework_lib
apple_framework(
File "/private/var/tmp/_bazel_dwi.herdinanto/cace77b040ff6b91b67f77326ff7816f/external/build_bazel_rules_ios/rules/framework.bzl", line 97, column 28, in apple_framework
library = apple_library(
File "/private/var/tmp/_bazel_dwi.herdinanto/cace77b040ff6b91b67f77326ff7816f/external/build_bazel_rules_ios/rules/library.bzl", line 487, column 29, in apple_library
objc_hdrs = [f for f in public_headers if f.endswith((".inc", ".h", ".hh", ".hpp"))]
Error: type 'select' is not iterable
i'm stuck and need help to resolve this issue
Attributes like srcs
& public_headers
need to be iterable for the rules_ios macros to function. I'd suggest using something like https://github.com/bazel-ios/cocoapods-bazel to generate the declaration for this type of a dependency.
For example, in your case, it'd look something like this:
apple_framework(
name = "Appboy-Push-Story",
module_name = "Appboy_Push_Story",
platforms = {"ios": "10.0"},
resource_bundles = {"AppboyPushStory": glob(
["AppboyPushStory/Resources/**/*"],
exclude_directories = 0,
)},
vendored_xcframeworks = [
{
"name": "AppboyPushStory",
"slices": [
{
"identifier": "ios-arm64_i386_x86_64-simulator",
"platform": "ios",
"platform_variant": "simulator",
"supported_archs": [
"arm64",
"i386",
"x86_64",
],
"path": "AppboyPushStory/AppboyPushStory.xcframework/ios-arm64_i386_x86_64-simulator/AppboyPushStory.framework",
"build_type": {
"linkage": "static",
"packaging": "framework",
},
},
{
"identifier": "ios-arm64_x86_64-maccatalyst",
"platform": "ios",
"platform_variant": "maccatalyst",
"supported_archs": [
"arm64",
"x86_64",
],
"path": "AppboyPushStory/AppboyPushStory.xcframework/ios-arm64_x86_64-maccatalyst/AppboyPushStory.framework",
"build_type": {
"linkage": "static",
"packaging": "framework",
},
},
{
"identifier": "ios-arm64_armv7",
"platform": "ios",
"platform_variant": "",
"supported_archs": [
"arm64",
"armv7",
],
"path": "AppboyPushStory/AppboyPushStory.xcframework/ios-arm64_armv7/AppboyPushStory.framework",
"build_type": {
"linkage": "static",
"packaging": "framework",
},
},
],
},
],
visibility = ["//visibility:public"],
)
You can pass this to your custom macro/rule if you need to do mutations there via this in your Podfile
:
plugin 'cocoapods-bazel', {
rules: {
'apple_framework' => { load: '//:lib.bzl', rule: 'ios_xcode_framework_lib' }.freeze,
}.freeze,
}
hmm,, it seems work
but how about this
load("@build_bazel_rules_ios//rules:precompiled_apple_resource_bundle.bzl", "precompiled_apple_resource_bundle")
load("//bazel:ios_lib.bzl", "ios_objc_lib", "ios_swift_lib", "ios_apple_lib")
ios_apple_lib(
name = "DeveloperSettings",
srcs = glob([
"DeveloperSettings/**/*.m",
"DeveloperSettings/**/*.swift",
]),
hdrs = glob([
"DeveloperSettings/**/*.h",
]),
objc_copts = [
"-I$(BINDIR)/Modules/DeveloperSettings",
],
sdk_frameworks = [
"Combine",
"SwiftUI",
"UIKit",
],
data = [
":DeveloperSettingsResources",
],
deps = [
"//Modules/AppSharing:AppSharing",
"//Modules/TVLKit"
] + select({
"//Config:release": [],
"//conditions:default": ["//Pods/FLEX:FLEX"],
}),
)
so i should create 2 ios_apple_lib?
I'm not sure what you're asking. Can you clarify the question a bit?
Please reopen if this is still an issue.