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

Invalid Mac & Catalyst Framework Bundles #12668

Closed
pmacro opened this issue Mar 31, 2024 · 10 comments
Closed

Invalid Mac & Catalyst Framework Bundles #12668

pmacro opened this issue Mar 31, 2024 · 10 comments
Assignees
Labels

Comments

@pmacro
Copy link

pmacro commented Mar 31, 2024

Description

I'm unable to create an archive of my Mac Catalyst app due to the Framework Bundles not being correctly setup (please see the attached log snippets).

The problem is that the bundles are supposed to use symlinks, but instead they include three copies of the binary, Modules, Resources, and PrivateHeaders. Taking the example of GoogleAppMeasurement.xcframework, this makes it almost twice as large as it needs to be overall, and makes the included macOS and Catalyst .frameworks three times larger than they should be.

According to Apple, the top level entries should symlink to Versions/Current, which should in turn symlink to Versions/A (or Versions/Whatever).

Workaround

# resolve packages as a separate step
xcodebuild -resolvePackageDependencies -workspace My.xcworkspace -scheme MyScheme -derivedDataPath build -destination generic/platform\=macOS,variant\=Mac\ Catalyst

cd build/SourcePackages/artifacts

# Fixes the "Current" symlink. This makes the archive succeed.
find -P . -regex ".*\.framework/\Versions/\Current" -execdir rm -rf {} \; -execdir ln -s A {} \;
# Find the top-level symlinks and fix those too. The archive succeeds without this, but is rejected by Apple.
# I haven't scripted this yet, but `ln -s ` all top-level entries to the matching Versions/Current/blah entry.

# Create the archive as normal, but avoid touching the packages.
xcodebuild -skipPackageUpdates -workspace My.xcworkspace -scheme MyScheme -derivedDataPath build -destination generic/platform\=macOS,variant\=Mac\ Catalyst archive

Reproducing the issue

Reproduce errors

  • Create a Mac Catalyst (or probably Mac, too) app.
  • Add some Firebase dependencies, like FirebaseAnalytics.
  • Create an archive using xcodebuild. You should see errors.

Inspect incorrect Framework Bundles

  • Download one of the binaries, such as the analytics one
  • Compare the Catalyst or Mac frameworks with Apple's docs. Also observe the unnecessary copies and wasted bandwidth/CI/storage this causes for Google as well as Firebase users.

Firebase SDK Version

10.23.1

Xcode Version

15.3

Installation Method

Swift Package Manager

Firebase Product(s)

Analytics, Crashlytics

Targeted Platforms

macCatalyst

Relevant Log Output

Couldn't resolve framework symlink for '/Users/username/dev/MyApp/build/SourcePackages/artifacts/googleappmeasurement/GoogleAppMeasurement/GoogleAppMeasurement.xcframework/ios-arm64_x86_64-maccatalyst/GoogleAppMeasurement.framework/Versions/Current': readlink(/Users/username/dev/MyApp/build/SourcePackages/artifacts/googleappmeasurement/GoogleAppMeasurement/GoogleAppMeasurement.xcframework/ios-arm64_x86_64-maccatalyst/GoogleAppMeasurement.framework/Versions/Current): Invalid argument (22) (in target 'MyApp' from project 'MyApp')
    Couldn't resolve framework symlink for '/Users/username/dev/MyApp/build/SourcePackages/artifacts/firebase-ios-sdk/FirebaseAnalytics/FirebaseAnalytics.xcframework/ios-arm64_x86_64-maccatalyst/FirebaseAnalytics.framework/Versions/Current': readlink(/Users/username/dev/MyApp/build/SourcePackages/artifacts/firebase-ios-sdk/FirebaseAnalytics/FirebaseAnalytics.xcframework/ios-arm64_x86_64-maccatalyst/FirebaseAnalytics.framework/Versions/Current): Invalid argument (22) (in target 'MyApp' from project 'MyApp')
    Couldn't resolve framework symlink for '/Users/username/dev/MyApp/build/SourcePackages/artifacts/googleappmeasurement/GoogleAppMeasurementIdentitySupport/GoogleAppMeasurementIdentitySupport.xcframework/ios-arm64_x86_64-maccatalyst/GoogleAppMeasurementIdentitySupport.framework/Versions/Current': readlink(/Users/username/dev/MyApp/build/SourcePackages/artifacts/googleappmeasurement/GoogleAppMeasurementIdentitySupport/GoogleAppMeasurementIdentitySupport.xcframework/ios-arm64_x86_64-maccatalyst/GoogleAppMeasurementIdentitySupport.framework/Versions/Current): Invalid argument (22) (in target 'MyApp' from project 'MyApp')

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
      {
        "package": "Firebase",
        "repositoryURL": "https://github.com/firebase/firebase-ios-sdk",
        "state": {
          "branch": null,
          "revision": "888f0b6026e2441a69e3ee2ad5293c7a92031e62",
          "version": "10.23.1"
        }
      },
      {
        "package": "GoogleAppMeasurement",
        "repositoryURL": "https://github.com/google/GoogleAppMeasurement.git",
        "state": {
          "branch": null,
          "revision": "c7a5917ebe48d69f421aadf154ef3969c8b7f12d",
          "version": "10.23.1"
        }
      },
      {
        "package": "GoogleDataTransport",
        "repositoryURL": "https://github.com/google/GoogleDataTransport.git",
        "state": {
          "branch": null,
          "revision": "a637d318ae7ae246b02d7305121275bc75ed5565",
          "version": "9.4.0"
        }
      },
      {
        "package": "GoogleUtilities",
        "repositoryURL": "https://github.com/google/GoogleUtilities.git",
        "state": {
          "branch": null,
          "revision": "26c898aed8bed13b8a63057ee26500abbbcb8d55",
          "version": "7.13.1"
        }
      },

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@pmacro
Copy link
Author

