Closed thebluepotato closed 5 years ago
This is awesome! Thank you for retrying the SPM support effort after https://github.com/cezheng/Fuzi/issues/34#issuecomment-249348356 , it seems both SPM and Xcode have become more usable since I last looked at it.
You're welcome!
You just have to release a new version now (I guess 3.1.1 since technically, no code inside the module has changed) so the Package can be referenced by version tag instead of branch. Both are supported (and my projects using Fuzi now reference the master
branch), but it is recommended, especially for other packages depending on yours, to point to a version (3.1.1 < 4.0.0, like Cocoapods ~> '3.1.1'
).
Sorry for the delay, I'm bumping the version now
@thebluepotato Is this working for you on Xcode beta 4? I'm getting:
/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
No, I get the same error. Reading up on PackageDescription, the .headerSearchPath
has to be relative and not absolute, but it wasn't really enforced, which allowed us to use SDKROOT
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 here and one in SPM as well.
After some tinkering with Package.swift, it builds! The
Fuzi
target now expressly provides in Package.swift that it should linklibxml2
and that the search path for the headers should be$(SDKROOT)/usr/include/libxml2
. In that sense, it works exactly as Cocoapods does. The SwiftPM description is not extra clear as to whether one should use link+include or.systemLibrary
target but the latter essentially required to add a modulemap again and proved difficult to use cross-platform.The two settings that are now present in Package.swift (supported since Swift 5.0) basically set the right compiler flags. Two caveats though:
$(SDKROOT)
isn't resolved automatically withswift build
. However, it compiles effortlessly in Xcode 11, which now includes full support for SPM. Adding Swift Packages there is also a breeze and everything is resolved automatically.Should fix #7, at least in part. It does not yet provide support for Linux, but there are other issues that currently prevent porting Fuzi to Linux. IMO, since the title and the latest comments of that issue revolved around pure SwiftPM support and since SwiftPM is bound to become much more popular with Xcode 11, I think this PR provides for full SPM support for all Apple platforms, using Xcode.