Closed nmdias closed 7 years ago
Hi @HipsterJazzbo ,
Well, two things cross my mind so far:
1st step
The Package.swift
needs to be updated with it's targets and dependencies. The project structure, as is, reflects from my understanding of the SPM the following modules:
Theses modules will depend on themselves, in such way that the dependency graph should translate to something like this on the Package.swift
file:
let package = Package(
name: "FeedKit",
targets: [
Target(name: "Dates"),
Target(name: "Extensions"),
Target(name: "Model", dependencies: ["Dates", "Extensions"]),
Target(name: "Parser", dependencies: ["Model"])
],
dependencies : [],
exclude: ["Tests"]
)
I'm unable, as of yet, to make this work. Here's what I'm doing so far:
Do a local commit, to the local FeedKit
repo with the Package
updated to the above example. Tag that commit with let's say 6.1.0
Create a folder Project
and run:
swift package init
Update the newly created Project
's Package.swift
to:
let package = Package(
name: "Project",
dependencies: [
.Package(url: "/Volumes/HD2/Sources/FeedKit", majorVersion: 6)
]
)
Run:
swift package generate-xcodeproj
Open project and attempt to build. This will not work, as it is right now, because, for instance, the Model
module depends on the Extensions
module.
To fix these issues, I would need to import Extensions
where needed in the Model
module. However, the xcproject of FeedKit right now, as it's own set of Targets:
These are completely different from the ones automagically generated with the Swift Package Manager. So, I have yet to figure a way to do this, without disturbing the waters.
2nd step
I'm not sure if this one is possible with the free tier of Travis, but trigger Unit Tests also within a Linux environment, after running the usual tests for the existing targets.
I'm new to SPM, so this was all I could figure out in the last couple of days. I'm not sure if there's additional steps down the road.
I moved everything into a single FeedKit folder, and SPM now recognises it as a single module instead of several modules with multiple dependencies. It's now successfully building.
Assuming I'm not using anything incompatible with the linux port of the Foundation libraries, this just might compile in linux out of the box.
Update on the linux end, the output from running swift build
Compile Swift Module 'FeedKit' (91 sources)
/usr/src/MyApp/.build/checkouts/FeedKit.git--7419358408863835521/Sources/FeedKit/Parser/JSONFeedParser.swift:52:41: error: 'Error' is not convertible to 'NSError'; did you mean to use 'as!' to force downcast?
return Result.failure(error as NSError)
~~~~~~^~~~~~~~~~
as!
/usr/src/MyApp/.build/checkouts/FeedKit.git--7419358408863835521/Sources/FeedKit/Parser/XMLFeedParser.swift:221:40: error: 'Error' is not convertible to 'NSError'; did you mean to use 'as!' to force downcast?
self.parsingError = parseError as NSError
~~~~~~~~~~~^~~~~~~~~~
as!
<unknown>:0: error: build had 1 command failures
error: exit(1): /usr/bin/swift-build-tool -f /usr/src/MyApp/.build/debug.yaml
6.1.0 is out in the wild with linux support 😍
@nmdias You're amazing.
It seems that 8.0.0 has regressed back in this matter:
error: type 'NSString' has no member 'stringEncoding'
error: 'Error' is not convertible to 'NSError'; did you mean to use 'as!' to force downcast?
Is there a version safe to use on Linux between 6.1.0 and 8.0.0 ?
@asos-rshev 7.1.0 should be OK. I'll release a fix when possible. Thanks
@nmdias thanks, verified, 7.1.0 is fine. 7.1.1 on the contrary, is showing the first error as above.
Pardon if this is an silly question, but what's involved in this?