google-maps-ios-utils icon indicating copy to clipboard operation
google-maps-ios-utils copied to clipboard

[SPM] GoogleMaps 6.x.x XCFramework Not Compiling on x86_64

Open luispadron opened this issue 3 years ago • 10 comments
trafficstars

Environment details

  1. Specify the API at the beginning of the title: GoogleMaps
  2. OS type and version: macOS 11.6.1
  3. Library version and other environment information: XCode 13.2

Steps to reproduce

Using the XCFrameworks from here

We created a Package.swift to wrap these frameworks up:

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "GoogleMaps",
    platforms: [
        .iOS(.v13),
        .macOS(.v10_15),
    ],
    products: [
        .library(
            name: "GoogleMapsBase",
            targets: [
                "GoogleMapsBase"
            ]
        ),
        .library(
            name: "GoogleMapsCore",
            targets: [
                "GoogleMapsCore"
            ]
        ),
        .library(
            name: "GoogleMaps",
            targets: [
                "GoogleMaps",
                "GoogleMapsBase",
                "GoogleMapsCore"
            ]
        ),
        .library(
            name: "GoogleMapsM4B",
            targets: [
                "GoogleMapsM4B"
            ]
        ),
    ],
    targets: [
        .binaryTarget(
            name: "GoogleMaps",
            path: "Frameworks/GoogleMaps.xcframework"
        ),
        .binaryTarget(
            name: "GoogleMapsBase",
            path: "Frameworks/GoogleMapsBase.xcframework"
        ),
        .binaryTarget(
            name: "GoogleMapsCore",
            path: "Frameworks/GoogleMapsCore.xcframework"
        ),
        .binaryTarget(
            name: "GoogleMapsM4B",
            path: "Frameworks/GoogleMapsM4B.xcframework"
        ),
    ]
)

This works fine, we can include the SPM package in Xcode and it'll resolve and pull in the frameworks. However, when we go to build on an X86_64 simulator we get a ton of Undefined symbols for architecture x86_64 errors.

I was under the impression that these frameworks ship with both arm64 and x86 support, and looking at the contents of the .xcframework that seems to be the case. I would expect this to just work but there seems to be an issue here somewhere. This happens on an existing project as well as on a brand new project.

Stack trace

Build logs are attached below: GMSearchAppLogs.txt

luispadron avatar Dec 14 '21 18:12 luispadron

Is this also an issue while trying to install the XCFramework using one of the supported methods (Carthage or installing manually?). Or does this issue only happen while using the XCFrameworks via SPM as shown in your Package.swift?

arriolac avatar Dec 14 '21 23:12 arriolac

I haven't tried it any other way, other than by wrapping it via SPM. We only use SPM at work so was trying to get it functional for the GoogleMaps SDK now that .xcframework are available.

luispadron avatar Dec 14 '21 23:12 luispadron

SPM is not supported yet so there could be integration issues while using it. I recommend using either Carthage or installing the XCFrameworks manually to get around this issue.

See: https://issuetracker.google.com/issues/141721633

arriolac avatar Dec 15 '21 17:12 arriolac

SPM is not supported yet so there could be integration issues while using it. I recommend using either Carthage or installing the XCFrameworks manually to get around this issue.

See: https://issuetracker.google.com/issues/141721633

We'll wait for SPM support, manually installing at scale is really not feasible and adding a second dependency manager on top of SPM with Carthage isn't ideal either. Am a little confused what would be missing for SPM support because xcframeworks should work with SPM in most cases, do you happen to know what is missing?

luispadron avatar Jan 12 '22 20:01 luispadron

Is this also an issue while trying to install the XCFramework using one of the supported methods (Carthage or installing manually?). Or does this issue only happen while using the XCFrameworks via SPM as shown in your Package.swift?

I have the same issue as @luispadron using Carthage (GoogleMaps 6.0.1-beta, xcframeworks GoogleMaps and GoogleMapsBase) when I try to build my project for x86_64 Simulator. So the problem probably lies not in the integration with SPM but in the xcframeworks themselves.

UPDATE: I didn't add GoogleMapsCore.xcframework and that resulted in Undefined symbols for architecture x86_64 errors.

elena-gordienko avatar Jan 14 '22 17:01 elena-gordienko

@luispadron SPM has very limited support for static framework bundles, which GoogleMaps XCFrameworks are. I previously attempted to create a GitHuhb repository to host XCFrameworks to support SPM but ran into some issues due to this structure. I will revisit this once SPM has better support for static framework bundles, or alternatively, GoogleMaps XCFrameworks switches to dynamic frameworks.

@elena-gordienko can you file a separate issue detailing your bug? AFAIK, 6.0.1-beta works using Carthage and installing it manually on both arm64 and x86 simulators. Thanks.

arriolac avatar Jan 14 '22 18:01 arriolac

@arriolac You are right, I've checked it once again and it turns out that the 6.0.1-beta works using Carthage and when installing it manually. The mistake was mine, I forgot to add GoogleMapsCore. Updated my previous comment. Thank you!

elena-gordienko avatar Jan 17 '22 17:01 elena-gordienko

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

stale[bot] avatar Jun 12 '22 22:06 stale[bot]

Can you provide an update to the progress of this please?

iosdevben avatar Jun 21 '22 21:06 iosdevben

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

stale[bot] avatar Jun 18 '23 10:06 stale[bot]