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

iOSのApp Storeへの申請を通るようにした #723

Merged
merged 26 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
47663e6
xcframeworkでdylibをframeworkに入れる
nekomimimi Dec 30, 2023
471d096
Merge branch 'main' into add_framewodks
nekomimimi Jan 4, 2024
94661ad
Headersのディレクトリーまで作る
nekomimimi Jan 4, 2024
3ac7672
onnxruntimeのdylbのファイル名からバージョン番号をなくした。
nekomimimi Jan 4, 2024
be6326a
space除去
nekomimimi Jan 6, 2024
c994f67
コメント修正
nekomimimi Jan 6, 2024
d9e693f
plistをBinary形式からXML形式へ変換
nekomimimi Jan 8, 2024
2cd3af7
ファイルのcopyとして使ってるlipoをcpに変更
nekomimimi Jan 24, 2024
e5cda74
github actionそのままで、bashにした。
nekomimimi Feb 5, 2024
72fad0d
文法的なミスを修正
nekomimimi Feb 5, 2024
1f542f9
重複ロジックを削除した。細部を見直した。
nekomimimi Feb 5, 2024
0bb8aca
誤字修正
nekomimimi Feb 5, 2024
7d89087
コピー前でもlibvoicevox_core.dylibに参照できるようにした。
nekomimimi Feb 5, 2024
0c62e3d
コメントの削除
nekomimimi Feb 5, 2024
e181490
アーキテクチャをまとめてループ化
nekomimimi Feb 5, 2024
ec308f9
Merge branch 'VOICEVOX:main' into add_framewodks
nekomimimi Feb 5, 2024
4c8a7e1
ファイル名の変更。ios_xcframework.bash -> make_ios_xcframework.bash
nekomimimi Feb 9, 2024
d95e7da
ヘッダーファイルを取得する際に固定になってたアーキテクチャを指定するようにした。
nekomimimi Feb 9, 2024
929925a
artifactのディレクトリをbashに注入するようにした。
nekomimimi Feb 9, 2024
18206a0
環境変数未定義のエラーチェックの追加。echoの文言修正
nekomimimi Feb 9, 2024
bb6e24b
環境変数を " で囲う
nekomimimi Feb 9, 2024
92b3bc8
Update .github/workflows/build_and_deploy.yml
Hiroshiba Feb 25, 2024
c93d896
OUTPUT_ASSET_PATHにしたりなどの微調整
Hiroshiba Feb 25, 2024
3f037f1
指摘の点でrun: |の後、コマンドが1行の時には|を削除した。
nekomimimi Feb 26, 2024
d6da3be
同様にチェックして、run: |の後、コマンドが1行の時には|を削除した。
nekomimimi Feb 26, 2024
a1ffeab
OUTPUT_ASSET_PATHと同じ値が書かれているのを解消した。
nekomimimi Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 16 additions & 28 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ jobs:
- name: Raplace resource
if: inputs.is_production
shell: bash
run: |
run:
mv -f download/resource/core/README.md ./README.md
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
Expand Down Expand Up @@ -315,7 +315,7 @@ jobs:
cp -v target/${{ matrix.target }}/release/libvoicevox_core_java_api.so java_artifact/ || true
- name: Code signing (Windows)
if: startsWith(matrix.os, 'windows') && inputs.code_signing
run: |
run:
bash build_util/codesign.bash "artifact/${{ env.ASSET_NAME }}/voicevox_core.dll"
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
Expand Down Expand Up @@ -361,44 +361,32 @@ jobs:
needs: [config, build_and_deploy]
runs-on: macos-12
env:
IOS_X86_64_PATH: artifact/voicevox_core-x86_64-apple-ios
IOS_AARCH64_SIM_PATH: artifact/voicevox_core-aarch64-apple-ios-sim
IOS_AARCH64_PATH: artifact/voicevox_core-aarch64-apple-ios
ASSET_NAME: voicevox_core-ios-xcframework-cpu-${{ needs.config.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v2
with:
name: voicevox_core-x86_64-apple-ios
path: artifact/voicevox_core-x86_64-apple-ios
path: ${{ env.IOS_X86_64_PATH }}
- uses: actions/download-artifact@v2
with:
name: voicevox_core-aarch64-apple-ios-sim
path: artifact/voicevox_core-aarch64-apple-ios-sim
path: ${{ env.IOS_AARCH64_SIM_PATH }}
- uses: actions/download-artifact@v2
with:
name: voicevox_core-aarch64-apple-ios
path: artifact/voicevox_core-aarch64-apple-ios
- name: Create fat binary
run: |
mkdir -p "artifact/voicevox_core-sim"
lipo -create "artifact/voicevox_core-x86_64-apple-ios/libvoicevox_core.dylib" "artifact/voicevox_core-aarch64-apple-ios-sim/libvoicevox_core.dylib" -output "artifact/voicevox_core-sim/libvoicevox_core.dylib"
- name: Create XCFramework
run: |
mkdir -p "artifact/${{ env.ASSET_NAME }}"
# 必要なファイルだけコピー
mkdir -p "Headers-sim"
cp -v artifact/voicevox_core-x86_64-apple-ios/voicevox_core.h "Headers-sim"
cp -v crates/voicevox_core_c_api/xcframework/Headers/module.modulemap "Headers-sim"
mkdir -p "Headers-aarch64"
cp -v artifact/voicevox_core-aarch64-apple-ios/voicevox_core.h "Headers-aarch64"
cp -v crates/voicevox_core_c_api/xcframework/Headers/module.modulemap "Headers-aarch64"
xcodebuild -create-xcframework \
-library "artifact/voicevox_core-sim/libvoicevox_core.dylib" \
-headers "Headers-sim" \
-library "artifact/voicevox_core-aarch64-apple-ios/libvoicevox_core.dylib" \
-headers "Headers-aarch64" \
-output "artifact/${{ env.ASSET_NAME }}/voicevox_core.xcframework"
path: ${{ env.IOS_AARCH64_PATH }}
- name: Create xcframework
run:
build_util/make_ios_xcframework.bash
env:
OUTPUT_ASSET_PATH: artifact/voicevox_core-ios-xcframework-cpu
PickledChair marked this conversation as resolved.
Show resolved Hide resolved
- name: Archive artifact
run: |
cd artifact/${{ env.ASSET_NAME }}
cd artifact/voicevox_core-ios-xcframework-cpu
7z a "../../${{ env.ASSET_NAME }}.zip" "voicevox_core.xcframework"
- name: Upload to Release
if: fromJson(needs.config.outputs.deploy)
Expand Down Expand Up @@ -427,7 +415,7 @@ jobs:
- name: Raplace resource
if: inputs.is_production
shell: bash
run: |
run:
rm -r ./model; mv download/fat_resource/core/model ./model
- name: Create artifact
run: |
Expand Down Expand Up @@ -469,7 +457,7 @@ jobs:
- name: Install cargo-edit
run: cargo binstall cargo-edit@^0.11 --no-confirm
- name: set cargo version
run: |
run:
cargo set-version "$VERSION" -p voicevox_core_java_api

- name: "Download artifact (android-arm64-cpu)"
Expand Down
79 changes: 79 additions & 0 deletions build_util/make_ios_xcframework.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
set -eu

if [ ! -v IOS_X86_64_PATH ]; then # X86_64用のモジュールのディレクトリ(simulator)
echo "IOS_X86_64_PATHが未定義です"
exit 1
fi
if [ ! -v IOS_AARCH64_SIM_PATH ]; then # AARCH64_SIM用のモジュールのディレクトリ(simulator)
echo "IOS_AARCH64_SIM_PATHが未定義です"
exit 1
fi
if [ ! -v IOS_AARCH64_PATH ]; then # AARCH64用のモジュールのディレクトリ(実機)
echo "IOS_AARCH64_PATHが未定義です"
exit 1
fi
if [ ! -v OUTPUT_ASSET_PATH ]; then # 出力するASSETのディレクトリ
echo "OUTPUT_ASSET_PATHが未定義です"
exit 1
fi

echo "* Get original onnxruntime file name from rpath"
output=$(otool -L "${IOS_AARCH64_PATH}/libvoicevox_core.dylib")
matched_line=$(echo "$output" | grep "@rpath" | grep "libonnxruntime")
if [[ $matched_line ]]; then
if [[ $matched_line =~ (@rpath/([^ ]+\.dylib)) ]]; then
dylib_string=${BASH_REMATCH[2]}
else
echo "Expected pattern not found in the matched line"
echo "$output"
exit 1
fi
else
echo "No line containing '@rpath' and 'libonnxruntime' found"
echo "$output"
exit 1
fi
echo "Original onnx dylib file name: $dylib_string"

echo "* Copy Framework template"
arches=("aarch64" "sim")
artifacts=("${IOS_AARCH64_PATH}" "${IOS_AARCH64_SIM_PATH}")
for i in "${!arches[@]}"; do
arch="${arches[$i]}"
artifact="${artifacts[$i]}"
echo "* Copy Framework-${arch} template"
mkdir -p "Framework-${arch}/voicevox_core.framework/Headers"
cp -vr "crates/voicevox_core_c_api/xcframework/Frameworks/${arch}/" "Framework-${arch}/"
cp -v "${artifact}/voicevox_core.h" \
"Framework-${arch}/voicevox_core.framework/Headers/voicevox_core.h"
done

echo "* Create dylib"
# aarch64はdylibをコピー
cp -v "${IOS_AARCH64_PATH}/libvoicevox_core.dylib" \
"Framework-aarch64/voicevox_core.framework/voicevox_core"

# simはx86_64とarrch64を合わせてdylib作成
lipo -create "${IOS_X86_64_PATH}/libvoicevox_core.dylib" \
"${IOS_AARCH64_SIM_PATH}/libvoicevox_core.dylib" \
-output "Framework-sim/voicevox_core.framework/voicevox_core"

for arch in "${arches[@]}"; do
echo "* Change ${arch} @rpath"
# 自身への@rpathを変更
install_name_tool -id "@rpath/voicevox_core.framework/voicevox_core" \
"Framework-${arch}/voicevox_core.framework/voicevox_core"

# 依存ライブラリonnxruntimeへの@rpathを変更
install_name_tool -change "@rpath/$dylib_string" \
"@rpath/onnxruntime.framework/onnxruntime" \
"Framework-${arch}/voicevox_core.framework/voicevox_core"
done

echo "* Create XCFramework"
mkdir -p "${OUTPUT_ASSET_PATH}"
xcodebuild -create-xcframework \
-framework "Framework-sim/voicevox_core.framework" \
-framework "Framework-aarch64/voicevox_core.framework" \
-output "${OUTPUT_ASSET_PATH}/voicevox_core.xcframework"
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>23B81</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>voicevox_core</string>
<key>CFBundleIdentifier</key>
<string>jp.hiroshiba.voicevox.voicevox-core</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>voicevox_core</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>21C52</string>
<key>DTPlatformName</key>
<string>iphoneos</string>
<key>DTPlatformVersion</key>
<string>17.2</string>
<key>DTSDKBuild</key>
<string>21C52</string>
<key>DTSDKName</key>
<string>iphoneos17.2</string>
<key>DTXcode</key>
<string>1510</string>
<key>DTXcodeBuild</key>
<string>15C65</string>
<key>MinimumOSVersion</key>
<string>16.2</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module voicevox_core {
umbrella header "voicevox_core.h"
export *

module * { export * }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>23B81</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>voicevox_core</string>
<key>CFBundleIdentifier</key>
<string>jp.hiroshiba.voicevox.voicevox-core</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>voicevox_core</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneSimulator</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>21C52</string>
<key>DTPlatformName</key>
<string>iphonesimulator</string>
<key>DTPlatformVersion</key>
<string>17.2</string>
<key>DTSDKBuild</key>
<string>21C52</string>
<key>DTSDKName</key>
<string>iphonesimulator17.2</string>
<key>DTXcode</key>
<string>1510</string>
<key>DTXcodeBuild</key>
<string>15C65</string>
<key>MinimumOSVersion</key>
<string>16.2</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module voicevox_core {
umbrella header "voicevox_core.h"
export *

module * { export * }
}
5 changes: 0 additions & 5 deletions crates/voicevox_core_c_api/xcframework/Headers/README.md

This file was deleted.

This file was deleted.

6 changes: 6 additions & 0 deletions crates/voicevox_core_c_api/xcframework/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# xcframeworkフォルダの内容について
## Frameworks

iOS向けの配布ライブラリXCFramework内のFrameworkを作るための雛形です。
雛形は端末用とシミュレータ用の2種類です。

Loading