Unable to import Objective-C module into Swift
See original GitHub issueI have an objective-C(cocoapod JKBigInteger) project I am trying to import into Swift, though the module is compiling correctly, Swift don’t see it.
error: no such module 'JKBigInteger'
First attempt:
apple_library(
name = 'JKBigInteger',
exported_headers = glob([
'JKBigInteger/*.h',
'JKBigInteger/LibTomMath/*.h'
]),
srcs = glob([
'JKBigInteger/LibTomMath/*.c',
'JKBigInteger/*.m',
]),
visibility = ['PUBLIC'],
)
Second attempt by creating a framework:
apple_library(
name = 'JKBigIntegerDynamicLibrary',
srcs = glob([
'JKBigInteger/LibTomMath/*.c',
'JKBigInteger/*.m',
]),
preprocessor_flags = ['-fobjc-arc'],
exported_headers = glob([
'JKBigInteger/JKBigInteger.h',
'JKBigInteger/LibTomMath/*.h'
]),
visibility = ['PUBLIC'],
header_path_prefix = 'JKBigInteger',
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
)
apple_bundle(
name = 'JKBigInteger',
binary = ':JKBigIntegerDynamicLibrary#shared',
extension = 'framework',
info_plist = 'JKBigInteger/Info.plist',
visibility = ['PUBLIC'],
)
Using as dependency in my apple_binary:
apple_binary(
name = 'BuckDemoBinary',
deps = [
':Assets',
':Storyboards',
'//Pods/RxSwift:RxSwift',
'//Pods/RxCocoa:RxCocoa',
'//Pods/RxGesture:RxGesture',
'//Pods/JKBigInteger:JKBigInteger',
],
preprocessor_flags = ['-fobjc-arc', '-Wno-objc-designated-initializers'],
srcs = glob([
'BuckDemo/*.swift',
]),
frameworks = [
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Importing Objective-C into Swift - Apple Developer
To import a set of Objective-C files into Swift code within the same app target, ... it by using your product module name...
Read more >Unable to Import Objective-C Files into Swift project using ...
1 Answer 1 ... . Make sure AsyncSocket appears under Compile Sources of Build Phases and its header file is imported in the...
Read more >Swift-Objective C interoperability and best practices - Infinum
To use Objective-C code in Swift, it is only necessary to import Objective-C header file in bridging header file to expose it to...
Read more >Swift SPM dependency on Objc SPM (Could not build ... - Reddit
I have FeatureASwiftSPM that has a dependency on ObjectiveCSPM, this SPM starts to fail as soon as I import `ObjectiveCSPM` with the error...
Read more >Header import conditionally fails in mixed Swift package
This works well when I build the MyPackageObjC target, and I can use the resulting package in Obj-C code in my app. However,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any update on this one? I’m having the same issue.
This one is same as https://github.com/facebook/buck/issues/1563 and I’m trying to solve it using bridging header with no luck.
I have a rule for Lottie:
Then I add it in another
apple_binary
rule:In the bridging header I’ve added
#import <Lottie/Lottie.h>
, but no luck so far.