-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Cleanup Build Script, Support XCframeworks #69
Conversation
ack, forgot to mark this as draft. Still need to work on Cocoapods/Carthage support |
06b6492
to
0925fc8
Compare
@Sjors managed to get Swift Package Manager working by following these steps and uploading a zipped version of the xcframework as a Github release with the following updates to Package.swift. You can try by installing https://github.com/jurvis/libwally-swift as a dependency on any project. |
Still stumped by Cocoapods, opened an issue here CocoaPods/CocoaPods#11309. We will probably use this build method for Carthage. |
I'll try to get Swift package manager to work for nthKey. I'm tempted to just drop CocoaPods and Carthage if they can't be fixed, but let's try.
Sad, but possible of course. Using binary distribution doesn't seem like a good idea, unless they support deterministic builds. Can't Swift packages be distributed as source code? Update I think it does: https://developer.apple.com/documentation/swift_packages/identifying_binary_dependencies |
We can look into distributing Swift packages as source, but that will probably involve finding a way to configure the Xcode project to run what we define |
But that only checks the binary of the checksum, and doesn't prove that binary is derived from the source, right?
That's fine, but in that case we have to make sure CocoaPods still works after this PR, because I'm not going to consume binary packages in my own project :-) |
I want to say it does, mostly because the full
When running within the
I can ask around and see if I can get confirmation on this 😄 |
The checksum of a zip file only tells you what is in the zip file. Even if the zip file contains both code and a binary, the checksum doesn't prove that the binary is actually generated from the code. |
@Sjors ah, gotcha. I see your concern now. That makes sense. I'll keep tabs on the Cocoapods issue and update this PR to keep it working 😄 |
hey @Sjors I don't know how long we'll have to wait until we get back a response on our GitHub issue, I figured it may just be quicker if I figured out how to use Xcode to run an external build config so we won't need to manually call in essence, Github projects will use the external build config target to pass a set of envvars, build the libraries it needs, and produce the framework necessary. I'm still working on it while we wait in this forked repo, but it's already opened up an opportunity for us to get GitHub CI in. (see: https://github.com/jurvis/libwally-swift/actions/runs/2200395095) |
8d84209
to
c6887eb
Compare
@Sjors fixed Cocoapods. I also updated the PR to include a more detailed implementation description alongside some new demo screenshots. I also attached two sample projects, with Cocoapods and SwiftPM, that you can clone to try. |
3392047
to
2dba1ac
Compare
@Sjors I think it should work for real now. turns out the issue was with Cocoapods asking for support for multiple architectures ( I needed to modify the script to essentially do almost the same thing as the old one by |
Thanks, this worked! Let's clean up the PR just a little bit more, so in the future it's easier to understand what changed. Can you drop 8884c21? Adding a Swift package can be done in a separate PR, and it hardcodes a binary in your fork. Can you squash a255ccb into the previous two commits? I also get the impression that 2dba1ac is changing some of the things that were introduced in earlier commits. However, I'm not sure if squashing all of it is a good idea, since this PR is a rather big change. Ideally each commit leaves the project in a working state, though that may be too much to ask with such a big change in the build process. |
Adapt podspec to vendored xcframework Use new build-libwally-swift to prebuild cocoapod Create LibWallyCore scheme For testing external builds Cleanup build script Remove development team from LibWallyCore target Fix x86_64 builds Update docs
2dba1ac
to
94fa0ad
Compare
Sure thing! Reopened at #73
Done
yeah, I deliberately left this one separate because it changes some of the static lib import behaviours in Xcode. |
94fa0ad
to
8b60f26
Compare
Why does the last commit message say "Delete Package.swift from pbxproj"? |
@Sjors oh, it was my Git client that added it there. I was cleaning up the SPM commit and realized Xcode didn't remove the file import. I'll nix the commit message. all the trial-and-error has gotten me confused - my bad 😅 |
8b60f26
to
5f52df6
Compare
Thanks, I'll do one more quick test and then merge this thing... |
One more issue... if you build for the simulator, e.g. to run the test suite, and then for the device, it complains: Cleaning the build folder is not enough to make that go away. I had to do a Also, unrelated, and can wait for a followup, it might be a good idea to switch |
@Sjors yeah, unfortunately, the only way to get it to work is to cd into
I'll file a new issue for this, I will prefer to close this earlier because I'll be busy over the next couple of days and don't want to block. |
@Sjors I just thought about this a little more, I don't think we'll need to do anything too complicated. I just turned off "Build Active Architectures Only" so Xcode knows to build for all supported architectures. In the case of dev, I believe it will be fwiw, build still green on CI: https://github.com/jurvis/libwally-swift/actions/runs/2261318103 |
Remove build preaction
ed14176
to
cb2cdf4
Compare
@jurvis building both architectures is fine by me. I'll test again. |
@Sjors thanks for that! I was able to reproduce. I just tried adding my build artifact cleanup code snippet to the scheme's pre-build script instead. can you try again? let me know how you'll like the commits squashed, I don't have an opinion either way. |
It worked! |
Reopened of #61. Resolves #59.
Purpose
This PR primarily adds support for running apps that use Libwally-Swift in iOS simulator on M1 Macs. This is achieved by using
xcframeworks
, which will allow us down the road to support Mac Catalyst targets and publish it on Swift Package Manager.Implementation
We heavily lean towards more modern approaches to packaging frameworks in this new iteration. Specifically, instead of using
lipo
which will prevent us from same having the architecture on multiple platforms in a single universal framework, we will turn to xcframeworks. Xcframeworks contain many slices organized by platform, and is platform-aware. This allows us to target more than one platform for the same architecture (e.g. arm64 ios simulator and arm64 ios device)LibWallyCore
. The role of this target is to expose environment variables that Xcode passes to us viaxcodebuild
(either via the IDE or CLI) to any arbitrary build process. This allows us to not have to manage architecture-related logic within our shell script, and only build for the architectures relevant for our users.libwally-core
,build-libwally.sh
needed to be reworked so that it only does one thing: produce a C static library. It is the shell script that the aforementioned target calls when you hit "Build" or "Archive".build-libwally-swift.sh
. This script exists solely for Cocoapods to build xcframeworks for a developer's local dev environment.You can see the benefit of our new build system in action in
build-libwally-swift.sh
, where all we need to do is to call Xcode to build theLibWally
scheme. And since it listsLibWallyCore
as a dependent target, automatically builds the correct framework for the user.Demo
User Perspective
With SwiftPM:
With Cocoapods:
Developer's Perspective
Testing Notes
Follow-up
- Add Swift Package Manager support (?)