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

Clibsodium cannot be Product > Archived #226

Open
JakobOffersen opened this issue Dec 4, 2020 · 14 comments
Open

Clibsodium cannot be Product > Archived #226

JakobOffersen opened this issue Dec 4, 2020 · 14 comments

Comments

@JakobOffersen
Copy link

Hi

Description:
When making a Hello World-project and importing Sodium and CLibsodium according to the README, the project builds as expected. However, when I do Product > Archive, I get a IPA processing failed error. The attached log includes the following description, which may be relevant:

"Couldn't find platform family for "libsodium.a".

Thus I cannot distribute an app which uses Sodium

Details

  • I run Xcode Version 12.1 (12A7403)

Reproduction Steps

  • Create a new iOS project in Xcode.
  • Add Sodium and Clibsodium as dependencies according to the docs. Added below for convenience:

"To add Swift-Sodium as dependency to your Xcode project, select File > Swift Packages > Add Package Dependency, enter its repository URL: https://github.com/jedisct1/swift-sodium.git and import Sodium as well as Clibsodium."

  • Run Product > Archive
  • Click Distribute App, then choose Ad Hoc then Next

After these steps I end up with an error prompt saying IPA processing failed.
The corresponding log is attached below.
IDEDistribution.standard.log

Anyone who ran into the same issue and knows how to resolve it?
And is this an XCode issue or an Clibsodium issue?

@JakobOffersen
Copy link
Author

I've added the test project here: https://github.com/JakobOffersen/Sodium-Product-Archive-Issue

The issue is also present on XCode 12.2

@jedisct1
Copy link
Owner

jedisct1 commented Dec 4, 2020

Unfortunately I wasn't able to reproduce this (tried with the default iOS template, deployed for generic iOS platforms).

Configuration issue: platform iPhoneSimulator.platform doesn't have any non-simulator SDKs; ignoring it

Maybe you are trying to archive for simulators instead of actual devices?

@JakobOffersen
Copy link
Author

To be specific, I'm able to make an archive-build, but the problem appears when I try to distribute it - even for the simplest dummy-project. And I make sure to add both Sodium and CLibsodium to the iOS target.

Did also try out the fork from #233 but with no luck.

Not really sure, what goes wrong though...

Are you able to distribute your archived build (ad-hoc/to appstore connect etc)?

@JakobOffersen
Copy link
Author

I've made a small screencast of the issue.

Sodium.Archive.Issue.mov

@ph4r05
Copy link

ph4r05 commented Jan 6, 2021

@JakobOffersen Just btw, it may help: I am using Sodium 0.9.1, with XCode 12.3 and I was able to archive the product. Cocoapod has to be 1.10+ (pod --version), I am using use_frameworks! in my Podfile.

@mologie
Copy link

mologie commented Jan 21, 2021

The issue happens because some component (SPM?) copies libsodium.a into the target's Frameworks directory. That is complete nonsense, because libsodium.a is linked statically. The archive tool's logs reveal that this is indeed the issue:

