cezheng / Fuzi

A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
MIT License
1.06k stars 151 forks source link

'libxml/xmlversion.h' file not found #104

Open Parabak opened 4 years ago

Parabak commented 4 years ago

Hi guys,

maybe you can help me to resolve my issue.

I'm using Fuzi in my framework for at least a year, it works great. I even did one PR previously.

Now I struggle with the following thing. Using cocoapods I integrate my framework compiled with Xcode 11.0 Swift 5.1 with the enabled flag 'Build Libraries for Distribution' to project written in Xcode 11.2 Swift 5.1.2. I expect that it should work because we have an ABI stability released. However, I have an error:

Showing All Messages /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator13.2.sdk/usr/include/libxml2/libxml/HTMLparser.h:15:10: 'libxml/xmlversion.h' file not found

Could not build Objective-C module 'libxml2'

My Framework compiled in Xcode 11.2 with Swift 5.1.2 doesn't produce errors. Part of my podspec:

s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }

s.dependency "Starscream" , '~> 3.0.6' s.dependency "SwiftyXML", '~> 1.7.0' s.dependency 'Fuzi', '~> 3.1.1' s.dependency 'Sentry', '~> 4.2.1' s.dependency 'ReachabilitySwift', '= 4.3.0' s.dependency 'CryptoSwift', '~> 0.14.0'

The testing project has: Other linker flags: -l"xml2" Header Search Path: $(SDKROOT)/usr/include/libxml2

I can't understand the issue. Why it works for one version and doesn't work with another. Previously it was complaining that module was built with another Swift version, but 'Build Libraries for Distribution' flag looks like resolve it.

I also tried to find any hint in thread opened by @thebluepotato here: https://forums.swift.org/t/referring-to-libxml2-in-swift-package-description/28880 but failed.

I will appreciate any help. Thanks in advance!

Best regards, Alex.

Environment

RomanPodymov commented 4 years ago

Hello @Parabak I'm getting the same error using Fuzi 3.1.1, macOS 10.15.1, Carthage 0.34.0 and Xcode 11.2.1.

Parabak commented 4 years ago

@RomanPodymov, So far I didn't find a workaround. So please share solution, in case you find one.

cezheng commented 4 years ago

ABI compatibility is really just ensured by Apple that Fuzi does not really know about. Why is it absolutely necessary to use a binary built with earlier versions of Xcode with a project with newer Xcode version, given that you have all the source code and it only takes a few seconds to do a fresh build?

Parabak commented 4 years ago

Hi @cezheng, thanks for the reply! The problem is that our framework is distributed as binary and it was a company decision. So this fact most likely is not going to be changed. However, it's not only about building the binary with an older version of Xcode and also vice versa: Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler: Module compiled with Swift 5.1.2 cannot be imported by the Swift 5.1 compiler:

It there anything we can do about it? How Fuzi can be improved and is it possible at all? I can try to make PR if you can point me what should be improved or where I can read about it?

cezheng commented 4 years ago

I don't think this is a Fuzi bug, but you should probably file a bug to Apple if this is important to you.