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

ローカル開発用のbuild_restart.shCONTRIBUTING.mdを設置 #143

Merged
merged 5 commits into from
Apr 22, 2024

Conversation

y-yu
Copy link
Contributor

@y-yu y-yu commented Apr 6, 2024

  • 下記の記事を参考にローカルでの開発版をビルドしてインストールするスクリプトを設置した
  • スクリプトの使い方を説明したCONTRIBUTING.mdを設置した

@mtgto
Copy link
Owner

mtgto commented Apr 7, 2024

ありがとうございます。作者の手元ではこんなスクリプトをもってました。みんな考えることは同じですね。
(xcodebuild archiveではなく、Xcodeからビルド実行したものをさしかえられるようにデバッグビルドからコピーしている違いがありますね)

#!/bin/sh -eux
# デバッグビルドと置き替えてmacSKKを再起動するスクリプト
# 実行にはtrashコマンド, jqコマンドが必要です。
# https://github.com/ali-rantakari/trash
# https://jqlang.github.io/jq/

debug_path=$(xcodebuild -showBuildSettings -json -project macSKK.xcodeproj -scheme macSKK -configuration Debug 2>/dev/null | jq --raw-output '.[0].buildSettings | [.CONFIGURATION_BUILD_DIR, .WRAPPER_NAME] | join("/")')

# インストールされているmacSKKを移動
path="$HOME/Library/Input Methods/macSKK.app"
if [ -d "$path" ]; then
  mv "$path" /tmp
fi
# DebugビルドをInput Methodsに移動

if [ -d "$debug_path" ]; then
  cp -r "$debug_path" "$HOME/Library/Input Methods/"
fi

# 起動中のmacSKKを全部終了する
osascript -e 'tell application id "net.mtgto.inputmethod.macSKK" to quit' || true

if [ -d "/tmp/macSKK.app" ]; then
  trash "/tmp/macSKK.app"
fi

open "$path"

@mtgto
Copy link
Owner

mtgto commented Apr 7, 2024

そういえばmacOS 14+でApp Sandboxのセキュリティが強化されて、リリースページで配布されているバイナリに使っているCertificateと異なるチーム Provisioning Profileを使うと ~/Library/Containers/net.mtgto.inputmethod.macSKK 内のファイルを開こうとするのに警告がされるんじゃないかなと思っています。
https://zenn.dev/mtgto/articles/sonoma-app-sandbox-changes#%E3%81%9D%E3%81%AE2%3A-%E3%83%87%E3%83%90%E3%83%83%E3%82%B0%E3%83%93%E3%83%AB%E3%83%89%E3%82%92%E8%B5%B7%E5%8B%95%E3%81%99%E3%82%8B%E3%81%A8%E3%80%8C%22(%E3%82%A2%E3%83%97%E3%83%AA%E5%90%8D)%22%E3%81%8C%E3%81%BB%E3%81%8B%E3%81%AE%E3%82%A2%E3%83%97%E3%83%AA%E3%81%8B%E3%82%89%E3%81%AE%E3%83%87%E3%83%BC%E3%82%BF%E3%81%B8%E3%81%AE%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E3%82%92%E6%B1%82%E3%82%81%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%E3%80%8D%E3%81%A8%E3%81%84%E3%81%86%E3%83%80%E3%82%A4%E3%82%A2%E3%83%AD%E3%82%B0%E3%81%8C%E5%87%BA%E3%82%8B

貢献者が手元で私のTeam IDのProvisioning Profileをもたずにデバッグ実行するにはリリース版macSKKとはBundle Identifierが異なるバイナリを作れるようにしたほうがいいのかなあ…? とか考えていたりしました。

@y-yu
Copy link
Contributor Author

y-yu commented Apr 7, 2024

あまりちゃんとわかってないですが、こういう 👇編集をしないと手元でコンパイルできないですね。

diff --git a/macSKK.xcodeproj/project.pbxproj b/macSKK.xcodeproj/project.pbxproj
index 9434232..1a2e0a8 100644
--- a/macSKK.xcodeproj/project.pbxproj
+++ b/macSKK.xcodeproj/project.pbxproj
@@ -840,7 +840,7 @@
                                CURRENT_PROJECT_VERSION = 32;
                                DEAD_CODE_STRIPPING = YES;
                                DEVELOPMENT_ASSET_PATHS = "\"macSKK/Preview Content\"";
-                               DEVELOPMENT_TEAM = W3A6B7FDC7;
+                               DEVELOPMENT_TEAM = "";
                                ENABLE_HARDENED_RUNTIME = NO;
                                ENABLE_PREVIEWS = YES;
                                GENERATE_INFOPLIST_FILE = YES;
@@ -876,7 +876,7 @@
                                CURRENT_PROJECT_VERSION = 32;
                                DEAD_CODE_STRIPPING = YES;
                                DEVELOPMENT_ASSET_PATHS = "\"macSKK/Preview Content\"";
-                               DEVELOPMENT_TEAM = W3A6B7FDC7;
+                               DEVELOPMENT_TEAM = "";
                                ENABLE_HARDENED_RUNTIME = YES;
                                ENABLE_PREVIEWS = YES;
                                GENERATE_INFOPLIST_FILE = YES;
@@ -941,7 +941,7 @@
                                CODE_SIGN_ENTITLEMENTS = FetchUpdateService/FetchUpdateService.entitlements;
                                CODE_SIGN_STYLE = Automatic;
                                COMBINE_HIDPI_IMAGES = YES;
-                               DEVELOPMENT_TEAM = W3A6B7FDC7;
+                               DEVELOPMENT_TEAM = "";
                                GENERATE_INFOPLIST_FILE = YES;
                                INFOPLIST_FILE = FetchUpdateService/Info.plist;
                                INFOPLIST_KEY_CFBundleDisplayName = FetchUpdateService;

@y-yu
Copy link
Contributor Author

y-yu commented Apr 8, 2024

どうしようかな、このスクリプトじゃなくてもいいんですが、この手のものが何かしらないと普通の人(?)にとってはローカルでの検証が難しそうなので、なにかしらあったほうがいい気はしますね 👀

@mtgto
Copy link
Owner

mtgto commented Apr 13, 2024

あまりちゃんとわかってないですが、こういう 👇編集をしないと手元でコンパイルできないですね。

これは私がApple Develop Program (有償) に入ってAppleからもらっているTeam IDなのでたしかに変更しないとビルド通らなくなりますね (コンパイル後に署名する際に使ってる)。

#60 でやめたんですが、xcodebuildの引数で DEVELOPMENT_TEAM= をつけてあげるとxcodeprojファイル自体は書き換えなくてもビルド時に使用するProvisioning Profileをなしにできるのでそのほうがbuild_restart.shとしてはよさそうな気がします。


OSS開発でコラボレーターに共通のTeam IDを使って開発する、ってできないのかなあ…
Enterprise契約で複数人契約ならほんとにチームで使う証明書を作成できるけど、OSSのようにOwnerが正規の会員でそれ以外は許可した人だけが使えると便利なんだけどAppleのルール的に可能なのかわかっていない…

@mtgto
Copy link
Owner

mtgto commented Apr 13, 2024

Apple Developer契約したユーザー (Developer Program契約はせず、無料でもよいはず) をDeveloperとして私のTeamに追加、macSKKのMacアプリ開発用Provisioning Profileにコラボレーターの証明書とコラボレーターの端末を追加することはできる… 気がする。
https://developer.apple.com/jp/help/account/manage-your-team/invite-team-members

Co-authored-by: Satoshi Goto <[email protected]>
@y-yu
Copy link
Contributor Author

y-yu commented Apr 15, 2024

自分はApple Develop Programに毎年お金を払ってるんですが、理想的にはお金を払っていない方でも簡単な操作(環境変数の設定など?)でmacSKK.xcodeprojを書き換えることなくコンパイルできるといいですよね 👀
自分が作っているものではXcodeGenを使っていたりします。

@y-yu
Copy link
Contributor Author

y-yu commented Apr 15, 2024

** ARCHIVE SUCCEEDED **

./build_restart.sh  0.83s user 0.32s system 4% cpu 26.921 total

sudoなしでうまくいくようになりました 🎉


set -e
# ビルド
xcodebuild -workspace macSKK.xcodeproj/project.xcworkspace -scheme macSKK DEVELOPMENT_TEAM= clean archive -archivePath build/archive.xcarchive
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#60 を参考に DEVELOPMENT_TEAM=を追加した。

@mtgto mtgto merged commit fdc96de into mtgto:main Apr 22, 2024
2 checks passed
@y-yu y-yu deleted the add-build_restart-script branch April 22, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants