DEV Community

Alex Romanova
Alex Romanova

Posted on

Wdym Swift is for apple???

This week started with me saying "maybe" for my partner in lab 1. I wanted to explore something new, now that I got some confidence. Something that is rare (so not node), something that is interesting. So I saw an only swift project in the list. That person was looking for a partner, so I replied to her.

I found out Swift is used mostly for apple, but I saw it can be on windows as well. At this point we have decided to work as partners. I followed a bunch of tutorials on making Swift work on my win 10, it wasn't too bad, although definitely with some shaman work. The problems began when I tried to launch her project. It simply wouldn't. She did say she asked for prof help, however things didn't seem to work. I'm pretty sure the problem was in its version. The one she used wasn't yet out for windows.

Doing things

We came up with two solutions. She uploaded her code on replit where we could collaborate and test if things work without having to run in on my system. As it turned out in actual code - Swift is easy! I simply followed her already existing logic and mimicked it replacing some elements.

Here's what she had

         result = result.replacingOccurrences(of: "\r?\n\r?\n\r?\n", with: "<p>", options: .regularExpression)
         result = result.replacingOccurrences(of: "\r?\n\r?\n", with: "</p><p>", options: .regularExpression)
Enter fullscreen mode Exit fullscreen mode

And here's what I added

  if(self.input.hasSuffix(".txt")) {
... her code
} else {
         result = result.replacingOccurrences(of: "_?\n\r?", with: "</p>", options: .regularExpression)
         result = result.replacingOccurrences(of: "\n?\r?_", with: "<p>", options: .regularExpression)
}
Enter fullscreen mode Exit fullscreen mode

It was that easy. Well, I did make one stupid mistake that she pointed out when tested more.. I coded it pretty late at night.

I feel like I've gotten much better with regex, which I will probably soon forget again. That's just the usual cycle. She also asked me for help, I could tell from the question she didn't understand my code structure. She did a good job. I wonder, however, if it could be improved. Not sure exactly how.

Reviewing code in a pull request looks weird. I still get confused with automatically generated comments. However, it was pretty easy to see and tell what the person was going for and what they are missing. Perhaps that was because of the small amount of changes we had to implement, when I generally don't want to deal with someone else's code.

Struggles

The biggest problem I had was not being able to run Swift. For every change I had to test it in the online tool, and then wait her to test it on her system, since as it turned out - replit wasn't as reliable. It was lucky code itself wasn't hard. I can't imagine the pain of long debugging sessions...

It is also somewhat weird how the usual git workflow with commits and history changes couldn't apply here. I would commit only after I had it working online and in my partner's system, so that resulted in just one push.

We did well communicating and were generally on the same page, so that wasn't an issue.


In the end, I am happy to have found out what Swift is. I am also happy to not touch it again, since I don't use apple nor am interested in developing for mobile. Perhaps if I ever had to - I'd be all set.

On fixing issues

I've had a lot of issues still up there for my project. I got stuck with user input things, and even though I fixed some - there are still more left. That's an oof. Hopefully I get it done today.

Top comments (0)