GithubHelp home page GithubHelp logo

line / rules_apple_line Goto Github PK

View Code? Open in Web Editor NEW
206.0 19.0 22.0 228 KB

LINE's Apple rules for Bazel

License: Apache License 2.0

Makefile 0.89% Starlark 96.31% Python 2.80%
apple bazel bazel-rules ios objc swift mixed-language

rules_apple_line's Introduction

LINE's Apple rules for Bazel

This repository contains additional rules for Bazel that can be used to bundle applications and frameworks for Apple platforms.

Overview

These are open references of what are used to build the LINE iOS app, which solve some of our specific use-cases, for instance, mixed Objective-C and Swift modules. They can be used as drop-in replacements for the official Apple rules when needed, with the goal of being easy to switch back to the official ones when we longer need them.

They may not work with certain revisions of rules_apple or rules_swift due to their breaking changes. If they don't work out-of-the-box for you, use them as references for your custom rule's implementation.

Build Definitions

Library Rules

Bundling Rules

Other Rules

Requirements

Bazel 4.0+

Setup

  • Setup rules_apple.

  • Add the following to your WORKSPACE file, replacing <commit> with the commit you wish to depend on and <sha256> with the expected SHA-256 of the zip file.

RULES_APPLE_LINE_COMMIT = "<commit>"

http_archive(
    name = "rules_apple_line",
    sha256 = "<sha256>",
    strip_prefix = "rules_apple_line-%s" % RULES_APPLE_LINE_COMMIT,
    url = "https://github.com/line/rules_apple_line/archive/%s.zip" % RULES_APPLE_LINE_COMMIT,
)

load(
    "@rules_apple_line//apple:repositories.bzl",
    "rules_apple_line_dependencies",
)

rules_apple_line_dependencies()

Examples

See the examples directory.

License

Copyright 2020 LINE Corporation

LINE Corporation licenses this file to you under the Apache License,
version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at:

   https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.

See LICENSE for more detail.

rules_apple_line's People

Contributors

asa avatar giuk-jung avatar luispadron avatar maxwelle avatar omarzl avatar thii avatar tinder-maxwellelliott avatar vikage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rules_apple_line's Issues

Facing pathing issues with modules-includes when building for application

Hello There,

I am facing an issue with module-includes pathing when I am building an ios_application rule using objc_static_framework. I am seeing the following issue:

<module-includes>:3:9: note: in file included from <module-includes>:3:
#import "../../../../../external/Branch/Branch-SDK/Branch-SDK/BNCCommerceEvent.h"
        ^
OMITTED/external/Branch/Branch-SDK/Branch-SDK/BNCCommerceEvent.h:9:9: error: 'BNCServerRequest.h' file not found
#import "BNCServerRequest.h"
        ^
OMITTED/TestHarnessViewController.swift:9:8: error: could not build Objective-C module 'Branch'
import Branch

With the following Folder structure:

tree -d ios-branch-deep-linking-attribution-0.33.1/Branch-SDK/Branch-SDK
├── BNCCommerceEvent.h
├── BNCCommerceEvent.m
..Some File omitted for brevity
├── Branch.h
├── Branch.m
├── Networking
..Some File omitted for brevity
│   ├── BNCServerRequest.h
│   ├── BNCServerRequest.m
│   └── Requests
..Some File omitted for brevity
│   ├── BranchCPIDRequest.h
│   ├── BranchCPIDRequest.m

Now I am able to build the backing ObjC library and the Framework for this dependency, yet when I import this code into ios_application via apple_library it cannot build. I have tried flattening the directory structure and that did make it work (i.e. Moving all files to a single directory), this would be my easiest option but this is an external dependency I do not own.

Oddly enough I also got this to work by placing this single objc_static_framework as a dependency of another objc_library rule and importing that into an ios_application rule. This will not work for my project since my App is pure swift

Am I missing something here? I have tried adding paths to includes but I get the same error.

Color set in .xcassets not available

I set resources = ["//examples/ios/App/Sources:Assets"] in ios_application

