Comments (10)
you should include the swift-Swift.h as well
from rules_apple.
@lswith my swift-Swift.h
#if defined(__has_feature) && __has_feature(modules)
@import ObjectiveC;
@import _oc;
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
SWIFT_CLASS("_TtC5swift10SwiftClass")
@interface SwiftClass : NSObject <OCDelegate>
- (void)hello;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end
#pragma clang diagnostic pop
from rules_apple.
@lswith @dmishe
I think it is a bug. swift library deps oc library. so the generated swift-Swift.h use @import _oc , but oc library cann't use @import syntax
from rules_apple.
Nice catch. This is a side-effect of incomplete support for objc modules in Bazel. If you remove enable_modules attributes, and import oc headers directly in your objc source, the problem should be resolved.
from rules_apple.
@dmishe But my swift library used OCObject, the generated swift-Swift.h still has @import _oc,
how do I change my swift calss ? SwiftClass.swift
import UIKit
import _oc
public class SwiftClass: NSObject, OCDelegate {
var oc1: OCObject?
public func hello() {
}
}
If I remove OCDelegate
, the swift-Swift.h have no @import _oc,
import UIKit
import _oc
public class SwiftClass: NSObject {
var oc1: OCObject?
public func hello() {
}
}
the swift-Swift.h is
#if defined(__has_feature) && __has_feature(modules)
@import ObjectiveC;
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
SWIFT_CLASS("_TtC5swift10SwiftClass")
@interface SwiftClass : NSObject
- (void)hello;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end
#pragma clang diagnostic pop
from rules_apple.
You will be able to import objc_library as a module in Swift without enable_modules. We do some special things for swift_library targets that makes this possible.
from rules_apple.
If I add OCDelegate
, it appears again
import UIKit
import _oc
public class SwiftClass: NSObject, OCDelegate {
var oc1: OCObject?
public func hello() {
}
}
the swift-Swift.h
#if defined(__has_feature) && __has_feature(modules)
@import ObjectiveC;
@import _oc;
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
SWIFT_CLASS("_TtC5swift10SwiftClass")
@interface SwiftClass : NSObject <OCDelegate>
- (void)hello;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end
#pragma clang diagnostic pop
Because OCDelegate is decleared in _oc, so @import _oc is added in swift-Swift.h
from rules_apple.
Yep and that's fine. The important thing is that without enable_modules=1 on the Objective-C side, those imports will never be hit (since __has_feature(modules) will return false).
The downside, as a mentioned above, is that you will need to import oc
headers before the swift header every time you use it.
from rules_apple.
@dmishe really really thank you.
from rules_apple.
No problem.
from rules_apple.
Related Issues (20)
- `ios_build_test` and `ios_application ` cannot be directly used with default platform from apple_support HOT 4
- iOS app tutorial steps produce an app that crashes on launch HOT 1
- xctoolrunner failed: error executing in Downstream CI with Bazel@HEAD HOT 2
- How to build for multiple architectures HOT 10
- Support XCFramework Signatures HOT 5
- Failed xctoolrunner error executing AssetCatalogCompile command with Bazel@HEAD HOT 2
- Terminating app due to uncaught exception 'IBPlatformToolFailureException', reason: 'The tool closed the connection (AssetCatalogSimulatorAgent) HOT 1
- Bazel 7: Linking actions missing`-framework` flags for framework imports HOT 2
- iOSApp.ipa: code object is not signed at all HOT 1
- framework import by apple_static_framework_import crashed after update bazel from 5.4.1 to 6.5.0 HOT 3
- Duplicate symbols from apple_static_xcframework
- [Bazel 7] ios_application linking issue - "Could not find or use auto-linked framework" HOT 3
- [Bazel CI] Rule fails to build with error: 'struct' value has no field or method 'to_json' HOT 2
- `target_compatible_with` appears to be broken in Bazel 7.x
- `security` tool fails when codesigning with 3.5.0 HOT 2
- Support extension blocks in DocC rule
- Question: data attribute for macos_command_line_application or alternative
- Unable to nest app bundles within a macos_application
- How should I build a Network Extension about Xcode HOT 4
- Generated XCFramework fails on Xcode 15.3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_apple.