Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift Package Manager #24

Conversation

MaartenZonneveld
Copy link
Collaborator

@MaartenZonneveld MaartenZonneveld commented Feb 5, 2024

  • Add support for Swift Package Manager.
  • Drop support for Carthage and Cocoapods.

@MaartenZonneveld MaartenZonneveld changed the title Swift package manager Swift Package Manager Feb 5, 2024
@MaartenZonneveld MaartenZonneveld marked this pull request as ready for review February 5, 2024 08:35
@boldtrn
Copy link
Collaborator

boldtrn commented Feb 5, 2024

Thanks for opening this PR @MaartenZonneveld. Any reason you closed this? Is this in favour of #23?

@MaartenZonneveld
Copy link
Collaborator Author

Any reason you closed this?

Reopened now 👌

Copy link
Contributor

@Giordano-Menegazzi Giordano-Menegazzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeWise LGTM, alleen 2 stukjes code zijn commented... Mischien verwijderen of uncommenten? 🤔

XcodeProj/Examples/Swift/CustomViewController.swift Outdated Show resolved Hide resolved
XcodeProj/RouteTest/Fixture.swift Outdated Show resolved Hide resolved
@@ -1,4 +1,5 @@
import Foundation
import MapboxCoreNavigationObjC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why we sometimes use MapboxCoreNavigation and sometimes MapboxCoreNavigationObjC? Why the ObjC?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Objective-C & Swift can not co-exist in a single swift package target. Therefore a separate target for the objective-C components is created.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok got it. Would this mean, since we are in a swift file here, that we should rather import the swift dependency?

Sorry if this is a stupid question :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter if you import it from Objective-C or Swift. If this file uses something that is defined in the Objc package, it should import the Objc package.