ios_application(
    name = "App",
    app_icons = ["//examples/ios/App/Sources:AppIcon"],
    bundle_id = select(APP_IDENTIFIER),
    bundle_name = select(APP_EXECUTABLE_NAME),
    extensions = [
        "//examples/ios/App/ShareExtension:ShareExtension_appex",
    ],
    families = [
        "iphone",
        "ipad",
    ],
    infoplists = ["//examples/ios/App/Sources:PreprocessedInfoPlist"],
    linkopts = select({
        "//examples/ios/App/Configuration:Debug": [],
        # Speed up link time of the app. The exported symbol list is only
        # needed for an app if you're using that app as the bundle loader in tests.
        "//conditions:default": [
            "-exported_symbols_list",
            "/dev/null",
        ],
    }),
    minimum_os_version = DEFAULT_MINIMUM_OS_VERSION,
    version = ":version",
    visibility = ["//visibility:public"],
    resources = ["//examples/ios/App/Sources:Assets"],
    watch_application = "//examples/ios/App/WatchKitApp",
    deps = ["//examples/ios/App/Sources:Main"],
)
filegroup(
    name = "Assets",
    srcs = glob([
      "**/*.xcassets",
    ],
    exclude = [
      "Assets.xcassets/*.appiconset/**",
    ]),
    visibility = ["//visibility:public"],
)

Color set in .xcassets not available, only the picture works.

view.backgroundColor = UIColor(named: "primary")

Swift code is not being compiled or archived

Hello I have 3 libraries, one in Objective-C (Amplitude-iOS), other one in Swift (ObjectMapper) and a mixed one (RxSwift + a dummy .m file)

I am running the following command

bazel build //:Amplitude-iOS //:ObjectMapper //:RxSwift --python_version=PY3 --cpu=ios_x86_64 --apple_platform_type=ios --verbose_failures --sandbox_debug --subcommands --ios_minimum_os=12.0

And when I look in the bazel-bin directory there are only two .a files: libAmplitude-iOS.a and libRxSwift.a

If a run ar -t with the libAmplitude-iOS.a I see that there are 14 .o files which corresponds with the number of .m source files

omarzl@mbp-omar exported_libs % ar -t bazel-bin/libAmplitude-iOS.a                                                                                                                                                            
__.SYMDEF
AMPConstants_69d0a734354b5db134c2893a4161a6d7.o
AMPDatabaseHelper_3ce394e8374a71ca185335530daf03f7.o
AMPDeviceInfo_6941f9a7f4f2f9c7b05ffb59cfcae914.o
AMPIdentify_b6e25ffb9a47bb738a3110067cbd6bdf.o
AMPLocationManagerDelegate_d6cc0574ce7b251a1a0de43f5096b8d9.o
AMPRevenue_edcc78e5e6939b0865f93de2b3781aa9.o
AMPTrackingOptions_5923c90a5ee0e9d29a35228ca584be61.o
AMPURLConnection_29b1a1224fd7ccf7036a8f66da53774f.o
AMPURLSession_ae5a05de96254d84934ab2d6e7a0ea27.o
AMPUtils_42cfe63f40eb632317ac07b38e0c9099.o
Amplitude_33a97a094c115fc384cad215184f0fbd.o
ISPCertificatePinning_5256c1810f4cd79ee1a3e3ed5f000abd.o
ISPPinnedNSURLConnectionDelegate_99c34a6f04fbfca446535d93f055ea8b.o
ISPPinnedNSURLSessionDelegate_d802e965b4b973ebb90843b7ad6c755a.o

But if I run ar -t with the libRxSwift.a library there is only the dummy m file but no swift object files are being archived

omarzl@mbp-omar exported_libs % ar -t bazel-bin/libRxSwift.a      
__.SYMDEF SORTED
RxSwift-dummy_e151122338dca6ddb0d82612c1760f0d.o

And finally with the target ObjectMapper that is swift only, there is no .a file and don't see it is compiling the code at all.

image

