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
0
votes
0 answers
Variable name "value" is getting error in objective-c and swift combined project
Created variable "value" in Objective-C file.
Then import this file in App-Bridging-Header.h file.
Then getting following error.
Before import in App-Bridging-Header.h file it's working.
After import in App-Bridging-Header.h file it's not working.

Chirag Kothiya
- 955
- 5
- 12
- 28
0
votes
1 answer
Import a Swift module in Obj C module
I have a xcworkspace with two xcodeprojects inside (one is a static library where all the base functionalities are implemented and the other is a demo project which uses classes from first one) - and all the code so far has been written in Objective…

aleksie3006
- 149
- 2
- 5
0
votes
1 answer
"No visible @interface for 'MySwiftFile' declares the selector '****'" in iOS framework
I've been having trouble with using Swift in an ObjC framework in iOS. My framework has Objective-C code, which I want to call Swift code from.
I think I have created the bridging properly, I'll show below what I've done.
MySwiftFile.swift :
open…

fff
- 199
- 2
- 10
0
votes
1 answer
Xcode SQLClient Issues
I am using a library called "SQLClient", located here: https://github.com/martinrybak/SQLClient
to access my database which is located on a server. After installing the library, the pods, etc, I tried making an objective-c header file and put the…

izzykk
- 31
- 6
0
votes
1 answer
iOS: How to user a specific function from my swift class in objective C? `Use of undeclared identifier 'NetworkClient'`
I use this code in Swift that works well, but impossible to call it in Objective C.
import Foundation
import Alamofire
enum Router: URLRequestConvertible {
case users
static let baseURLString = "https://api.stackexchange.com/2.2"
func…

ΩlostA
- 2,501
- 5
- 27
- 63
0
votes
1 answer
Read file in document failed in Xcode 11.3
When I read file in document using stringWithContentsOfURL it failed
this is error in Xcode console:
Error Domain=NSCocoaErrorDomain Code=256 "The file “1.txt” couldn’t be opened."…

jansma
- 1,605
- 1
- 15
- 22
0
votes
1 answer
How to Import the Objective c file in the swift
Hello I am working on the react native project which i converted to swift from objective c using this How to convert iOS react native template to swift? thread.
Now I wanted to use this https://github.com/wonday/react-native-orientation-locker to…

Fahad Rehman
- 1,189
- 11
- 25
0
votes
1 answer
Circumvent ObjC to Swift bridge with KVC?
Recently ran into a crash in our app:
EXC_BREAKPOINT 0x00000001c5c8986c
static URLRequest._unconditionallyBridgeFromObjectiveC(_:)
It's coming from a webView decide policy where we access the request property:
func webView(_ webView: WKWebView,…

gngrwzrd
- 5,902
- 4
- 43
- 56
0
votes
1 answer
In a mixed objc/swift module, Xcode always tries to include the module itself
This one is not easy to explain, but is also very annoying.
I'm working on a Cocoapods framework (in development mode) with objc and swift sources. Let's call it the "SuperCompoment" framework
Xcode auto generates the SuperComponent-Swift.h file, to…

Martin
- 11,881
- 6
- 64
- 110
0
votes
2 answers
Error to compile Xcode Swift project using C++ library linked on Build Phases
I've searched a lot on the web but not found the solution for my problem.
My objective is create a simple class in C++ and use it on Swift. To this I did follows this tutorial -> http://www.swiftprogrammer.info/swift_call_cpp.html (It's very…

Augusto
- 3,825
- 9
- 45
- 93
0
votes
1 answer
Getting error while accessing internal enum from public enum in swift 4.2
I am getting error while accessing internal enum values inside public enum
Code snippet
@objc public enum Sample1 : Int {
case valid
fileprivate static var upgradeStatus:[String: Sample1] = [
RawString.validValue.rawValue :…

Prasad Devadiga
- 2,573
- 20
- 43
0
votes
2 answers
Xcode Pods functions not found in ModuleName-Swift.h
Because of a constraining library, I need to use Objective-C files in my Swift project.
So, I added the import module-Swift.h in my .m file.
It finds it without any issues.
The problem come from the auto-generated module-Swift.h" file.
I have a lot…

Anas A.
- 81
- 1
- 6
0
votes
2 answers
Can't see Swift variable/method in Objective C
I am unable to see the method/variable to set myVar to true from Objective C even tough I've added the @objc and public modifiers and there is no Bool in the setMyVarTrue() method's signature.
This is probably caused by the difference between…

Peter G.
- 7,816
- 20
- 80
- 154
0
votes
1 answer
Could I extend NSString class in Static Library and use it in App with Swift?
I extend NSString in my custom static library CommonLib :
//NSString+ext.h
#import
@interface NSString (ext)
- (BOOL)isContainsEmoji;
@end
//NSString+ext.m
#import "NSString+ext.h"
@implementation NSString (ext)
-…

hopy
- 559
- 3
- 18
0
votes
0 answers
public var of an Objective C enum type inside a Swift class not accessible from another Objective C class
I have an enum defined in Enums.h -
typedef NS_ENUM(NSUInteger, ScreenTypes)
{
ScreenA = 0,
ScreenB,
ScreenC,
ScreenD
};
Next, I declare a public var of this enum in a Swift class XYZ.swift
public var screenType:…

letsbondiway
- 470
- 3
- 18