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

[Bug]: Missing XCFrameworks in v3.2.0 #4703

Closed
emilianoalvarez91 opened this issue Jul 29, 2024 · 13 comments
Closed

[Bug]: Missing XCFrameworks in v3.2.0 #4703

emilianoalvarez91 opened this issue Jul 29, 2024 · 13 comments

Comments

@emilianoalvarez91
Copy link

Mapbox Navigation SDK version

v3.2.0

Steps to reproduce

Fetch the mapbox-navigation-ios package pointing to version 3.2.0.

From version 3.1.1 the navigation SDK could be added as xcframeworks, however since 3.2.0 MapboxNavigationCore and MapboxNavigationUIKit and their dependencies are not exposed as binaries.

My Project uses frameworks for modularization and if I add mapbox-navigation-ios as a swift package inside my framework and then add it to my app target the app fails to compile due to duplicated symbols. Therefore, I would require the dependencies as xcframeworks to manually add them.

Expected behavior

All artificts should be retrieved:
_MapboxNavigationUXPrivate.xcframework;
MapboxCoreMaps.xcframework;
MapboxDirections.xcframework;
MapboxMaps.xcframework;
MapboxNavigationCore.xcframework;
MapboxNavigationUIKit.xcframework;
Turf.xcframework;
MapboxNavigationNative.xcframework;
MapboxCommon.xcframework.

Actual behavior

Only these are retrieved as XCFrameworks:
MapboxCoreMaps.xcframework;
MapboxNavigationNative.xcframework;
MapboxCommon.xcframework.

Is this a one-time issue or a repeatable issue?

repeatable

@emilianoalvarez91 emilianoalvarez91 added the bug Something isn’t working label Jul 29, 2024
@kried
Copy link
Contributor

kried commented Aug 1, 2024

Hi @emilianoalvarez91

Thank you for the report.

The Nav SDK iOS is intended to be distributed as open source. We intentionally switched to the source code distribution for the Swift SDKs, as we did for the v2 SDK.

You can create local frameworks for the distributed libraries using the standard xcodebuild -create-xcframework command or by using some third party tools, like Scipio.

@emilianoalvarez91
Copy link
Author

Hi @kried, have you tried building the XCFrameworks on 3.2.0?

When using Scipio I'm getting the following error:
Screenshot 2024-08-02 at 01 09 23

Which is exactly the same issue that I get when I'm trying to embed the framework when using SMP

image
image
image
image

@fbeccaceci
Copy link

Hi @kried, have you tried building the XCFrameworks on 3.2.0?

When using Scipio I'm getting the following error: Screenshot 2024-08-02 at 01 09 23

Which is exactly the same issue that I get when I'm trying to embed the framework when using SMP

image image image image

I'm having the same problem, did you find a solution?

@emilianoalvarez91
Copy link
Author

Not yet, I'm still waiting for a solution on this

@emilianoalvarez91
Copy link
Author

Hi, @kried @chizhavko @volkdmitri the new framework distribution is not allowing to upgrade to the newest framework. I've tried the solution proposed by @kried but that's not working as there is something wrong in how MapboxNavigationCore is created.

Not being able to migrate to v3.2.0 is a serious issue as v3.1.1 doesn't allow you to use dynamic access tokens and forcing the only option to expose the access token in the info.plist.

I'm trying to upgrade since July 1st and still I'm unable to do so. What are the options to migrate to the newest versions of the framework?

@kried
Copy link
Contributor

kried commented Aug 19, 2024

Hi @emilianoalvarez91

The Nav SDK iOS is distributed as source code, in both v3 and v2. It is the designated way for our library to distribute the release. We will support a second option to distribute the release as a framework, but at the moment I cannot guarantee the timeline.


As a temporary workaround, you can build local xcframework. Please note that in this case, you need to provide all dependencies as frameworks.

You can test the flow in a branch kried/framework-build. Execute sh scripts/build_frameworks.sh in the root directory and open the Examples/Examples.xcodeproj project.


I've tried the solution proposed by @kried but that's not working as there is something wrong in how MapboxNavigationCore is created.

On the screenshot, it is visible that the dependency MapboxNavigationNative was not added. You need to add all the compiled frameworks to the project to resolve missing symbol errors.

  1. You can update Package.swift: remove test targets and specify explicitly dependency on MapboxNavigationNative binary target. I attached the example Package.swift for v3.3.0.
    Package.swift.zip

  2. build the frameworks with Scipio by executing the following lines in the mapbox-navigation-ios directory:

if [ ! -d "scipts/Scipio" ]; then
    git clone https://github.com/giginet/Scipio.git scipts/Scipio
fi
cd scipts/Scipio
git checkout "0.21.0"
swift build -c release

swift run -c release scipio create ../.. -f \
    --platforms iOS  \
    --only-use-versions-from-resolved-file \
    --enable-library-evolution \
    --support-simulators \
    --embed-debug-symbols \
    --verbose
  1. Update Framework Search Path in Xcode project to contain the build results from $PROJECT_DIR/../XCFrameworks
  2. Embed the xcframeworks into the project. Please note that you need to embed all of the frameworks on the screenshots and not add the dependencies through SPM.
Screenshot 2024-08-19 at 22 18 12

@emilianoalvarez91
Copy link
Author