2021-01-21 15:40:07 +0000 [MT] Running /Applications/Xcode.app/Contents/Developer/usr/bin/symbols '-noTextInSOD' '-noDaemon' '-arch' 'all' '-symbolsPackageDir' '/var/folders/6w/t82mgtds0sg26f8dw45q22pr0000gn/T/XcodeDistPipeline.~~~8MSZmJ/Symbols' '/var/folders/6w/t82mgtds0sg26f8dw45q22pr0000gn/T/XcodeDistPipeline.~~~8MSZmJ/libsodium.a'
2021-01-21 15:40:07 +0000  error: No UUID for /var/folders/6w/t82mgtds0sg26f8dw45q22pr0000gn/T/XcodeDistPipeline.~~~8MSZmJ/libsodium.a(libsodium_la-aead_chacha20poly1305.o)
2021-01-21 15:40:07 +0000  error: No UUID for /var/folders/6w/t82mgtds0sg26f8dw45q22pr0000gn/T/XcodeDistPipeline.~~~8MSZmJ/libsodium.a(libsodium_la-aead_xchacha20poly1305.o)
error: No UUID for /var/folders/6w/t82mgtds0sg26f8dw45q22pr0000gn/T/XcodeDistPipeline.~~~8MSZmJ/libsodium.a(libsodium_la-crypto_auth.o)
error: No UUID for /var/folders/6w/t82mgtds0sg26f8dw45q22pr0000gn/T/XcodeDistPipeline.~~~8MSZmJ/libsodium.a(libsodium_la-auth_hmacsha256.o)
error: No UUID for /var/folders/6w/t82mgtds0sg26f8dw45q22pr0000gn/T/XcodeDistPipeline.~~~8MSZmJ/libsodium.a(libsodium_la-auth_hmacsha512.o)
error: No UUID for /var/folders/6w/t82mgtds0sg26f8dw45q22pr0000gn/T/XcodeDistPipeline.~~~8MSZmJ/libsodium.a(libsodium_la-auth_hmacsha512256.o)
(...repeats for every object...)

You can review your own logs by building an archive via xcodebuild -exportArchive and opening the log folder that it prints.

I have not yet found a workaround. It does not seem to be possible to solve this with a build phase, because libsodium.a is copied after the last build phase runs:

image

@bas-d
Copy link

bas-d commented Jan 22, 2021

It seems to work by adding a script as 'Post-action' for Archive in the build scheme:

image

APPLICATIONS_PATH="$ARCHIVE_PRODUCTS_PATH/Applications"
rm "$APPLICATIONS_PATH/$FRAMEWORKS_FOLDER_PATH/libsodium.a"
rm "$APPLICATIONS_PATH/$PRODUCT_NAME.app/PlugIns/libsodium.a"
find "$APPLICATIONS_PATH/$PRODUCT_NAME.app/PlugIns" -name '*.appex' -type d | while read -r EXTENSION
do
rm -r "$EXTENSION/Frameworks"
done

I also provide libsodium for my app extensions, if you don't, you may need to adjust / remove the last 4 lines.

@FabioTacke
Copy link

I encountered the same problem when settings up the following minimal example:

  1. Create a repository containing a tiny swift library that uses swift-sodium as a dependency. Like this one: https://github.com/TICESoftware/ExampleCryptoLibrary
  2. Create a new Xcode project for an iOS app and add the just created swift library as a dependency using SPM.

When trying to archive the project compiling Aead.swift fails on importing Clibsodium: "No such module 'Clibsodium'"

I tried the workaround @bas-d suggested but that didn't solve the issue.

@cbrown-pp3
Copy link

I had the same issue. For me the solution was to separate Clibsodium into its own package and set it as a dependency in the Sodium Package.swift file.

This also allows the Sodium package to be reduced to only the .swift files in the Tests, Sodium and Sodium/Generators directories simplifying the entire package.

@FabioTacke
Copy link

I agree. This is also what @jnross suggested in #233 and implemented in #235.

@bas-d
Copy link

bas-d commented Mar 15, 2021

Yes, for me it also only works with the separate CLibsodium package from #235. This seems to fix the No such module 'Clibsodium' error.

The post-action script fixes the SPM bug that copies the libsodium.a into the framework directory, which causes errors when validating or distributing. However, this comment indicates that this issue is fixed in Xcode 12.5, but I haven't verified that.

@FabioTacke
Copy link

I guess we need to rely on the workaround with two separate repositories until this bug gets fixed: https://bugs.swift.org/browse/SR-13803

@the-pear
Copy link

@JakobOffersen
Have you tried 12.5? Archive worked fine for me.

@markshiz
Copy link

markshiz commented Aug 18, 2021

Xcode 12.5, 12.5.1, and the workaround suggested above all still break the first build for me. 😭 I haven't tried archiving, however. That might be improved one place or another.

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

9 participants