iOS Swift >=3 URLComonents - weird discrepancy between local and bitrise

I have a weird issue when using the Swift native SDK component URLComponent.

This is the code in question: -

private func applyDynamicHost(url initialUrl: URLString?) -> URLString? {
    guard let url = initialUrl else { return nil }
    guard var urlComponents = URLComponents.init(string: url) else { return nil }
    urlComponents.host = hostName
    urlComponents.scheme = NetworkConfig.serverProtocol
    guard let finalUrlString = urlComponents.string else { return nil }
    return finalUrlString // CI
//    return finalUrlString.removingPercentEncoding // local
  }

It takes an url and swaps the host name and protocol to some determined by the app.

Now notice the return value for CI, there’s no “removePercentEncoding”, that’s because it doesn’t seem to need it on the Bitrise CI box. However, if i run exactly the same code locally, it doesn’t remove the percent encoding and I have to apply that myself. This is annoying as it means I have to manually change code everytime I want to run tests locally.

I appear to be running the same version of xCode on both my laptop and desktop as that on Bitrise Box.

8.3.x

Anyone else stumbled across this weirdness or something similar?

Note: I haven’t tried on a blank project yet so it could very well be something wrong in my app but with such a simple change I can’t see why that would be?

Daniel.

Hi @DanielCreagh,

Definitely strange, but there’s absolutely nothing special on the bitrise.io mac VMs. These are clean macOS installs, with Xcode and a couple of other tools preinstalled.

Can it be because of system language / locale? The bitrise.io mac VMs are default US installs.

It maybe something weird like that.

I’ll investigate. Can you point me in the direction of where I can change that setting please?

System Preferences on your Mac

Small update.

It now works fine on my desktop. No idea what has changed but my iMac now runs the code in the same manner as Bitrise so there is something specific about my laptop which causes this discrepancy.

Definitely sounds like some kind of environment config… Maybe something in your bash_profile on your laptop? Hard to say…