bazel-ios / rules_ios

Bazel rules for building iOS applications and frameworks
Apache License 2.0
278 stars 85 forks source link

apple_library error @import module when mixing with other libraries #19

Open JuanFelippo opened 4 years ago

JuanFelippo commented 4 years ago

Hi! i have 2 scenarios that fails:

Scenario1:

structure: ModuleA (mixed, objc /swift) -> depends on ModuleC (pure obc)

bazel build //MixedTest:ModuleA_swift

error: umbrella header 'ModuleC-umbrella.h' not found umbrella header "ModuleC-umbrella.h"

Scenario2:

structure: ModuleD (pure swift) -> depends on ModuleE (pure swift)

bazel build //MixedTest:ModuleD_swift

MixedTest/ModuleD/D.swift:2:8: error: cannot load underlying module for 'ModuleE' import ModuleE

Fork to reproduce error: https://github.com/JuanFelippo/rules_ios branch: feature/mixed

Any ideasss?

segiddins commented 4 years ago

Try using apple_framework instead of apple_library ? apple_library is not meant to be used as a dependency by anything but packaging / bundling rules

ob commented 4 years ago

Yeah, what @segiddins said, also in your dependencies, don't depend on the _objc or _swift labels directly, just depend on ModuleA. I suspect you had to depend on those components because you are using apple_library instead of apple_framework.

If you make it work we should add it to the examples since we only have a basic one with a single ios_application rule.

segiddins commented 4 years ago

@ob maybe it makes sense to hide apple_library inside a struct so it can't be used from BUILD files?

ob commented 4 years ago

Yeah, let's do that.

JuanFelippo commented 4 years ago

Iยดve just pushed a few changes using apple_framework ๐Ÿ‘ Good News! Scenario 2 was fixed.

About scenario 1, in order to use a swift class (from a framework) in a objc framework. What import should i import? @ob @segiddins

import "MixedTest/ModuleC-umbrella.h" (not working)

import "MixedTest/ModuleC_swift-Swift.h" (not working)

+1 adding to examples if it works ๐Ÿ˜„

segiddins commented 4 years ago

Try @import ModuleC; maybe?

JuanFelippo commented 4 years ago

Excelent! It Worked!!!! ๐Ÿ˜„ !!! Will make a PR to repo as example! super clean @segiddins @ob , Thanks so much for your help!

tinder-maxwellelliott commented 3 years ago

Yeah, let's do that.

I would be interested in how to do this refactor. Is there an example in the codebase of this already?