How can I get checksum for a Binary Package?
Asked Answered
A

2

9

I created my xcframework on my Desktop called MyXCFramework.xcframework then I zipped it like Boris said in WWDC2020 about Distribute binary frameworks as Swift packages both files are on Desktop and I want to get my checksum, then I used this line of code in terminal:

cd ~/Desktop/

swift package compute-checksum ~/Desktop/MyXCFramework.xcframework.zip

But terminal through this error:

error: root manifest not found

How can I solve this error?

I do not know why terminal trying to reach to manifest in this point?! because there is no manifest yet! I need checksum to build my manifest for Distribute binary framework as Swift package. So How can I solve this issue?

Acrylic answered 26/7, 2021 at 12:24 Comment(2)
if you are already at the current folder (desktop) why are you using ~/Desktop/ when computing the checksum? I remember that I had similar issue and when running from the same folder it solved.Unhandy
@Leo: if you open your terminal you would not be on level of Desktop! Therefore I moved to Desktop level. Also you mentioned about same folder! What you mean by that? As you see the WWDC video, Boris doesn’t explain or show how he did, just presented the terminal command with issue! I checked other similar issues like mein! Almost every one has issue to create the checksum. I can send or share my test framework also my xcframework with you, if it helps to find the answer. My xcframework works just fine but I cannot make checksum!Acrylic
A
9

After searching a lot and lots of trial and errors I found 2 ways to solve the issue:

First way from Apple

To create the required checksum, open the Terminal app, navigate to the root of the package, and run swift package compute-checksum path/to/MyFramework.zip.

Way 1:

1 - It is important to mention that Apple says MyFramework.zip but in the fact it is MyXCFramework.zip

2 - Apple says: navigate to the root of the package it means the package that you are going to type and give checksum to! It is weird that the Folder or the Package is needed for reading checksum because checksum is the parameter for Package! I do not know what is happening under the hood but it is how it works.

Way 2:

You can give some dummy value as checksum to Package, then Xcode would through an error and give you the correct and needed checksum and also tell you the wrong checksum you used. Then you copy that error massage and strike the correct checksum and replace it instead of the dummy checksum. We are not done yet! As Xcode wouldn't have build the correct Package with new correct checksum, it would be in kind of a lockdown! You need to go to File in Xcode then Swift Package then click on Reset Package Caches. After that you are good to go! In this way you shortcut the Terminal way for reading checksum.

Here you are 2 way of finding checksum!

Acrylic answered 27/7, 2021 at 7:42 Comment(0)
J
3

This happens if you're trying to compute the checksum of a Swift binary artifact you've downloaded and which is in a directory that's not a Swift Package. You can still compute its checksum by doing the following:

  1. cd into the directory that contains the xcframework you've downloaded
  2. touch Package.swift
  3. swift package compute-checksum name_of_the_zip_file_containing_your_xcframework.zip
Jessie answered 16/2, 2023 at 17:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.