Questions tagged [objc-bridging-header]
51 questions
17
votes
2 answers
Accessing property of forwardly declared enum from swift
Given that there is an ObjC compatible enum written in Swift:
// from MessageType.swift
@objc enum MessageType: Int {
case one
case two
}
and an ObjC class with a property of type MessageType which has to be forwardly declared:
// from…

Miroslav Kovac
- 1,168
- 1
- 16
- 27
8
votes
3 answers
Include an extension for a class only if iOS11 is available
I am trying to extend a class written in Obj-C and include an extension written in Swift that makes it conform to the UIDropInteractionDelegate, like so:
@available(iOS 11.0, *)
extension NoteEditViewController: UIDropInteractionDelegate {
…

Makaronodentro
- 907
- 1
- 7
- 21
6
votes
1 answer
`@discardableResult override init()` in Swift 3.1 throwing `warn_unused_result` Objective-C warning
I have a Swift class that is bridged to Objective-C. Even with @discardableResult, it's throwing this warning on build in the Objective-C class:
Ignoring return value of function declared with 'warn_unused_result' attribute
Is there a way to…

Ben Guild
- 4,881
- 7
- 34
- 60
5
votes
2 answers
How "id" type understands the receiver of method without casting?
After merging master to my working branch I got compiler error on the line, which wasn't be changed. The error looks like
id test;
[test count];
Multiple methods named 'count' found with mismatched result.
At first it looks clear, because…

iamirzhan
- 914
- 5
- 16
4
votes
1 answer
CocoaPod Include of non-modular header inside framework module
I am making a open-source library in Swift, it uses a third-party library (MailCore) which is itself in Obj-C so I added a bridging-header in my library.
The library is itself working fine when I run in my example project but when I try to use it as…

SandeepAggarwal
- 1,273
- 3
- 14
- 38
4
votes
1 answer
What does a Obj-C nonnull function returns to Swift?
I have an objective c library that can be used in Swift using the bridging header.
One of my public methods is annotated as returning nonnull but in fact it can return nil in some cases.
I was expecting that a Swift code calling this method would…

Jan
- 7,444
- 9
- 50
- 74
3
votes
2 answers
failed to emit precompiled header
Good Afternoon
I am trying to implement googles heatmaps into my map based project.
In this particular project, I get the following errors when trying to build.
failed to emit precompiled header…
user9951119
3
votes
1 answer
Force Objective-C method returning `id` and inout NSError to bridge to an optional return
Consider this Objective-C class:
@interface TestAPI : NSObject
-(nullable id)aNullableMethod;
-(nullable id)aNullableMethodWithError:(inout NSError **)error;
@end
I'm using TestAPI as an abstract base class and want to inherit from it in…

Daniel Pietsch
- 121
- 1
- 8
3
votes
1 answer
Use of undeclared identifier when I want use swift file in objective c project
when I want use swift file in objective c project and I declare an object from swift class, I get "Use of undeclared identifier" error.
the way that I pass:
coping swift file in project and type @objc before declare swift class
create header file…

Somaye Sabeti
- 31
- 1
- 4
3
votes
1 answer
Swift 3 import CommonCrypto
How to import the Obj-C CommonCrypto library to an existing Swift Xcode Project (Swift 3, Xcode 8.3.3)?
I tried to create my own Objective-C bridging file and it wasn't working.

Alec
- 666
- 8
- 23
3
votes
1 answer
Access Swift function for an object from Objective-C class
I'm trying to implement some Swift-framework into my Objective-C project. I have already set up all Bridge-Headers and also written @objc before functions and classes in a swift class. So it's required to do the following, but the example code is…

dvijok
- 89
- 8
2
votes
1 answer
Framework not visible in auto-generated swift file
I want to import some swift classes in objective-c project.
I added all classes, I created the bridging-header, I imported the MyTarget-swift.h file in my classes and everything seems working fine.
When I'm building the project, I found a very…

Gaby Fitcal
- 1,814
- 1
- 17
- 28
2
votes
0 answers
Swift class in ObjC Project : Receiver 'MySwiftClass' for class message is a forward declaration
After spending a few hours to integrate swift files successfully to my Objective-C based iOS project, I face the next challenge now :
In one of my Objective-C class header (Say, MyObjCClass.h), I do the forward declaration for MySwiftClass.
In the…

Harish J
- 525
- 1
- 4
- 16
2
votes
1 answer
No such module Common Crypto
I am working with swift 3.2. I have made a bridging header file which has the following:
#import
In my projects build setting I am pointing to my bridging header file but i am still getting the error 'No such module…

user2363025
- 6,365
- 19
- 48
- 89
2
votes
0 answers
Swift integration issue in Xcode 9?
I am working on an Application written in Swift. I added Objective-C classes. I have done every thing described here, Now i can use all my Objective-C classes in Swift files but can't access Swift files in Objective-C classes. Even I can't import…

Nisar Ahmad
- 885
- 1
- 10
- 25