Skip to content

Commit 93787a9

Browse files
committed
chore: Add ios/macos framework build.
1 parent 9f723f8 commit 93787a9

File tree

8 files changed

+201
-72
lines changed

8 files changed

+201
-72
lines changed

.github/workflows/deploy.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,73 @@ jobs:
217217
token: ${{ secrets.GITHUB_TOKEN }}
218218
artifacts: "toxcore-nightly-${{ matrix.target }}.tar.gz,toxcore-nightly-${{ matrix.target }}.tar.gz.sha256"
219219

220+
build-xcode-framework:
221+
name: Xcode Framework
222+
needs: [build-ios, build-macos]
223+
runs-on: 'macos-14'
224+
steps:
225+
- uses: actions/checkout@v4
226+
with:
227+
submodules: recursive
228+
- name: Download artifact for ios
229+
uses: actions/download-artifact@v4
230+
with:
231+
pattern: toxcore-ios-*
232+
- name: Download artifact for iphonesimulator
233+
uses: actions/download-artifact@v4
234+
with:
235+
pattern: toxcore-iphonesimulator-*
236+
- name: Download artifact for macos
237+
uses: actions/download-artifact@v4
238+
with:
239+
pattern: toxcore-macos-*
240+
- name: Run build
241+
run: |
242+
mv toxcore-* other/deploy/apple/
243+
other/deploy/apple/make-framework.sh
244+
tar -C other/deploy/apple -zcf toxcore-xcframework.tar.gz Tox.xcframework
245+
- name: Upload artifacts
246+
uses: actions/upload-artifact@v4
247+
with:
248+
name: toxcore-xcframework
249+
path: toxcore-xcframework.tar.gz
250+
- name: Get tag name for release file name
251+
if: contains(github.ref, 'refs/tags/v')
252+
id: get_version
253+
run: |
254+
VERSION="$(echo "$GITHUB_REF" | cut -d / -f 3)"
255+
echo "release_tarball=toxcore-$VERSION-xcframework.tar.gz" >>$GITHUB_OUTPUT
256+
- name: Create tarball for release upload
257+
if: contains(github.ref, 'refs/tags/v')
258+
run: |
259+
cp toxcore-xcframework.tar.gz "${{ steps.get_version.outputs.release_tarball }}"
260+
sha256sum "${{ steps.get_version.outputs.release_tarball }}" > "${{ steps.get_version.outputs.release_tarball }}.sha256"
261+
- name: Upload to versioned release
262+
if: contains(github.ref, 'refs/tags/v')
263+
uses: ncipollo/release-action@v1
264+
with:
265+
allowUpdates: true
266+
draft: true
267+
token: ${{ secrets.GITHUB_TOKEN }}
268+
artifacts: "${{ steps.get_version.outputs.release_tarball }},${{ steps.get_version.outputs.release_tarball }}.sha256"
269+
- name: Create tarball for nightly upload
270+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
271+
run: |
272+
cp toxcore-xcframework.tar.gz toxcore-nightly-xcframework.tar.gz
273+
sha256sum toxcore-nightly-xcframework.tar.gz > toxcore-nightly-xcframework.tar.gz.sha256
274+
- name: Upload to nightly release
275+
uses: ncipollo/release-action@v1
276+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
277+
with:
278+
allowUpdates: true
279+
tag: nightly
280+
omitBodyDuringUpdate: true
281+
omitNameDuringUpdate: true
282+
prerelease: true
283+
replacesArtifacts: true
284+
token: ${{ secrets.GITHUB_TOKEN }}
285+
artifacts: "toxcore-nightly-xcframework.tar.gz,toxcore-nightly-xcframework.tar.gz.sha256"
286+
220287
build-android:
221288
name: Android
222289
needs: [update-nightly-tag]

other/deploy/apple/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/Tox.xcframework
2+
/toxcore-ios*
3+
/toxcore-iphonesimulator*
4+
/toxcore-macos*
5+
/smoke-test.c

