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

Conversation

evil159
Copy link
Contributor

@evil159 evil159 commented Jan 30, 2023

This PR is based on #1759:

When using CocoaPods with static linking the resources will be copied to the root of the .app. When copying these resources the build will fail if the application already contains any resources with the same name. This will happen in any application that has its own Assets.xcassets since the application will generate an Assets.car and the MapboxMaps pod will also try to copy its own Assets.car to the .app.

The recommended solution for this with CocoaPods is to use resource_bundles. This will cause CocoaPods to create a bundle with the name specified in resource_bundles. The created resource bundle will be copied to either the .framework or .app depending on the linking method used, resolving any resource conflicts with the hosting application.

Additionally code signing is disabled for Cocoapods distribution pending Cocoapods issue CocoaPods/CocoaPods#11402 to be included in the upcoming release.

@evil159 evil159 requested a review from a team as a code owner January 30, 2023 16:27
@codecov
Copy link

codecov bot commented Jan 30, 2023

Codecov Report

Merging #1888 (e98278e) into main (8fde41a) will decrease coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1888      +/-   ##
==========================================
- Coverage   89.31%   89.25%   -0.06%     
==========================================
  Files         243      243              
  Lines       15174    15183       +9     
==========================================
- Hits        13552    13551       -1     
- Misses       1622     1632      +10     
Flag Coverage Δ
integration 57.51% <100.00%> (-0.11%) ⬇️
unit 83.64% <100.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...Maps/Foundation/Extensions/Bundle+MapboxMaps.swift 100.00% <100.00%> (ø)
Sources/MapboxMaps/Foundation/DateProvider.swift 0.00% <0.00%> (-50.00%) ⬇️
Sources/MapboxMaps/Offline/OfflineErrors.swift 43.85% <0.00%> (-7.02%) ⬇️
Sources/MapboxMaps/Style/SourceType.swift 87.50% <0.00%> (-6.25%) ⬇️
...MapboxMaps/Foundation/ResourceOptionsManager.swift 95.08% <0.00%> (-3.28%) ⬇️

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

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!

@Saikishore031
Copy link

HI Team,

Could you please help me to build iOS using azure devops pipelines with two provisioning profiles, build is getting succeeded but when trying to install the IPA file in iOS device it is getting crashed. Same code is working in local machine with Xcode 14.2

@evil159 evil159 enabled auto-merge (squash) February 1, 2023 11:10
@evil159 evil159 merged commit 72654de into main Feb 1, 2023
@evil159 evil159 deleted the rl/MAPSIOS-572-fix-static-linking-cocoapods branch February 1, 2023 11:22
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.

None yet

4 participants