WORKSPACE

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
    name = "build_bazel_rules_apple",
    remote = "https://github.com/bazelbuild/rules_apple.git",
    commit = "18fbeadb089638eb2248de6e7685e0d4415c21cc",
)

git_repository(
    name = "build_bazel_rules_swift",
    remote = "https://github.com/bazelbuild/rules_swift.git",
    commit = "cd66dc7c0aa6010f56676dbb89091f882d4ec9c5",
)

git_repository(
    name = "rules_apple_line",
    remote = "https://github.com/line/rules_apple_line.git",
    commit = "d6a7706751634b938cb28fa666c4e04e1aeb4832",
)

load(
    "@build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)

swift_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:extras.bzl",
    "swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

load(
    "@rules_apple_line//apple:repositories.bzl",
    "rules_apple_line_dependencies",
)

# If you want to lock apple_support, rules_apple and rules_swift to specific
# versions, be sure to call this function after their repository rules.
rules_apple_line_dependencies()

BUILD.bazel

load("@rules_apple_line//apple:apple_library.bzl", "apple_library")
load("@rules_apple_line//apple:objc_library.bzl", "objc_library")
load("@rules_apple_line//apple:swift_library.bzl", "swift_library")

objc_library(
    name = "Amplitude-iOS",
    srcs = glob([
        "Amplitude-iOS/Sources/Amplitude/*.m",
        "Amplitude-iOS/Sources/Amplitude/SSLCertificatePinning/*.m",
    ]),
    hdrs = [
        "Amplitude-iOS/Sources/Amplitude/AMPConstants.h",
        "Amplitude-iOS/Sources/Amplitude/AMPDatabaseHelper.h",
        "Amplitude-iOS/Sources/Amplitude/AMPDeviceInfo.h",
        "Amplitude-iOS/Sources/Amplitude/AMPIdentify.h",
        "Amplitude-iOS/Sources/Amplitude/Amplitude+SSLPinning.h",
        "Amplitude-iOS/Sources/Amplitude/Amplitude.h",
        "Amplitude-iOS/Sources/Amplitude/AMPLocationManagerDelegate.h",
        "Amplitude-iOS/Sources/Amplitude/AMPRevenue.h",
        "Amplitude-iOS/Sources/Amplitude/AMPTrackingOptions.h",
        "Amplitude-iOS/Sources/Amplitude/AMPURLConnection.h",
        "Amplitude-iOS/Sources/Amplitude/AMPURLSession.h",
        "Amplitude-iOS/Sources/Amplitude/AMPUtils.h",
        "Amplitude-iOS/Sources/Amplitude/SSLCertificatePinning/ISPCertificatePinning.h",
        "Amplitude-iOS/Sources/Amplitude/SSLCertificatePinning/ISPPinnedNSURLConnectionDelegate.h",
        "Amplitude-iOS/Sources/Amplitude/SSLCertificatePinning/ISPPinnedNSURLSessionDelegate.h",
    ],
    copts = [
        "-w",
        "-Xanalyzer",
        "-analyzer-disable-all-checks",
    ],
    enable_modules = True,
    module_name = "Amplitude_iOS",
    sdk_dylibs = ["sqlite3.0"],
    visibility = ["//visibility:public"],
)

swift_library(
    name = "ObjectMapper",
    srcs = glob([
        "ObjectMapper/Sources/*.swift"
    ]),
    enable_modules = True,
    module_name = "ObjectMapper",
    visibility = ["//visibility:public"],
)

apple_library(
    name = "RxSwift",
    srcs = glob(
        [
            "RxSwift/RxSwift/**/*.swift",
            "RxSwift/Platform/**/*.swift",
            "RxSwift/RxSwift-dummy.m",
        ],
        exclude = [
            "RxSwift/RxSwift/Platform/**/*.swift",
        ],
    ),
    enable_modules = True,
    module_name = "RxSwift",
    objc_copts = [
        "-w",
        "-Xanalyzer",
        "-analyzer-disable-all-checks",
    ],
    visibility = ["//visibility:public"],
)

What I am missing? How could I make that all the targets generate an .a static archive?

I am using the latest commit for all the rules and here are the files to test with.

bazel_libs.zip

`mixed_static_framework` fail to import generated -Swift.h file.

Hello!

I have an issue when trying to use mixed_static_framework to be used with https://github.com/mxcl/PromiseKit

Layout

.
├── PromiseKit
│   └── BUILD
└── WORKSPACE

Build

load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("@rules_apple_line//apple:mixed_static_framework.bzl", "mixed_static_framework")
load("@rules_apple_line//apple:objc_library.bzl", "objc_library")

# Using Mixed Static Framework

mixed_static_framework(
    name = "PromiseKit",
    module_name = "PromiseKit",
    srcs = glob([
        "Sources/**/*.m",
        "Sources/**/*.swift",
    ]),
    hdrs = glob([
        "Sources/**/*.h",
    ]),
    objc_copts = [
        "-Ibazel-out/apl-darwin_x86_64-dbg/bin/PromiseKit",  # i expect this is wrong
        "-IPromiseKit/Sources"
    ],
)

Building with bazel build //PromiseKit throws these errors

Use --sandbox_debug to see verbose messages from the sandbox
PromiseKit/Sources/AnyPromise.m:4:13: error: 'PromiseKit/PromiseKit-Swift.h' file not found with <angled> include; use "quotes" instead
    #import <PromiseKit/PromiseKit-Swift.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            "PromiseKit/PromiseKit-Swift.h"
PromiseKit/Sources/AnyPromise.m:6:9: fatal error: 'PMKCallVariadicBlock.m' file not found
#import "PMKCallVariadicBlock.m"
        ^~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
Target //PromiseKit:PromiseKit failed to build
INFO: Elapsed time: 8.808s, Critical Path: 8.57s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

Ideally this should works since -Swift.h file is generated (inside bazel-out). As for importing .m file I've got suggestion to add search header path but still doesn't work or I am understand it wrong.

Importing rules_apple_line doesn't work

After the headermap patch was added, it appears that importing fails. I import the library with:

    http_archive(
        name = "rules_apple_line",
        sha256 = "aaca7310c31733adace87393ace44dceef4bc18a315e2799d1de1bb56f65592f",
        strip_prefix = "rules_apple_line-200c811e5543c31769220617432425b4ae5e01db",
        url = "https://github.com/line/rules_apple_line/archive/200c811e5543c31769220617432425b4ae5e01db.tar.gz",
    )

And I get the error:

ERROR: An error occurred during the fetch of repository 'com_github_ob_rules_ios':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_meisel/f86a8c8f171499aca10fad369fca25ea/external/bazel_tools/tools/build_defs/repo/git.bzl", line 182, column 10, in _git_repository_implementation
		patch(ctx)
	File "/private/var/tmp/_bazel_meisel/f86a8c8f171499aca10fad369fca25ea/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 135, column 22, in patch
		ctx.patch(patchfile, strip)
Error in patch: Not a regular file: /Users/meisel/projects/c/third_party/rules_ios.patch
ERROR: Skipping '//base/Kids:KidsNew': no such package '@com_github_ob_rules_ios//rules': Not a regular file: /Users/meisel/projects/c/third_party/rules_ios.patch
ERROR: no such package '@com_github_ob_rules_ios//rules': Not a regular file: /Users/meisel/projects/c/third_party/rules_ios.patch

So, it looks like //third_party:rules_ios.patch is interpreted to be in my workspace, and not that of rules_apple_line's

Compile metal_library error - No attribute 'platform_type' in attr. Make sure you declared a rule attribute with this name.

Hi LINE Engineers,
I have another problem when compile metal_library with rules_apple_line.
Current my solution is copy your rules to build my custom rules and fix this issue. But it not good.

ERROR: /Users/thanhvu/Desktop/test/metal/BUILD:3:14: in metal_library rule //metal:MetalResource:
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_thanhvu/14020c955c9a251a040f84610e66eb94/external/rules_apple_line/apple/metal_library.bzl", line 51, column 83, in _metal_library_impl
		platform_prerequisites = platform_support.platform_prerequisites_from_rule_ctx(ctx)
	File "/private/var/tmp/_bazel_thanhvu/14020c955c9a251a040f84610e66eb94/external/build_bazel_rules_apple/apple/internal/platform_support.bzl", line 145, column 55, in _platform_prerequisites_from_rule_ctx
		rule_descriptor = rule_support.rule_descriptor(ctx)
	File "/private/var/tmp/_bazel_thanhvu/14020c955c9a251a040f84610e66eb94/external/build_bazel_rules_apple/apple/internal/rule_support.bzl", line 823, column 65, in _rule_descriptor
		platform_type = getattr(apple_common.platform_type, ctx.attr.platform_type)
Error: No attribute 'platform_type' in attr. Make sure you declared a rule attribute with this name.
Available attributes: _action_listener, _config_dependencies, _xcode_config, _xcode_path_wrapper, applicable_licenses, compatible_with, deprecation, exec_compatible_with, exec_properties, expect_failure, features, generator_function, generator_location, generator_name, name, out, restricted_to, srcs, tags, target_compatible_with, testonly, toolchains, transitive_configs, visibility
ERROR: Analysis of target '//App:app' failed; build aborted: Analysis of target '//metal:MetalResource' failed
INFO: Elapsed time: 0.101s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 1 target configured)

