SwiftUI Preview Runtime linking failure

I'm using GoogleMaps in my project.

Legacy preview works well but new preview (Xcode 16.3.1 beta) produces error. It doesn't seem to find Googlemaps.a.

== PREVIEW UPDATE ERROR:

    FailedToLaunchAppError: Failed to launch ***
    
    ==================================
    
    |  [Remote] JITError
    |  
    |  ==================================
    |  
    |  |  [Remote] CouldNotLoadInputStaticArchiveFile: Could not load static archive during preview: /Users/xxx/Library/Developer/Xcode/DerivedData/BOA-eiluspltxasszsfkpqrnnsxsjhth/Build/Products/Debug_BOA_Inhouse-iphonesimulator/GoogleMaps.a
    |  |  
    |  |  path: /Users/xxx/Library/Developer/Xcode/DerivedData/BOA-eiluspltxasszsfkpqrnnsxsjhth/Build/Products/Debug_BOA_Inhouse-iphonesimulator/GoogleMaps.a
    |  |  
    |  |  ==================================
    |  |  
    |  |  |  [Remote] XOJITError
    |  |  |  
    |  |  |  XOJITError: arm64 slice of /Users/xxx/Library/Developer/Xcode/DerivedData/BOA-eiluspltxasszsfkpqrnnsxsjhth/Build/Products/Debug_BOA_Inhouse-iphonesimulator/GoogleMaps.a does not contain an archive

Whoa, that's wild. Can you file a feedback with the fully preview diagnostics and also attach your build of GoogleMaps.a? We need to take a look at your build settings and that specific build product to understand what's going on here.

Hi, I filed a feedback. The number is FB16747894.

Any updates?

We're investigating ways we mitigate this, but looking at the GoogleMaps.a you uploaded, it's not actually a static archive. It's a universal object file. I assume you are building this using the public GoogleMaps SDK so I pulled it down but when I built the sample project, the GoogleMaps.a file is a static archive.

Are you using an older version of the SDK perhaps that emitted a different kind of build product? If so could you let me know how you're including it in your project? Like the Swift Package version or the like?

In the meantime, are you able to rename that file to be GoogleMaps.o and try that?

As you said, GoogleMaps.a is not a static library when I check it with

lipo -info GoogleMaps.a

the result is

Architectures in the fat file: GoogleMaps.a are: x86_64 arm64

And I'm using GoogleMaps v8.3.0 as the package's dependency and it produces a same result when I change it to v9.3.

But it works when I make a new project and only add GoogleMaps with dependencies not package's dependencies and both results are the universal object GoogleMaps.a not the static library.

FYI, I found GoogleMapsTarget.o which is static library in the same directory where the GoogleMaps.a is.

Finally when I change GoogleMaps.a to .o Xcode regenerates GoogleMaps.a and produces results

== PREVIEW UPDATE ERROR:

    FailedToLaunchAppError: Failed to launch previews.com.apple.PreviewAgent.iOS
    
    ==================================
    
    |  [Remote] JITError
    |  
    |  ==================================
    |  
    |  |  [Remote] CouldNotLoadInputStaticArchiveFile: Could not load static archive during preview: /Users/***/Library/Developer/Xcode/DerivedData/BOA-eiluspltxasszsfkpqrnnsxsjhth/Build/Products/Debug_BOA_Inhouse-iphonesimulator/PackageFrameworks/GoogleMaps.a
    |  |  

Ah this is a good piece of info I was missing before. What is the dependency that is importing GoogleMaps on your behalf? Is it a public package that I could use to try to reproduce?

No it's private package.

In our package, We have several 3rd party maps and these maps are compiled with the predefined settings in Xcode and the google map is one of them.

Due to security reasons, we cannot share the internal structure. However, when Google Maps is required, it is added as a target in the project, as shown below.

  static var google = PackageDescription.Package.Dependency.package(
    url: "https://github.com/googlemaps/ios-maps-sdk.git",
    from: "8.4.0"
  )

...
...
...

static var google: [PackageDescription.Target] = [
    .target(
      name: .google,
      dependencies: [
        .byName(name: .core),
        .product(name: "GoogleMaps", package: "ios-maps-sdk"),
        .product(name: "GoogleMapsBase", package: "ios-maps-sdk"),
        .product(name: "GoogleMapsCore", package: "ios-maps-sdk")
      ],
      resources: [
        .copy("Theme/dark.json")
      ]
    )
  ]

Thank you for bearing with me! This was key missing information. I can reproduce the problem in a small sample project using a package structure like you described here. I'll update the feedback and see what we can do with the build system and linker teams to figure this out.

Ok, sounds good!

I'm waiting and please tell me if you need more information.

@Frameworks Engineer

Is there any news for this subject?

I'm looking forward to see the fix in new Xcode beta release.

Any Updates? I am getting similar error when using latest version of GoogleMaps and GooglePlacesSwift SDKs. I cannot run SwiftUI previews.


    [Remote] JITError: Runtime linking failure
    
    Additional Link Time Errors:
    Symbols not found: [ _$s17GooglePlacesSwift5PlaceVMa, _$s17GooglePlacesSwift9PlaceTypeVMa, _$s17GooglePlacesSwift9PlaceTypeV8rawValueSSvg, _$s17GooglePlacesSwift5PlaceV5typesShyAA0D4TypeVGvg, _$s17GooglePlacesSwift5PlaceV16formattedAddressSSSgvg, _$s17GooglePlacesSwift5PlaceV11displayNameSSSgvg, _$s17GooglePlacesSwift24AutocompleteSessionTokenVMa, _$s17GooglePlacesSwift9PlaceTypeVMn ]
    
    ==================================
    
    |  [Remote] LLVMError
    |  
    |  LLVMError: LLVMError(description: "Failed to materialize symbols: { (static-Main, { __replacement_tag$1 }) }")

Here is a whole diagnose summary if it helps.

SwiftUI Preview Runtime linking failure
 
 
Q