-
Notifications
You must be signed in to change notification settings - Fork 161
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
Update our Package.swift to build MapboxMaps from source #125
Conversation
Codecov Report
@@ Coverage Diff @@
## main #125 +/- ##
==========================================
+ Coverage 48.93% 48.97% +0.03%
==========================================
Files 101 102 +1
Lines 5683 5687 +4
==========================================
+ Hits 2781 2785 +4
Misses 2902 2902
Flags with carried forward coverage won't be shown. Click here to find out more.
|
let bundle = Bundle(for: type(of: self)) | ||
var sdkVersionOptional = bundle.infoDictionary?["MGLSemanticVersionString"] | ||
if sdkVersionOptional == nil { | ||
sdkVersionOptional = bundle.infoDictionary?["CFBundleShortVersionString"] | ||
} | ||
guard let sdkVersion = sdkVersionOptional as? String else { return } | ||
let sdkVersion = "10.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a ticket to find a better solution
@@ -1,4 +1,4 @@ | |||
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon-ios.json" "10.0.0-beta.11" | |||
binary "https://api.mapbox.com/downloads/v2/carthage/mobile-maps-core/MapboxCoreMaps-dynamic.json" "10.0.0-beta.15" | |||
github "mapbox/mapbox-events-ios" "v0.10.7" | |||
github "mapbox/mapbox-events-ios" "v0.10.8" | |||
github "mapbox/turf-swift" "v2.0.0-alpha.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to update Turf here and in the podspec as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we still need this version for Carthage so that it gets built in library evolution mode. For CocoaPods, we will switch to 1.2.0 as part of #118.
3c9e79b
to
f298012
Compare
Configuration Changes: - Updated Package.swift to build the project from source - Reorganized the source files according to SPM conventions - Updated the paths of the groups in the MapboxMaps Xcode project to point to the new file locations - Marked OrnamentsLocalizable.strings as a localized resource - Updated MBXGeometry.swift to conditionally compile the @unknown default: of a switch statement with an expression of type Geometry from Turf. This is required since when we build the SDK as an XCFramework, Turf is compiled in library evolution mode, so a default case is required, but when we build the SDK as a Swift package, Turf is not built in library evolution mode, so the default case is unnecessary (and the compiler warns if it is present). - .gitignore updates: - Stopped ignoring IDEWorkspaceCHecks.plist - Stopped ignoring .swiftpm - Stopped ignoring Package.resolved - Started ignoring MapboxAccessToken Dependency Version Changes: - Switched to MapboxMobileEvents v0.10.8 (Carthage & SPM only) - Switched to Turf v1.2.0 (SPM only) Bundle & Info.plist Usage Changes: - Added a Build Pre-Action to MapboxMaps's SPM scheme to copy the Mapbox access token from either ~/.mapbox or ~/mapbox into the new MapboxAccessToken file. The integration tests need this token. Previously, they looked for it in the test bundle's Info.plist, but this approach does not work for SPM. IntegrationTestCase.setupAccessToken() has been updated accordingly. - Added Bundle.mapboxMaps and Bundle.mapboxMapsTests abstractions to allow accessing the SDK's resources. These abstractions handle differences that occur when building the SDK as a Swift package vs building it as a framework. In the SDK source, Bundle.main is used when the intent is to access the bundle of the containing application, and Bundle.mapboxMaps is used when the intent is to use the SDK's bundle. - Replaced usages of Bundle.object(forInfoDictionaryKey:) with Bundle.infoDictionary?[] - Hard-coded the SDK version in EventsManager.swift because we will not be able to customize the SDK's Info.plist when the SDK is built as a Swift package. Fixes: - Fixed an issue in MapViewIntegrationTests.setUpWithError() in which super.setUpWithError() was invoked with try? instead of try, preventing it from being able to skip the test. - Reviewed Xcode 12.4's upgrade recommendations - Fixed a canImport in MapboxMapsAnnotationsTests.swift Deletions: - Deleted unused installation tests - Deleted some placeholder SPM-style tests in the Tests directory - Deleted some unused source files and dangling file references
f298012
to
195f58b
Compare
The change broke building the Examples scheme for testing.
dependencies: [ | ||
.package(name: "MapboxCommon", url: "https://github.com/mapbox/mapbox-common-ios.git", .exact("10.0.0-beta.11")), | ||
.package(name: "MapboxCoreMaps", url: "https://github.com/mapbox/mapbox-core-maps-ios.git", .exact("10.0.0-beta.15")), | ||
.package(name: "MapboxMobileEvents", url: "https://github.com/mapbox/mapbox-events-ios.git", .exact("0.10.8")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be exact
, or can it be from:
like the Turf dependency and Cartfile?
Pull request checklist:
mapbox-maps-ios
changelog:<changelog>MapboxMaps can now be built and tested using Swift Package Manager</changelog>
.Summary of changes
Configuration Changes
Package.swift
to build the project from sourceOrnamentsLocalizable.strings
as a localized resourceMBXGeometry.swift
to conditionally compile the@unknown default:
of a switch statement with an expression of typeGeometry
from Turf. This is required since when we build the SDK as an XCFramework, Turf is compiled in library evolution mode, so adefault
case is required, but when we build the SDK as a Swift package, Turf is not built in library evolution mode, so thedefault
case is unnecessary (and the compiler warns if it is present)..gitignore
updates:IDEWorkspaceCHecks.plist
.swiftpm
Package.resolved
MapboxAccessToken
Dependency Version Changes
Bundle & Info.plist Usage Changes
~/.mapbox
or~/mapbox
into the newMapboxAccessToken
file. The integration tests need this token. Previously, they looked for it in the test bundle'sInfo.plist
, but this approach does not work for SPM.IntegrationTestCase.setupAccessToken()
has been updated accordingly.Bundle.mapboxMaps
andBundle.mapboxMapsTests
abstractions to allow accessing the SDK's resources. These abstractions handle differences that occur when building the SDK as a Swift package vs building it as a framework. In the SDK source,Bundle.main
is used when the intent is to access the bundle of the containing application, andBundle.mapboxMaps
is used when the intent is to use the SDK's bundle.Bundle.object(forInfoDictionaryKey:)
withBundle.infoDictionary?[]
EventsManager.swift
because we will not be able to customize the SDK'sInfo.plist
when the SDK is built as a Swift package.Fixes
MapViewIntegrationTests.setUpWithError()
in whichsuper.setUpWithError()
was invoked withtry?
instead oftry
, preventing it from being able to skip the test.canImport
inMapboxMapsAnnotationsTests.swift
Deletions
Tests
directory