Swift’s compatibility with C and Objective-C lets you create a project that contains files written in either language.
Questions tagged [objective-c-swift-bridge]
117 questions
3
votes
1 answer
Can I prevent extensions from being exported to Swift header for Objective-C?
I have an Objective-C project with 1 Swift class. This class is using a framework that is also written in Swift. (Used CocoaPods to include the framework)
My problem is that the -Swift.h file is exporting my extensions that adhere to protocols in…

Aaron Bratcher
- 6,051
- 2
- 39
- 70
3
votes
1 answer
Extension is not recognized after a bridge from Objective-C to Swift
I have question for expert on Swift and Objective-C.
I'm developing on iOS project in swift.
In this project, I have import an older owned library (in Objective-C) used with a Objective-C bridge.
When I use some function of this library in my Swift…

user3281706
- 111
- 3
3
votes
1 answer
Import Obj-C file which imports auto-generated Swift header
This is a partial duplicate of Import a file in bridging-header which imports Swift header but I encounter the same issue as Rich
But what about enums declared in Swift? :(
I am porting an Obj-C iPad app to the iPhone. However I am a Swift…

bennyty
- 371
- 5
- 18
3
votes
4 answers
Error, bridging header test.h does not exist
So I am going crazy, since I keep on getting the error as described in the title and nothing that I worked.
I will show you what I have tried:
What else can I do?
Please help.

Timo Cengiz
- 3,367
- 4
- 23
- 45
3
votes
1 answer
arrow operator in swift
I am trying to adopt a SDK written in objective-c in a swift project. The objective-c way to initialize the SDK is as follows:
@implementation ViewController
nokeSDK *nokelock;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional…

sully77
- 357
- 3
- 11
2
votes
1 answer
Can I use NS_SWIFT_NAME or NS_REFINED_FOR_SWIFT on a C enum to map a global function to a Swift property?
I have an enum like
typedef NS_ENUM(NSInteger, MyEnum) {
MyEnumCase1,
MyEnumCase2,
...
};
and a function that maps those enum values to arbitrary strings
FOUNDATION_EXPORT NSString *myEnumString(MyEnum val);
Is it possible to expose this to…

Greg
- 10,360
- 6
- 44
- 67
2
votes
1 answer
Calling swift closure from Objective-c
i am on macOS, objective-c. I included a Swift 5 framework and one thing i don't know is how to provide a closure.
This is the swift declaration:
var cancelledStateColorHandler: ((NSColor) -> NSColor)?
How do i pass a handler from objective-c to…

Pat_Morita
- 3,355
- 3
- 25
- 36
2
votes
1 answer
how to push a swift view controller from objective-c class and pass data back and continue the next process in objective c class
I want to push swift UIViewController from my objective C uiviewcontroller and wait for that viewcontroller to send back data. How can I do it.
I tried using protocol/Delegate in swift but it throws error as it is not available in objc .h file even…

Reed
- 944
- 7
- 15
2
votes
1 answer
How to make a callback function pointer from C++ to Swift?
There are many tutorials to make this on web but none are clear and objective, because thats I'm prefer show my case.
I'm developing a iOS app that use a C API to connect to a service web and it have callback functions, my task is simple, I must get…

Augusto
- 3,825
- 9
- 45
- 93
2
votes
1 answer
Error to use C++ on Swift project on Xcode: Undefined symbols for architecture x86_64
There are a lot of questions about this on the web but I couldn't solve my problem. I've been studying this for a few days.
I want run a simple C++ class on Swift project, to this I followed this tutorial:…

Augusto
- 3,825
- 9
- 45
- 93
2
votes
1 answer
@objc annotation on the classname vs the class itself
Say I have a class called ExampleClass.
Say I then write code like so:
@objc class ExampleClass: NSObject {}
With an ObjectiveC file header like so:
#import
#import
@interface…

Abraham P
- 15,029
- 13
- 58
- 126
2
votes
2 answers
Calling Swift class method from Objective-C
I have this function in Swift
class func someFunction(idValue: Int, completionHandler: @escaping (_ jsonData: JSON) -> ()) {
(...)
if (some validation) {
completionHandler(jsonData)
} else {
…

martinc
- 89
- 2
- 11
2
votes
0 answers
Failed to emit precompiled header for bridge header in xcode9.2
My project works fine at first. when I added Notification Service Extension, I got build errors:
My bridging-Header.h like below:
I don't know why would this happen? So I searched it. I have read some similar questions, it looks like I need a…

Longshihua
- 395
- 1
- 3
- 20
2
votes
1 answer
How use Objective-c method in my Swift Class
Hello I want to use this method inside my swift class, already create the header, but I only manage to access the method (setApiKey). this is the code in objective c
#import
@class CLQResponseHeaders, CLQError;
@class…

Dac Devs
- 21
- 2
- 3
2
votes
1 answer
Objective-C code Swift-framework-internal
I have the following structure for a Swift framework:
FrameworkA
├── FrameworkA.swift
└── Objective-C
├── ClassA.h
└── ClassA.m
Unfortunately, I cannot access ClassA within FrameworkA.swift; the error is:
Use of unresolved identifier…

Michael Dorner
- 17,587
- 13
- 87
- 117