Include XCFrameworks to a Podspec
Asked Answered
M

1

6

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 !

Mf answered 3/11, 2021 at 10:43 Comment(1)
Did you found the answer ?Hamforrd
H
3

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.

Hydrosome answered 3/11, 2021 at 14:52 Comment(2)
If anyone was curious to see it in a non-json format: github.com/firebase/firebase-ios-sdk/blob/master/…Episiotomy
I'm struggling to get this to work. I found a simple example, but the xcframework is not downloaded. Is this sample incorrect now? github.com/CocoaPods/CocoaPods/blob/master/examples/…Dilemma

© 2022 - 2024 — McMap. All rights reserved.