platforms: [.iOS(.v14)],
products: [
.library(
name: "MapboxNavigation",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we should rename this to MapLibreNavigation or something like this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should rename it at some point. However, a rename like that would involve renaming a lot more parts of the repository. I think the scope of this PR should be limited to swift package manager, as it is already a big change

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, if it's not just about the name here, but also refers to file names, then we can do this in a follow-up 👍

Package.swift Outdated
let package = Package(
name: "maplibre-navigation-ios",
defaultLocalization: "en",
platforms: [.iOS(.v14)],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is iOS 14 required for maplibre-native v6?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, MapboxDirections requires iOS 14 minimum

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new requirement? I have seen that you added SPM support there as well, but I think the old Carthage build was compatible with iOS 8 or something like that.

Has something changed that much that requires iOS14?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MapboxDirections fork supports back to iOS 12.0. So I now restored iOS 12 support for this PR as well.

Copy link
Collaborator

@boldtrn boldtrn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for working on this. I can't comment about the SPM changes itself.

If we start with a fresh SPM package I think this should be released as MapLibre and not Mapbox.

The changes in CustomViewController.swift seem to be unrelated to the SPM change. IMHO these should not be part of this PR to keep the commit history clean.

@mindthefish
Copy link
Contributor

Is the use of Carthage and Cocoapods discouraged or why was it removed? Are the different types of integration incompatible? If not, I would be in favor of giving the user the choice.

@MaartenZonneveld
Copy link
Collaborator Author

MaartenZonneveld commented Feb 12, 2024

Is the use of Carthage and Cocoapods discouraged or why was it removed? Are the different types of integration incompatible? If not, I would be in favor of giving the user the choice.

@mindthefish Swift Package Manager requires a certain structure, that is not compatible with how the project was structured before. With this PR it becomes structured for SPM, breaking the cocoapods and carthage integrations. It is of course possible to fix, and support all 3 integration solutions. However, that would encompass a lot more work, and tbh I don't believe cocoapods and carthage are worth the effort anymore. We could always bring back carthage and cocoapods support later if it is desired.

@MaartenZonneveld MaartenZonneveld force-pushed the feature/swift-package-manager branch from f70598f to 5c7e396 Compare February 12, 2024 08:36
@boldtrn
Copy link
Collaborator

boldtrn commented Mar 1, 2024

@MaartenZonneveld thanks for working on this. What is the state of this PR? Do you think we can get this merged soon?

Currently CI is failing, that is something we should take care of before merging.

@boldtrn
Copy link
Collaborator

boldtrn commented Mar 13, 2024

Any update on this @MaartenZonneveld? I think this would be a great addition and I'd love to merge this.

@hactar
Copy link
Collaborator

hactar commented Mar 17, 2024

Currently using Maarten's fork in a new project we just started. It works. Would be important to merge it rather sooner than later, we'd like to do a few PRs against it to improve other things.

@MaartenZonneveld
Copy link
Collaborator Author

I've been very busy with other projects. I hope to be able to work on it this week.

If anyone has time to look into the failing CI, help is much appreciated 🙏

@MaartenZonneveld MaartenZonneveld removed the request for review from KasparElmans March 18, 2024 08:52
@boldtrn
Copy link
Collaborator

boldtrn commented Mar 18, 2024

Thanks for the update @MaartenZonneveld.

@hactar would you be able to look into the failing CI? I think this could speed up getting this PR merged. I would love to merge this PR as well.

@mindthefish
Copy link
Contributor

To review this PR, I took a closer look at the version of https://github.com/flitsmeister/mapbox-directions-swift referenced here. Attempting to check out, build and test it led to a bunch of problems that I cannot report in the repo because issues are disabled.
I may be wrong, but I do not feel comfortable using v0.23.3 of https://github.com/flitsmeister/mapbox-directions-swift.git in its current state.
@MaartenZonneveld , since you were involved here: There are a lot of deleted files that are still referenced in the project. I was not able to build any of the targets. Do you consider the current release of https://github.com/flitsmeister/mapbox-directions-swift.git to be mature?

Bildschirmfoto 2024-03-25 um 12 05 57 Bildschirmfoto 2024-03-25 um 12 06 17 Bildschirmfoto 2024-03-25 um 12 38 39

@Patrick-Kladek
Copy link
Contributor

@mindthefish you have opened MapboxDirections.xcodeproj however this part is not actively used in this PR. When you use Swift Package Manager all dependencies will use their Package.swift and not the legacy xcodeproj file.

So maplibre-navigation-ios Package.swift file references https://github.com/flitsmeister/mapbox-directions-swift which will then use https://github.com/flitsmeister/mapbox-directions-swift/Package.swift and this works perfectly. I've run the tests and they all pass *

Bildschirmfoto 2024-04-02 um 15 22 29

  • I would say the failing test testRateLimitErrorParsing should have never been committed as its relying on an external service which will give unreliable results.

We could update to https://github.com/mapbox/mapbox-directions-swift. The License of this project allows it and the last release was on 1st March so it seems to be maintained.

Copyright © 2014–2023, Mapbox

Permission to use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted, provided that the above copyright notice and this permission
notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.

@boldtrn
Copy link
Collaborator

boldtrn commented Apr 2, 2024

We could update to https://github.com/mapbox/mapbox-directions-swift. The License of this project allows it and the last release was on 1st March so it seems to be maintained.

Our goal is to be independent of Mapbox dependencies, so we should not rely on it IMHO. We could decide to fork the directions repo and start a fresh fork, ideally in the MapLibre org. I am not sure if this will introduce other issues / changes.

@hactar
Copy link
Collaborator

hactar commented Apr 2, 2024

Yeah, MapLibre should have its own fork of Mapbox/MapLibre Directions I think too. The question is what should we fork from? mapbox's version, or flitsmeisters version? Anyone know what the differences are?
Screenshot 2024-04-02 at 14 58 26

@Patrick-Kladek
Copy link
Contributor

Patrick-Kladek commented Apr 4, 2024

I've forked this branch and prepared a Pull Request to fix the CI. I've based my changes against @MaartenZonneveld fork and submitted a PR there, however no CI is running there.

My second attempt was to submit the PR against this Repo in #33 however now I need a workflow approval from someone with write access.

319587070-d47ec574-6099-4c5d-a878-71e53da3b3bf

Now that there are 2 Pull Requests this might result in some confusion, so we should agree were we move forward (so I can close the redundant PR) and we get all feedback addressed in one place.

@boldtrn
Copy link
Collaborator

boldtrn commented Apr 4, 2024

I approved the workflow, thanks for working on this 👍. @MaartenZonneveld how would you like to progress? Should we go ahead and review/merge the PR from @Patrick-Kladek? Do you want to pull the relevant changes from #33? That said CI is currently failing for #33

@Patrick-Kladek
Copy link
Contributor

@boldtrn thanks for approving, will check check why it fails

@Patrick-Kladek
Copy link
Contributor

So it turns out the build failed because the GitHub Actions macOS Image doesn't have the latest swift-tools version:

package 'maplibre-navigation-ios' is using Swift tools version 5.9.0 but the installed version is 5.7.1

I've pushed the changes to fix this, however I need another approval. @boldtrn can you approve all my (future) runs or only grant access for one build at a time?

@boldtrn
Copy link
Collaborator

boldtrn commented Apr 4, 2024

I've pushed the changes to fix this, however I need another approval. @boldtrn can you approve all my (future) runs or only grant access for one build at a time?

I approved the CI again. Yeah, unfortunately an admin needs to approve the CI run until your first successful contribution to this repo. So for this PR I'll have to approve every CI run. If you want you can ping me in the OSMUS slack if you want to avoid writing here and if we need multiple runs.

@Patrick-Kladek
Copy link
Contributor

Just found out you can actually create multiple Pull Requests in different Repos from the same branch. Therefore I've created a PR in my fork, enabled GitHub Actions there and made it run. This was way faster and probably less annoying than to ping you every time.

Here is the result: https://github.com/Patrick-Kladek/maplibre-navigation-ios/pull/1

My main finding for GitHub Actions are:

  • image: macos-latest resolves to macOS-12 for some reason, had to explicitly specify macos-14 for the image
  • macos-14 uses Xcode 15.0.1 as default, had to use xcode-select to configure Xcode 15.3
  • be patient, sometimes it seems that there is no progress during the build, after around 5 min the whole workflow completes.
  • from now on we will get nice build warnings & errors in the PR like this

Bildschirmfoto 2024-04-05 um 00 48 26

@boldtrn please approve the workflow again so we get a green checkmark there. After that we should decide how to proceed with reviewing this PR @MaartenZonneveld.

@boldtrn
Copy link
Collaborator

boldtrn commented Apr 5, 2024

Thanks a lot @Patrick-Kladek, the CI passed. @MaartenZonneveld please let us know how you would like to continue 👍

@mindthefish
Copy link
Contributor

Great news, I can't wait to start using SPM for this repo. I'm still a little concerned that over 300 files have been changed to basically enable SPM, but I honestly don't have an overview of all those changes.

@Patrick-Kladek
Copy link
Contributor

Patrick-Kladek commented Apr 5, 2024

@mindthefish I can comment only on my part of the changes, most of which are from deleted files like the Examples (I don't think we can support that via SPM) followed by moving files to different folders.

I would guess the actual changes are 30-50 files and even there most were missing just some imports (seems like SPM is stricter here then Xcode, or Xcode adds some frameworks automatically)

Bildschirmfoto 2024-04-05 um 13 10 38

I would prefer to merge this rather sooner than later as this is a huge PR already. Afterwards I would prepare more Pull Requests like:

  • if needed investigate how to bring the Examples back
  • rename everything from Mapbox to Maplibre, however for this we need to agree which external dependencies (like mapbox-directions) we fork into the maplibre organization.

Once we have that we can make a new major release from where we will support SPM and are truly Maplibre without any references to Mapbox anymore

@mindthefish
Copy link
Contributor

Totally agree!

@XanderD99 XanderD99 mentioned this pull request Apr 9, 2024
@boldtrn
Copy link
Collaborator

boldtrn commented Apr 10, 2024

Thanks again for providing this PR @MaartenZonneveld. Given that this is a big PR and kind of blocking further changes. Would you be able to provide some feedback on how we should continue with the two PRs until tomorrow? Are you fine with the changes from @Patrick-Kladek? Do you want to pull / cherry pick them in your PR or should we close #24 and go ahead with #33, or do you have a different idea?

Given the importance, it would be great if we can go ahead with the SPM compatibility.

@Patrick-Kladek
Copy link
Contributor

As @MaartenZonneveld is not responding I would propose to continue the official discussion in PR #33

@boldtrn
Copy link
Collaborator

boldtrn commented Apr 12, 2024

Given that there hasn't been any update here, let's close this PR in favor for #33.

@boldtrn boldtrn closed this Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants