How to use Objective-C framework in Swift without Bridging Header?

Yaobin Then

I'm developing a Flutter plugin (in Swift) trying to wrap an Obj-C framework. I was able to import the Header files in MyPlugin.h file, but now how do I use the framework without a Bridging Header? I'm just getting not found in scope.

If I were to generate a Bridging Header, I ran into another error using bridging headers with framework targets is unsupported

This is my podspec file, I had to set DEFINES_MODULE to NO in order to build the project without running into Include of non-modular header inside framework module error

Pod::Spec.new do |s|
  s.name             = 'lisnr'
  s.version          = '1.0.0'
  s.summary          = 'Flutter plugin for LISNR'
  s.description      = <<-DESC
  Flutter plugin for LISNR.
                       DESC
  s.homepage         = 'redacted'
  s.license          = { :file => '../LICENSE' }
  s.author           = { 'redacted' => 'redacted' }
  s.source           = { :path => '.' }
  s.source_files = 'Classes/**/*'
  s.dependency 'Flutter'
  s.platform = :ios, '8.0'

  s.preserve_paths = 'radius.framework'
  s.xcconfig = { 'OTHER_LDFLAGS' => '-framework radius' }
  s.vendored_frameworks = 'radius.framework'

  # Flutter.framework does not contain a i386 slice.
  s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'NO', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
  s.swift_version = '5.0'
  s.public_header_files = 'Classes/**/*.h'
end

The other codes are pretty much generated by the Flutter CLI.

Foti Dim

You need a module map. You can either write it manually and put in the framework or do it with a script. See how I did it here for the Spotify SDK which is an ObjC framework.

The script for you would be something like that:

#!/bin/sh

MODULE_DIR="MY_PATH/radius.framework" # You framework's path
mkdir -p "${MODULE_DIR}"
printf "module radius {\n\
header \"Headers/radius.h\"\n\
export *\n\
}" > "${MODULE_DIR}/module.map"

Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.

En caso de infracción, por favor [email protected] Eliminar

Editado en
0

Déjame decir algunas palabras

0Comentarios
Iniciar sesiónRevisión de participación posterior

Artículos relacionados

Используйте классы Swift в файлах Bridging Objective C

Obteniendo "archivo no encontrado" en Bridging Header al importar marcos Objective-C en el proyecto Swift

Bridging an array of enums from Swift to Objective-C

Usar clases Swift en archivos Bridging Objective C

How to use Objective-C enum in Swift

Как вызвать код Swift из Objective-C в целевой платформе Framework?

If using Cocoapods and use_frameworks!, should I use Obj-C Bridging Header?

How to use a swift module in an objective-c module with SwiftPM?

Cómo encontrar la ruta de Bridging-Header.h - Swift, Xcode

Objective-C 프레임 워크를 Swift 프로젝트로 가져올 때 Bridging Header에서 "파일을 찾을 수 없음"발생

Typhoon Framework: Swift u Objective-C

Using multiple Objective-C header files in Swift project

How to use Cocoapods in a Swift framework?

iOS Swift framework: ¿Cómo importar correctamente el código Objective C en Swift Framework?

No se puede acceder a Swift Framework en Objective-C

Sinch framework (Objective C) y Swift no son compatibles

Exposez des fichiers Swift à Objective-C dans Framework

Añadiendo el marco Objective C dentro de Swift Framework

Sinch framework (Objective C) y Swift no son compatibles

How to convert this Swift syntax into Objective-C?

How to call an Objective C class method in Swift

Should I use Realm Objective-C or Realm Swift in my mixed Objective-C / Swift project?

Случайно удаленный файл Bridging-Header.h

Xcode 8 with mixed Swift and Objective-c project generated "ModuleName-Swift.h" header not found

Как я могу отправлять (и получать) чрезвычайно большие плавающие массивы из Swift в Objective c ++ в c ++, а затем выполнять резервное копирование в Swift?

How to use core data into my swift framework

Swift/Obj-C interop: Prevent bridging of Foundation classes?

Разница между перечислителем и итератором в Swift или Objective C

Увеличивает ли добавление библиотек Objective-C в проект Swift размер приложения?

TOP Lista

CalienteEtiquetas

Archivo