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 16 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
21 changes: 2 additions & 19 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,26 +376,9 @@ jobs:
with:
name: voicevox_core-aarch64-apple-ios
path: artifact/voicevox_core-aarch64-apple-ios
- name: Create fat binary
- name: Create xcframework
run: |
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
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"
build_util/ios_xcframework.bash
- name: Archive artifact
run: |
cd artifact/${{ env.ASSET_NAME }}
Expand Down
59 changes: 59 additions & 0 deletions build_util/ios_xcframework.bash
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -eu

echo "* Get original onnxruntime file name from rpath"
output=$(otool -L "artifact/voicevox_core-aarch64-apple-ios/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"

arches=("aarch64" "sim")
for arch in "${arches[@]}"; do
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-aarch64-apple-ios/voicevox_core.h" \
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
"Framework-${arch}/voicevox_core.framework/Headers/voicevox_core.h"
done

echo "* Create dylib"
# aarch64はdylibをコピー
cp -v "artifact/voicevox_core-aarch64-apple-ios/libvoicevox_core.dylib" \
Copy link
Member

@Hiroshiba Hiroshiba Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

入出力のディレクトリ、
artifact/voicevox_core-x86_64-apple-ios
artifact/voicevox_core-aarch64-apple-ios-sim
artifact/voicevox_core-aarch64-apple-ios
artifact/${ASSET_NAME}
は外から引数、あるいは環境変数として与えられるようにしておくと便利かもと思いました!

というのも、たとえばbuild.yamlの方でartifactのディレクトリ名を変えたとき、こっちのbashファイル内のディレクトリ名を変えるのを忘れそうなんですよね。
引数や環境変数で与えるようにすればどこを変えればよいかわかりやすいかなと!

Copy link
Contributor Author

@nekomimimi nekomimimi Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

入出力ディレクトリをyaml側からbash側に入れるようにしました。
少し気持ち悪い点がありまして、
yaml側の環境定義で
ASSET_NAME: voicevox_core-ios-xcframework-cpu-${{ needs.config.outputs.version }}
ASSET_PATH: artifact/voicevox_core-ios-xcframework-cpu-${{ needs.config.outputs.version }}
と記述に重複があります。
(envの中で前に定義したのが使えないようで、次のstepsで
echo "ASSET_PATH=artifact/${ASSET_NAME}" >> $GITHUB_ENV
とできるようなのですが、わかりにくいので現状はこれにしました。)

"Framework-aarch64/voicevox_core.framework/voicevox_core"

# simはx86_64とarrch64を合わせてdylib作成
lipo -create "artifact/voicevox_core-x86_64-apple-ios/libvoicevox_core.dylib" \
"artifact/voicevox_core-aarch64-apple-ios-sim/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 "artifact/${ASSET_NAME}"
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
xcodebuild -create-xcframework \
-framework "Framework-sim/voicevox_core.framework" \
-framework "Framework-aarch64/voicevox_core.framework" \
-output "artifact/${ASSET_NAME}/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