AppleScript argv 引数

osascript シェル実行

AppleScript でスクリプトで引数を受け取りたい場合のコード例です

on run argv
    argv as text
end

上記コードをファイルに保存し(ここではindex.scptとしました) 「/usr/bin/osascript」から実行すると結果「ab」が返ります

/usr/bin/osascript index.scpt a b
/usr/bin/osascript index.scpt a b

引数をカンマ区切りで返す場合下記のように記述できます

on run argv
	set _d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to ","
	try
		set _a to argv as text
	on error
		set _a to "error"
	end try
	set AppleScript's text item delimiters to _d
	_a
end run

AppleScriptをシェル実行したい場合

osascriptから実行しなくてもAppleScriptはシェルに入れることができます。その場合先頭に「#!/usr/bin/env osascript」が必要です。

#!/usr/bin/env osascript
on run argv
    argv as text 
end

上記のコードをファイル保存し、chmodで実行権限を与えると実行可能です。

Mac (MacBook) パスワード付きZIPファイル作成方法

Mac パスワード付きZIP作成

Mac(macOS)でパスワード付きZIPファイルを作成する場合「ターミナル」アプリを開いてzipcloakコマンドを利用しますが、Retool-zipアプリを使えば簡単にパスワード付きZIPを作成できます(M1 CPUにも対応しています)

App Storeの下記URLからRetool-zipダウンロードインストールします

https://apps.apple.com/us/app/retool-zip/id1589645185

Retool-zipをインストールするとアプリケーションフォルダ内に下のようなアイコンが作られます

Retool-zipアイコン

このアイコンをダブルクリックすると起動します

起動すると下の画面が表示されます

Retool-zip起動後メイン画面
Retool-zipメイン画面

基本的な利用方法は、①のZIPパスワードを設定(もしくは自動)圧縮したいファイルを②ドラッグアンドドロップし③ZIP作成ボタンをクリックすると保存ダイアログが出てきます

パスワード設定項目のLengthでパスワード桁を変更し右側「🔁更新」ボタンをクリックするとパスワードのパターンを変えることができます。

Xcode Project Archives [Distribute App]ERROR ITMS-90296

com.apple.security.app-sandbox

macOS用アプリをApp Storeから配布する場合。Xcode メニューから[Project|Archives]をクリックでOrganizerが起動し[Distribute App]ボタンで「App Store Connect」に送信できます。普段macOSのアプリを作ってもApp Storeを使って配布することがなくて知らなかったんですが、”com.apple.security.app-sandbox”を設定しないと配布できないようでした。

ERROR ITMS-90296: "App sandbox not enabled. The following executables must include the "com.apple.security.app-sandbox" entitlement with a Boolean value of true in the entitlements property list: [( "com.mjeld.xxx.pkg/Payload/xxx.app/Contents/MacOS/xxx" )] Refer to App Sandbox page at https://developer.apple.com/documentation/security/app_sandbox for more information on sandboxing your app."

上記のエラーがでまして、Xcode アプリ[TARGET]のApp SandboxをONに変更して再度[Distribute App]すれば送信成功しました。