Here is example project:
test_compile_metal.zip

Access internal ObjC properties in mixed modules

Hi folks, I have looked into Bazel for a project with mixed modules and found one difference. According to Apple docs https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_swift_into_objective-c

Methods and properties that are marked with the internal modifier and declared within a class that inherits from an Objective-C class are accessible to the Objective-C runtime. However, they're inaccessible at compile time and don't appear in the generated header for a framework target.

Swift declarations of @objc properties and methods with internal access level should be available in ObjC files of the same module. And Xcode working according to the doc.
My module declaration is fairly simple:

mixed_static_framework(
    name = "MyModule",
    srcs = glob(["MyModule/*.m", "MyModule/*.swift"]),
    hdrs = glob(["MyModule/*.h"]),
    umbrella_header = "MyModule/MyModule.h",
)

Also, I can access generated Swift header only via #import "MyModule-Swift.h" and can't with #import <MyModule/MyModule-Swift.h>"
Is this Xcode internal feature or I'm doing something wrong?

fatal error: 'Realm/Realm.h' file not found

Hello maintainers,

I'd like to ask regarding this import issue. I cannot use #import <Realm/Realm.h> for apple_library depends to apple_dynamic_framework_import.

Here is my rule.

load("@build_bazel_rules_apple//apple:apple.bzl", "apple_dynamic_framework_import")
load("@rules_apple_line//apple:apple_library.bzl", "apple_library")