pmacro commented Mar 31, 2024

I missed that this is essentially a duplicate of #12587

@pmacro pmacro closed this as completed Mar 31, 2024
@paulb777
Copy link
Member

paulb777 commented Apr 1, 2024

Reopening since this is not a duplicate. #12587 was fixed in 10.23.1, but it looks like there's an issue with the structure with the Swift Package Manager distribution. Note the links in the finder when downloading the SPM zip versus the nightly zip distribution:

Screenshot 2024-04-01 at 6 44 50 AM

@paulb777 paulb777 reopened this Apr 1, 2024
@paulb777 paulb777 added api: analytics macOS Issues or feature requests for macOS. Swift Package Manager Catalyst and removed needs-triage labels Apr 1, 2024
@paulb777 paulb777 added this to the 10.24.0 - M146 milestone Apr 1, 2024
@ncooke3
Copy link
Member

ncooke3 commented Apr 1, 2024

zip -r is used to compress the XCFrameworks for SwiftPM binary distros. It looks like this does not preserve the symlinks when unzipping.

@ncooke3
Copy link
Member

ncooke3 commented Apr 1, 2024

The release tooling is being updated to zip with the --symlinks flag in 10.24.0 to preserve the symlinks and avoid the unneeded extra directories.

@ncooke3 ncooke3 closed this as completed Apr 1, 2024
@cdebortoliWebedia
Copy link

It seems linked, I cannot push on git the updated frameworks (from Cocoapods). There is no problem with the 10.22.0 version.

fatal: pathspec 'Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/ios-arm64_x86_64-maccatalyst/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h' is beyond a symbolic link

@stopthatnoise
Copy link

stopthatnoise commented Apr 10, 2024

the problem with

fatal: pathspec '/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/ios-arm64_x86_64-maccatalyst/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h' is beyond a symbolic link

still exist in 10.24. I cannot stage pods for git. 10.22 works fine

@appfrilans
Copy link

Get similar issues with Xcode 15.3 and Firebase 10.24:

/Users/xxxx/Library/Developer/Xcode/DerivedData/.....x.app: code object is not signed at all
In subcomponent: /Users/xxxx/Library/Developer/Xcode/DerivedData/projectx-cysskpexycpatifcnhjfjwtdldad/Build/Products/Debug-maccatalyst/x.app/Contents/Frameworks/GoogleAppMeasurement.framework

@ncooke3
Copy link
Member

ncooke3 commented Apr 10, 2024

the problem with

fatal: pathspec '/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/ios-arm64_x86_64-maccatalyst/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h' is beyond a symbolic link

still exist in 10.24. I cannot stage pods for git. 10.22 works fine

@stopthatnoise, could you please open a new issue with more details on the error, including how to reproduce?


@appfrilans, could you please open a new issue with more details on how the code object is not signed at all error appeared?

@mushyoom
Copy link

mushyoom commented Apr 17, 2024

@ncooke3 (@stopthatnoise )

the problem with

fatal: pathspec '/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/ios-arm64_x86_64-maccatalyst/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h' is beyond a symbolic link

still exist in 10.24. I cannot stage pods for git. 10.22 works fine

Hi, I have opened an issue to describle the details .
Looking forward to your confirmation and response :)

@firebase firebase locked and limited conversation to collaborators May 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

9 participants