7

I'm facing the issue with distributing compiled swift framework. My framework heavily relies on the libxml2 dynamic library. In order to avoid issues with Swift module compatibility, I've set build flag BUILD_LIBRARY_FOR_DISTRIBUTION = YES.

So I've used Xcode 11.3 Swift v5.1.3 to build my framework. I've integrated it into the Demo.app project. As being expected Demo.app works fine in Xcode 11.3.

However, I have another error trying to build Demo.app in Xcode 11.0 Swift 5.1. I've got the error:

#import "libxml/HTMLparser.h"
        ^
/Applications/Xcode_11.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator13.0.sdk/usr/include/libxml2/libxml/HTMLparser.h:15:10: error: 'libxml/xmlversion.h' file not found
#include <libxml/xmlversion.h>
         ^
/.../DemoApp/ThirdParty/testXML.framework/Modules/testXML.swiftmodule/x86_64-apple-tvos-simulator.swiftinterface:6:8: error: could not build Objective-C module 'libxml2'
import libxml2
       ^
/.../DemoApp/AppDelegate.swift:11:8: error: failed to load module 'testXML'
import testXML

Here is the repo with both framework and app projects.

I'm using both Xcode version on the same Mac.

Aliaksandr B.
  • 146
  • 16
  • Is it important to you to be able to build on an older version if the new version works correctly? Am I misreading the question? – Tofu Warrior Jan 06 '20 at 22:28
  • @TofuWarrior: let me rephrase it: it's important to me to distribute binary built on a latest swift version which is compatible with elder swift versions. Eg. built with swift 5.1.3 but compatible with 5.0. – Aliaksandr B. Jan 08 '20 at 09:14
  • @AliaksandrB. Were you able to fix this? I am stuck with the same issue :( – Srinija Apr 17 '20 at 00:27

1 Answers1

0

Your project runs fine on my Xcode 11.3 tvOS simulator. However there's something I've noticed. The framework you built only contains x86_64 architectures (simulator only), it won't work on physical devices.

For Xcode before 11.3 it seems like you need to add $(SDKROOT)/usr/include/libxml2 and ${SRCROOT}/libxml2 to Build Settings. That fixed the issue for me on Xcode 11.2.1

Quang Vĩnh Hà
  • 494
  • 3
  • 8