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

Fix static linking cocoapods #1888

Merged
merged 10 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Mapbox welcomes participation and contributions from everyone.

## main

* Added basic signposts for performance profiling. To enable them, use `MAPBOX_MAPS_SIGNPOSTS_ENABLED` environment variable. ([#1818](https://github.com/mapbox/mapbox-maps-ios/pull/1818))
* Fix build erros appearing when SDK distributed as a static library through Cocoapods. ([#1888](https://github.com/mapbox/mapbox-maps-ios/pull/1888))

## 10.11.0-rc.1 - January 26, 2023

Expand Down
6 changes: 5 additions & 1 deletion MapboxMaps.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ Pod::Spec.new do |m|
m.swift_version = '5.5'

m.source_files = 'Sources/MapboxMaps/**/*.{swift,h}'
m.resources = ['Sources/**/*.{xcassets,strings}', 'Sources/MapboxMaps/MapboxMaps.json']
m.resource_bundles = { 'MapboxMapsResources' => ['Sources/**/*.{xcassets,strings}', 'Sources/MapboxMaps/MapboxMaps.json'] }

# Xcode 14.x throws an error about code signing on resource bundles, turn it off for now.
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a TODO to remove this when cocoapods 1.12 is released, they fixed this issue CocoaPods/CocoaPods#11723

# TODO: remove after Cocoapods 1.12 is released
m.pod_target_xcconfig = { 'CODE_SIGNING_ALLOWED' => 'NO' }

m.dependency 'MapboxCoreMaps', '10.11.0-rc.1'
m.dependency 'MapboxMobileEvents', '1.0.10'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ extension Bundle {
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: BundleLocator.self)
// When using frameworks this bundle will be our `.framework` bundle.
// When using static linking this bundle will be the the host application's `.app` bundle.
let bundle = Bundle(for: BundleLocator.self)
Copy link
Contributor

Choose a reason for hiding this comment

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

Basically, this bundle will be used only for binary distribution, right?

I mean, for spm the module bundle will be used, for cocoapods, it will be the MapboxMapsResources.bundle, but for binary distribution we still need BundleLocator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly!


// When using CocoaPods a "resource bundle" will be used to avoid resource conflicts with the host application.
// Check for the existence of the resource bundle and use that instead if it is present.
let resourceBundle = bundle.path(forResource: "MapboxMapsResources", ofType: "bundle")
.flatMap(Bundle.init(path:))

return resourceBundle ?? bundle
#endif
}

Expand Down