apple_library(
    name = "TVLStorage",
    enable_modules = True,
    hdrs = glob([
        "TVLStorage/**/*.h"
    ]),
    srcs = glob([
        "TVLStorage/**/*.m",
        "TVLStorage/**/*.swift",
    ]),
    deps = [
        ":Realm_VendorFramework",
    ],
    sdk_frameworks = [
        "Security"
    ]
)

apple_dynamic_framework_import(
    name = "Realm_VendorFramework",
    framework_imports = glob([
        "Vendor/Frameworks/realm-objc-3.21.0/Realm.framework/**"
    ]),
)

I run bazel build //Modules/TVLStorage:TVLStorage and it returns.

Use --sandbox_debug to see verbose messages from the sandbox
In file included from Modules/TVLStorage/TVLStorage/Realm/RLMRealm+SafeTransaction.m:9:
Modules/TVLStorage/TVLStorage/Realm/RLMRealm+SafeTransaction.h:9:9: fatal error: 'Realm/Realm.h' file not found
#import <Realm/Realm.h>

Any idea how to fix this issue? Thanks!

Header map generation not working

Maybe this should be an issue in rules_ios, I'm not sure, but I'll start here. Header maps don't seem to be working for me. The copts added seem correct, but the .hmap files don't seem to get created during the build. Trying to build zz here fails with it being unable to find a header for "yo.h".