@kried thank you very much for the thorough response, I will check this tomorrow.

@fbeccaceci
Copy link

Hi @emilianoalvarez91

The Nav SDK iOS is distributed as source code, in both v3 and v2. It is the designated way for our library to distribute the release. We will support a second option to distribute the release as a framework, but at the moment I cannot guarantee the timeline.

As a temporary workaround, you can build local xcframework. Please note that in this case, you need to provide all dependencies as frameworks.

You can test the flow in a branch kried/framework-build. Execute sh scripts/build_frameworks.sh in the root directory and open the Examples/Examples.xcodeproj project.

I've tried the solution proposed by @kried but that's not working as there is something wrong in how MapboxNavigationCore is created.

On the screenshot, it is visible that the dependency MapboxNavigationNative was not added. You need to add all the compiled frameworks to the project to resolve missing symbol errors.

  1. You can update Package.swift: remove test targets and specify explicitly dependency on MapboxNavigationNative binary target. I attached the example Package.swift for v3.3.0.
    Package.swift.zip
  2. build the frameworks with Scipio by executing the following lines in the mapbox-navigation-ios directory:
if [ ! -d "scipts/Scipio" ]; then
    git clone https://github.com/giginet/Scipio.git scipts/Scipio
fi
cd scipts/Scipio
git checkout "0.21.0"
swift build -c release

swift run -c release scipio create ../.. -f \
    --platforms iOS  \
    --only-use-versions-from-resolved-file \
    --enable-library-evolution \
    --support-simulators \
    --embed-debug-symbols \
    --verbose
  1. Update Framework Search Path in Xcode project to contain the build results from $PROJECT_DIR/../XCFrameworks
  2. Embed the xcframeworks into the project. Please note that you need to embed all of the frameworks on the screenshots and not add the dependencies through SPM.
Screenshot 2024-08-19 at 22 18 12

Thanks @kried now i can build the frameworks correctly and they works included as you show, anyway i'm trying to include them as vedored_frameworks in a pod but i get some errors with duplicated declarations
Screenshot 2024-08-20 alle 10 01 28

@kried
Copy link
Contributor

kried commented Aug 20, 2024

Thanks @kried now i can build the frameworks correctly and they works included as you show, anyway i'm trying to include them as vedored_frameworks in a pod but i get some errors with duplicated declarations

@fbeccaceci The problem is that if you add MapboxNavigation as frameworks, you should also use all its dependencies as frameworks. So you cannot use the public open source release of MapboxMaps, because it leads to the symbols duplications for the Maps SDK and its dependencies, like MapboxCommon.

On your screenshots, it looks like there are duplicate symbols for MapboxCommon. Please ensure that you don't use dependencies on the podsMapboxMaps in your podspec, but explicitly add them as frameworks.

@fbeccaceci
Copy link

This is my podspec

Pod::Spec.new do |s|
  s.name           = 'ExpoMapboxNavigation'
  s.version        = '1.0.0'
  s.summary        = 'A sample project summary'
  s.description    = 'A sample project description'
  s.author         = ''
  s.homepage       = 'https://docs.expo.dev/modules/'
  s.platforms      = { :ios => '15.0', :tvos => '15.0' }
  s.source         = { git: '' }
  s.static_framework = true

  s.dependency 'ExpoModulesCore'
  s.dependency 'SnapKit', '~> 5.7.0'

  s.vendored_frameworks = [
    "Frameworks/_MapboxNavigationHelpers.xcframework",
    "Frameworks/MapboxCommon.xcframework",
    "Frameworks/MapboxCoreMaps.xcframework",
    "Frameworks/MapboxDirections.xcframework",
    "Frameworks/MapboxMaps.xcframework",
    "Frameworks/MapboxNavigationCore.xcframework",
    "Frameworks/MapboxNavigationNative.xcframework",
    "Frameworks/MapboxNavigationUIKit.xcframework",
    "Frameworks/Turf.xcframework"
  ]

  # Swift/Objective-C compatibility
  s.pod_target_xcconfig = {
    'DEFINES_MODULE' => 'YES',
    'SWIFT_COMPILATION_MODE' => 'wholemodule'
  }

  s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
end

I fixed the last 2 errors ("No such module 'MapboxMaps'") fixing a typo on the podspec but the redefinition errors remained, i don't have any dependency on any mapbox library in the pospec and i added all the frameworks

@fbeccaceci
Copy link

@kried I actually managed to fix the errors adding

s.exclude_files = "Frameworks/*.xcframework/**/*.h"

to the podspec

Now i got a question, can the frameworks be compiled as static frameworks? Cause i tried with scipio and the compile but then at runtime i get this exception
Screenshot 2024-08-20 alle 10 41 16

@fbeccaceci
Copy link

I got it working using use_frameworks! :linkage => :static don't really know why, i'm not that an expert about ios frameworks stuff

@emilianoalvarez91
Copy link
Author

@kried I checked your branch and it works, also I could check the dynamic access token and that works too, thank you very much with the help here.

Can this solution be integrated into future versions of Package.swift? I don't mind generating the xcframeworks, but I prefer not to modify the original file. Otherwise, it would be difficult to track the URL for downloading MapboxNavigationNative.xcframework.zip or other framework dependencies.

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

No branches or pull requests

3 participants