Chris Prince
Chris Prince

Reputation: 7584

Server-Side Swift Development on MacOS with Xcode, Testing on Docker Ubuntu: How do I not clean/recreate each time?

Here's my development setup:

On MacOS, I use Xcode to edit and build (but not run) my code (I build under Xcode/MacOS only to make sure I've got syntax errors out of the project). I use swift package generate-xcodeproj to create the Xcode project, with some scripted tweaks to the Xcode project after, as I need some settings added.

In a Docker container running Ubuntu, in a terminal window on Mac OS, in the same directory as on Mac OS, I run my tests.

The problem I'm having is every time I switch "sides"-- to start testing in Docker/Ubuntu, or to start editing in Xcode, it seems I have to remove the .build folder. Which then involves downloading and building all the packages.

If I go from working on Docker/Ubuntu to Xcode/MacOS without the clean and rebuilding the Xcode project, I get this building my Server in Xcode: Xcode build error

If I generate the Xcode project, and then try to build and test on Docker/Ubuntu, swift test does an update on all packages, which takes time and then it has to build the project. After running tests on Docker/Ubuntu, when I go back to MacOS and try to build the project in Xcode, I get failures: enter image description here

For what it's worth, on Mac OS, here's my Swift version: Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)

And on Linux: Swift version 5.2.3 (swift-5.2.3-RELEASE)

This is really slowing me down to have to regenerate projects, redownload packages, and rebuild each time on each side when I switch. Thoughts?

Upvotes: 0

Views: 332

Answers (1)

Chris Prince
Chris Prince

Reputation: 7584

Well, I've figured out an answer: In all of the scripts I have on Docker/Linux, I've added --build-path .build.linux. For example:

swift build --build-path .build.linux 

and

swift test --build-path .build.linux

By default, when I generate the Xcode project for MacOS, it puts the Swift packages in .build and so I have separation.

This should work well as long as the packages used in the project don't change. If they do, I'll have to update them on both sides.

Upvotes: 1

Related Questions