BUILD.bazel:

load("@rules_apple_line//apple:apple_library.bzl", "apple_library")

apple_library(
    name = "zz",
    srcs = ["a.swift", "a.m", "nest/yo.h"],
)

a.m:

#import "yo.h"

void a() {}

nest/yo.h and a.swift: empty files

If I add the headermaps to the data attr, I can sort of get it working for non-sandboxed builds, but overall I'm not sure what's going on here. I'm on Bazel 3.7.0

Missing #import <Module/Module.h> file in generated Module-Swift.h

Hello There!

I am seeing the following error when I am compiling a mixed framework target:

bazel-out/apl-ios_x86_64-fastbuild/bin/Projects/Module/Module/Module-Swift.h:223:9: fatal error: 'Module/Module.h' file not found
#import <Module/Module.h>

This is happening in the code generated -Swift header

When I search through my bazel-out directory I cannot find Module.h. What is the right way to go about debugging this issue

module 'ModuleName' is not found

Using the latest commit, swift_library/swift_static_framework modules are failed to be imported.

bazelisk build //Modules/ViewDescription
ERROR: /Users/albertjanuar/Documents/ios/Modules/TVLUI/BUILD:6:14: Compiling Modules/TVLUI/TVLUI/NavigationController/TVLNavigationController.m failed: (Aborted): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang -arch x86_64 '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG ... (remaining 69 argument(s) skipped)
Modules/TVLUI/TVLUI/NavigationController/TVLNavigationController.m:9:9: fatal error: module 'MUIKit' not found
@import MUIKit;
 ~~~~~~~^~~~~~
1 error generated.
Error in child process '/usr/bin/xcrun'. 1

MUIKit is built with swift_library/swift_static_framework. We experience error build after this commit bazelbuild/rules_swift@b0ea825. Any idea what is the issue? Thanks

Able to build Mixed Framework via Command line, but cannot build in Xcode via Tulsi

Hello There,

First and foremost, thank you for this wonderful library I am quite excited to use it. As for my issue, I am seeing success when building a mixed framework via command line, something like this:

bazelisk build @CocoaLumberjack//:CocoaLumberjackFramework --apple_platform_type=ios --ios_multi_cpus=x86_64,arm64 -c opt

Works and builds a framework zip, but when I link to @CocoaLumberjack//:CocoaLumberjack in my other rules I am seeing this issue:

Screen Shot 2020-08-20 at 11 13 44 AM

Is this an issue around using enable_modules or not? I could modify these calls to use @import Cocoalumberjack;

I have a branch of off the bazel examples repo that replicates this issue using Tulsi, there is a working Tulsiproject in that branch at tutorial/ios-app/BazelExample.tulsiproj

Thank you for any help here!

Bridging Header Support

When I try to add a bridging header with swift_copts = ["-import-objc-header", "path/to/Bridging-Header.h"], it fails to build, telling me that frameworks don't support bridging headers. Ideally, this wouldn't happen, and also there'd be a bridging_header attr or something

swift code being compiled 3 times

Hello @thii!

We migrated all our project and its dependencies to bazel but we can't reduce the build time in incremental builds for swift targets.

I added the profiling flag to bazel build command and here are the results loaded in chrome, as you can see there are three "Compiling Swift module Apollo" steps in different threads.

image

And if I use the official Bazel rule there is only one "Compiling Swift module Apollo" step

image

So I think that the swift module is being compile 3 times, I tried to modify the swift_static_framework.bzl without success, as far as I understand I guess that it is compiling 3 times because of the 3 header maps (public, private, private angled), each one compiles a swift module?

Do you have the same behavior with Line's dependencies?

Here is the target definition:

load("@rules_apple_line//apple:apple_library.bzl", "swift_library")

swift_library(
    name = "Apollo",
    srcs = glob(["Apollo/Sources/Apollo/*.swift"]),
    module_name = "Apollo",
    visibility = ["//visibility:public"],
)

