1. 程式人生 > >AppleScript 建立IOS 描述配置檔案

AppleScript 建立IOS 描述配置檔案

最近接觸要用到iPhone 手機配置描述檔案。

首先,蘋果有一個專門生成配置描述檔案的工具:iPhone 配置描述工具,需要的話可以去蘋果官網找找,手動建立配置描述檔案,還算容易的。

由於專案需要,需要描述檔案自動根據請求內容自動生成,所以就要做成服務端生成,用指令碼自動生成現在還碰到一個問題是,怎麼獲取用指令碼獲取傳遞過來的引數,並把引數傳遞到指令碼中,暫時還沒解決。

mac平臺下就需要用AppleScript 指令碼語言,第一感覺applescript很不友好,確實都看不懂,說明文件列看了一會,還是不知道怎麼下手。

google 資料比較少,不過東拼西湊還是可以,下面是自己寫的一個wifi 配置描述檔案。

tell application "iPhone Configuration Utility"

set myconfigureto make newconfiguration profilewith properties {displayed name:"heitan",profile identifier:"com.heitan.wifi"}

tell myconfigure

set mywifipayloadto makenewWiFi payload of myconfigure with properties {service set identifier:"heitan",password

:"12345678"}

tell mywifipayload

make newtrusted server certificateof mywifipayloadwith properties {certificate name:"heitan"}

end tell

end tell

export myconfigureto "~/testwifi"

end tell


1、如何在終端執行applescript指令碼

命令:osascript scriptname(scriptname:指令碼名稱)

2、如何從執行指令碼命令中獲取引數

命令:osascript scriptname heitan 12345678

on run argv

set username1 to text of "" & item 1 of argv & ""

set userpwd to text of "" & item 2 of argv & ""

end run

一下圖片是通過命令,動態建立wifi配置描述檔案。