cezheng / Fuzi

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

SPM support broken in Xcode 11 beta 4 #102

Closed thebluepotato closed 4 years ago

thebluepotato commented 5 years ago

See #101

/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.0.sdk/usr/include/libxml2/libxml/HTMLparser.h:15:10: 'libxml/xmlversion.h' file not found

Reading up on PackageDescription, the .headerSearchPath has to be relative and not absolute, but it wasn't really enforced before Xcode 11 beta 4, which allowed us to use $(SDKROOT)/usr/include/libxml2 to point to the correct libxml2 headers. Another issue seems to be that I can't get Xcode to read the .unsafeFlags which would allow to at least build the Package (but not distribute it). I'll open an issue in SPM as well.

cezheng commented 5 years ago

Thanks, would be good to link the SPM issue here as well

iDevPro commented 5 years ago
Снимок экрана 2019-08-09 в 9 55 26
cezheng commented 5 years ago

We will have to wait and see if later version of Xcode can fix this issue

algi commented 5 years ago

This is actually a correct behaviour. According to the documentation (https://developer.apple.com/documentation/swift_packages/csetting/3112666-headersearchpath) it is supposed to be only internal directory, not pointing outside:

Use this setting to add a search path for headers within your target. You can’t use absolute paths and you can’t use this setting to provide headers that are visible to other targets. The path must be a directory inside the package.

So I'm afraid you'll have to find a different way...

iDevPro commented 5 years ago

@algi Yeah, I found another way )) I put source code to Third-party folder in my project, and now I happy :) My project now faster neither when I use swift-soup :)

cezheng commented 5 years ago

@iDevPro would you mind saying a bit more on how you solve the problem? Did you mean that you copied Fuzi's source code or copied libxml2 source code to your project?

Btw, I'm not sure what you meant by My project now faster neither when I use swift-soup :), do you mean Fuzi is faster or is slower? I never used swift-soup before, but I'm interested to know about it.

thebluepotato commented 5 years ago

@cezheng Sorry for being a bit silent these past months, I was enjoying my summer :) I'm currently hacking around at a solution which currently builds under iOS, but I still have to test integrating into a project. Stay tuned

thebluepotato commented 5 years ago

Response from the Swift team:

Unfortunately there is no way to properly reference libxml2 in a Swift package, but we are aware of this issue.

I am afraid the only workaround right now is copying and patching the libxml headers but that might cause other issues if your copy of headers get out-of-sync with the ones in SDK :(

https://forums.swift.org/t/referring-to-libxml2-in-swift-package-description/28880

thebluepotato commented 5 years ago

FYI, others have the exact same issue: https://forums.swift.org/t/dependency-only-for-linux/28515/

OCJvanDijk commented 4 years ago

From the Xcode 11.4 beta release notes:

You can import libxml2, libxslt, and libexslt modules in both Swift package targets and regular Xcode targets, without any additional search paths. (52043828)

So it seems SPM support for Fuzi should now be possible (but I didn't try it out yet)