And the trace files:

traces.zip

How to include header search path for metal_library rule

Hi LINE developer.
I use your rules to build metal_library. But i can't find any way to include header when build.
I use metal_library that import "MTIShaderLib.h" in MetalPetal lib.
Please provide the way to import header

How to allow import implementation file in Objective C code?

I am trying to build Objective C code which import .m file like this

#import "PMKCallVariadicBlock.m"

which renders error as such

Use --sandbox_debug to see verbose messages from the sandbox
PromiseKit/Sources/AnyPromise.m:6:9: fatal error: 'PMKCallVariadicBlock.m' file not found
#import "PMKCallVariadicBlock.m"
        ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Target //PromiseKit:PromiseKit failed to build
INFO: Elapsed time: 8.861s, Critical Path: 8.42s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

More about this is explained here #31

xcode_path_wrapper issue when building metal_library

Hi! I found this project because I was looking for a way to build metal libraries using Bazel. I'm pretty new to Bazel so I may just be holding this wrong, but I'm having trouble with the metal_library rule at tip of tree (currently 63f50b2).

When I try to build a metal_library I get:

$ bazel build //:example_metallib
ERROR: <path>/BUILD.bazel:3:14: in metal_library rule //:example_metallib:
Traceback (most recent call last):
	File "<tmp path>/external/rules_apple_line/apple/metal_library.bzl", line 64, column 44, in _metal_library_impl
		xcode_path_wrapper = ctx.executable._xcode_path_wrapper,
Error: No attribute '_xcode_path_wrapper' in executable. Make sure there is a label type attribute marked as 'executable' with this name
Available attributes:
ERROR: <path>/BUILD.bazel:3:14: Analysis of target '//:example_metallib' failed
ERROR: Analysis of target '//:example_metallib' failed; build aborted:

I suspected it could be a version compatibility issue with Bazel or rules_apple so I've played around with various versions of each to no avail.

I attached a zip of my minimal bazel project. I'd really appreciate knowing if this is my mistake or if I found a bug.

metallib.zip

Best way to suppress INFO logs from `swiftgen` rule

Hello!

I am running into an issue where I get a lot of logs from SwiftGen, is there any way to remove these INFO logs but keep my other info logs? Thanks

INFO: From SwiftGen Projects/Modules/Domain/AModuleLocalized.swift
File written: bazel-out/ios-x86_64-min12-applebin_ios-ios_x86_64-fastbuild-ST-c928d317f2e9/bin/Projects/Modules/AModuleLocalized.swift

weak_sdk_framework not being passed?

There is a requirement to add AdServices.framework but I need to include it as weak to support earlier devices without crashing them.

I added :

weak_sdk_frameworks = [
    "AdServices",
]

But somehow the framework is still not available on the newer devices (14.3+).

I found that your rules do not pass weak_sdk_frameworks into the native objc_library might cause this issue. The code here.

Since I'm still a beginner in Bazel, I would love to hear your thoughts if this is expected or not.
I would love to create the pull request for you if correct.

Thanks!

Building a mixed_static_framework with fully_static_link feature

I am trying to make a simple framework for ios that has dependencies on some swift code as well as objc and cpp libraries. For the purpose of shipping it to thirdparty, it needs to be a single statically linked binary. While ios_static_framework does not allow transitive dependencies, mixed_static_framework seems to work well with transitive dependencies. But I am failing to get it to build a single static binary even after using the "fully_static_link" feature.

The documentation for mixed_static_framework mentions that the default behavior is to not link in dependencies but was hoping it would work with the fully_static_link. When I do nm on the library in the framework, I see the cpp class related symbols are not found.

Any help is appreciated.

Below is a sample bazel repo which is a simple counter. The swift code calls objc which in turn calls the cpp code that has the counter logic.

https://github.com/karamach/test

Building the target from the counter directory using the following command
bazel build //counter_swift_objc_cpp:counter_mixedFramework --apple_platform_type=ios --ios_multi_cpus=arm64 --apple_bitcode=embedded --copt=-fembed-bitcode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.