3

I've got a static library, compiled for multiple architectures, included in a XCFramework.

It looks like this :

 | framework_1.xcframework
 |---- _CodeSignature
 |---- Info.plist
 |---- ios-arm64_arm64e
       |---- Headers
       |---- libframework.a
 |---- ios-arm64_x86_64-simulator
       |---- Headers
       |---- libframework.a
 |---- macos-arm64_arm64e_x86_64
       |---- Headers
       |---- libframework.a

I'm developing beside it an iOS framework, with a Podspec, looking like this :

Spec do |spec|
 spec.information

 spec.subspec 'XCFrameworkPod' do |xcframework|
  xcframework.vendored_frameworks = 'path/to/framework_1.xcframework'
 end

I've managed to include my headers, by specifying this :

  xcframework.source_files = 'path/to/framework_1.xcframework/ios-arm64_x86_64-simulator/Headers/**/*.h'

This way, my headers are available in my project. But when I try to use one of them, it doesn't compile. I've the following error :

Include of non-modular header inside framework module: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/inttypes.h' Include of non-modular header inside framework module: '/Users/myuser/Library/Developer/Xcode/DerivedData/MyProject/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/MyPod/XCFrameworkPod/Headers/header.h'

How to integrate correctly the xcframework & headers?

I've tried setting 'Clang allow non-modular headers', but it doesn't work in a Swift project.

Thanks for your help !

1 Answers1

1

The source_files attribute should not be used together with the vendored_frameworks attribute. All the headers should be embedded in the vendored_frameworks. Here's an example.

Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139
  • If anyone was curious to see it in a non-json format: https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseAnalytics.podspec – mfaani Jan 13 '23 at 13:12