XcodeProj
XcodeProj copied to clipboard
Linux compatibility
Context π΅οΈββοΈ
According to this task the only blocker to have support for Linux has been fixed.
What π±
Make xcodeproj Linux compatible.
Proposal π
- Set up the CI pipeline to run on Linux.
- Check out and fix any other issues with the usage of Foundation APIs.
Since the board is not public, I can't see the current progress on this one. I'd love to see Linux compatibility for xcodeproj. Currently it's not compatible, as you can see here my Linux CI builds are failling with this error:
/bitrise/src/.build/checkouts/xcodeproj.git--1264315860731431102/Sources/xcodeproj/Extensions/OSLog+Extras.swift:2:8: error: no such module 'os.signpost'
import os.signpost
^
The underlying OS is Ubuntu 18.04.
Hey @Dschee. Sorry, we stopped using Trello. We can wrap that one to run only on macOS. The main blocker is the PropertyListSerializer, which is not available on Linux. They don't seem to have done any work on the ticket that we opened
From the log @Dschee posted it looks like the signposting isnβt available on Linux either
@y-matsuwitter funded this issue with $30. Visit this issue on Issuehunt
I was working through this a bit. Some of these issues are workable, some will take some bigger rethinking.
The os.signpost issue is just for logging, so wrapping all those references with an #if os(macOS) works fine, for some reason canImport doesn't seem to work with SPM.
I was able to just copy the PlistSerializer file from Foundation and seems to compile fine as long as you add in an extension for the _typeMismatch function.
The bigger issue is the class PBXObjectReference: NSObject, Comparable, NSCopying, since none of the ObjC runtime is available for use on Linux.
I'm pretty experienced with doing Swift on Linux on Travis, so ask if you need help. I'm not familiar with Circle though.
Edit: sorry, old ticket; offer still stands though.
Will probably take you up on that @mxcl! I'm familiar with Circle, not terribly difficult to spin up a Linux job using the Swift Docker image on it. We've got a use case for using some of these tools in a service we run that's currently deployed on Linux boxes (unfortunately a bit hard to secure Mac hardware where it'll be used :/ )
Weirdly, most of the difficulty is around all the isEqual functions. I'll at least get as far as I can and potentially throw up a draft PR when I've got some time later this week.
Poked around a bit more, last remaining thing looks like finding a replacement for NSPropertyListSerialization that will work on Linux since PropertyListSerialization doesn't seem to port to Linux yet.
Sorry I haven't posted any updates here. The last time I gave this a try I managed to solve the issue of PropertyListSerialization not being available on Linux. I copied the implementation of the serializer over to the project and the compiler seemed happy about it.
Moreover, I had to add some macros around this class, which are only available on macOS.
After all that, I ran into some compilation issues that were hard to debug. If you would like to give it another try it'd be cool.
The macros around logging are fine, some stuff around a String/CVarArgs thing (not sure if this was ever fixed on Linux) but probably can be fixed with an overload.
Copying the implementation works fine for PropertyListEncoder and PropertyListDecoder but not for PropertyListSerialization, although it does look like the functionality is there in the swift-corelibs-foundation implementation? (https://github.com/apple/swift-corelibs-foundation/blob/swift-4.2-branch/Foundation/PropertyListSerialization.swift). I might be reading that wrong though, haven't done much with this.
Unfortunately it's the changes in this guy: https://github.com/tuist/xcodeproj/pull/365/files#diff-acb4ac63a93e60e6a26182f29ed8c02cR84 that are making this more difficult.
Was able to cover all the other errors here: https://github.com/thedavidharris/xcodeproj/commit/0251a7837727bf231ee5277b861316a36f3b2ef7. Tests still pass, although I need to verify that removing all the NSObject/isEqual behavior was done correctly.
Perhaps you can use some alternative PropertyListSerialization. For example SWXMLHash or Kanna
@thedavidharris I can fix some issues for Linux support. Where exactly are the problems?
It'd be awesome if you could give a hand to @thedavidharris to make a choice on the serialisation library. Looking at the ones that you shared I'd avoid Kana because it requires some libraries being available in the system. That makes the usage of the library a bit inconvenient.
Another interesting area to tackle given that we are doing all these refactorings is having some performance tests in place. It's possible with XCTest but I wonder if we could publish those number somewhere and compare them in every PR to notify authors about regressions.
Might be best to just consider Linux compatibility when addressing https://github.com/tuist/xcodeproj/issues/369 and that could replace some of the problematic code.
@CognitiveDisson I put up a draft PR at https://github.com/tuist/xcodeproj/pull/370 if you're willing to take a look. Not content with the current cleanliness of it, but it at least shows how to address most of the issues if you have suggestions for better ways to tackle them!