swift-sodium
swift-sodium copied to clipboard
Clibsodium cannot be Product > Archived
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
SodiumandClibsodiumas 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 chooseAd HocthenNext
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?
I've added the test project here: https://github.com/JakobOffersen/Sodium-Product-Archive-Issue
The issue is also present on XCode 12.2
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?
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)?
I've made a small screencast of the issue.
https://user-images.githubusercontent.com/35025032/102892590-65c6ab00-4460-11eb-8f27-48fcb8700474.mov
@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.
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:

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

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.
I encountered the same problem when settings up the following minimal example:
- Create a repository containing a tiny swift library that uses swift-sodium as a dependency. Like this one: https://github.com/TICESoftware/ExampleCryptoLibrary
- 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.
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.
I agree. This is also what @jnross suggested in #233 and implemented in #235.
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.
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
@JakobOffersen Have you tried 12.5? Archive worked fine for me.
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.