other/deploy/apple/Info.plist

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>English</string>
7+
<key>CFBundleExecutable</key>
8+
<string>Tox</string>
9+
<key>CFBundleName</key>
10+
<string>Tox</string>
11+
<key>CFBundleIconFile</key>
12+
<string></string>
13+
<key>CFBundleIdentifier</key>
14+
<string>chat.tox.toxcore</string>
15+
<key>CFBundleInfoDictionaryVersion</key>
16+
<string>6.0</string>
17+
<key>CFBundlePackageType</key>
18+
<string>FMWK</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
21+
<key>CFBundleVersion</key>
22+
<string>0.2.20</string>
23+
<key>CFBundleShortVersionString</key>
24+
<string>0.2.20</string>
25+
<key>CFBundleGetInfoString</key>
26+
<string>Tox Framework</string>
27+
</dict>
28+
</plist>
File renamed without changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Download the nightly builds of Tox for iOS, iPhone simulator, and macOS.
3+
4+
set -eux -o pipefail
5+
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
8+
cd "$SCRIPT_DIR"
9+
10+
for arch in arm64 armv7 armv7s; do
11+
if [ ! -d "toxcore-ios-$arch" ]; then
12+
tar -zxf \
13+
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-ios-$arch.tar.gz")
14+
fi
15+
done
16+
17+
for arch in arm64 x86_64; do
18+
if [ ! -d "toxcore-iphonesimulator-$arch" ]; then
19+
tar -zxf \
20+
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-iphonesimulator-$arch.tar.gz")
21+
fi
22+
done
23+
24+
for arch in arm64 x86_64; do
25+
if [ ! -d "toxcore-macos-$arch" ]; then
26+
tar -zxf \
27+
<(curl -L "https://github.com/TokTok/c-toxcore/releases/download/nightly/toxcore-nightly-macos-$arch.tar.gz")
28+
fi
29+
done
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
# Make a Tox.xcframework for iOS, iPhone simulator, and macOS from the nightly builds.
3+
#
4+
# Run download-nightly.sh before running this script if you run it locally.
5+
6+
set -eux -o pipefail
7+
8+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
10+
cd "$SCRIPT_DIR"
11+
12+
# Make a Tox.framework for iOS.
13+
rm -rf toxcore-ios/Tox.framework
14+
mkdir -p toxcore-ios/Tox.framework
15+
cp Info.plist toxcore-ios/Tox.framework
16+
cp -r toxcore-ios-arm64/include/tox toxcore-ios/Tox.framework/Headers
17+
lipo -create -output toxcore-ios/Tox.framework/Tox \
18+
toxcore-ios-arm64/lib/libtoxcore.dylib \
19+
toxcore-ios-armv7/lib/libtoxcore.dylib \
20+
toxcore-ios-armv7s/lib/libtoxcore.dylib
21+
install_name_tool -id @rpath/Tox.framework/Tox toxcore-ios/Tox.framework/Tox
22+
23+
# Make a Tox.framework for iPhone simulator.
24+
rm -rf toxcore-iphonesimulator/Tox.framework
25+
mkdir -p toxcore-iphonesimulator/Tox.framework
26+
cp Info.plist toxcore-iphonesimulator/Tox.framework
27+
cp -r toxcore-iphonesimulator-arm64/include/tox toxcore-iphonesimulator/Tox.framework/Headers
28+
lipo -create -output toxcore-iphonesimulator/Tox.framework/Tox \
29+
toxcore-iphonesimulator-arm64/lib/libtoxcore.dylib \
30+
toxcore-iphonesimulator-x86_64/lib/libtoxcore.dylib
31+
install_name_tool -id @rpath/Tox.framework/Tox toxcore-iphonesimulator/Tox.framework/Tox
32+
33+
# Make a Tox.framework for macOS.
34+
rm -rf toxcore-macos/Tox.framework
35+
mkdir -p toxcore-macos/Tox.framework
36+
cp Info.plist toxcore-macos/Tox.framework
37+
cp -r toxcore-macos-arm64/include/tox toxcore-macos/Tox.framework/Headers
38+
lipo -create -output toxcore-macos/Tox.framework/Tox \
39+
toxcore-macos-arm64/lib/libtoxcore.dylib \
40+
toxcore-macos-x86_64/lib/libtoxcore.dylib
41+
install_name_tool -id @rpath/Tox.framework/Tox toxcore-macos/Tox.framework/Tox
42+
43+
# Make a Tox.xcframework for iOS, iPhone simulator, and macOS.
44+
rm -rf Tox.xcframework
45+
xcodebuild -create-xcframework -output Tox.xcframework \
46+
-framework toxcore-ios/Tox.framework \
47+
-framework toxcore-iphonesimulator/Tox.framework \
48+
-framework toxcore-macos/Tox.framework
49+
50+
# Test the Tox.xcframework.
51+
cat >smoke-test.c <<'EOF'
52+
#include <stdio.h>
53+
54+
#pragma GCC diagnostic push
55+
#pragma GCC diagnostic ignored "-Wdocumentation-deprecated-sync"
56+
#include <tox/tox.h>
57+
#pragma GCC diagnostic pop
58+
59+
int main(void) {
60+
Tox *tox = tox_new(NULL, NULL);
61+
if (tox == NULL) {
62+
fprintf(stderr, "tox_new failed\n");
63+
return 1;
64+
}
65+
tox_kill(tox);
66+
return 0;
67+
}
68+
EOF
69+
pod lib lint toxcore.podspec
70+
71+
rm smoke-test.c

other/deploy/ios/toxcore.podspec renamed to other/deploy/apple/toxcore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ Pod::Spec.new do |s|
1919
s.vendored_frameworks = 'Tox.xcframework'
2020
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}"' }
2121
s.test_spec 'Tests' do |test_spec|
22-
test_spec.source_files = 'smoketest.c'
22+
test_spec.source_files = 'smoke-test.c'
2323
end
2424
end

other/deploy/ios/make_framework

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)