Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

各Framework内のbridgesupportファイル情報の収集

Posted on 11月 29 by Takaaki Naganoya

macOS内の標準装備のFrameworkの情報を収集するAppleScriptです。AppleScriptからmacOS内のFrameworkを呼ぶには、Framework内にbridgesupportファイルが存在している必要があります。

これまで、さまざまな資料を作成するさいに、Frameworkの有無だけをまとめてきましたが……結局のところ、bridgesupportファイルの有無を調査しないと意味がないのでは? ということで書いてみたものです。

結果は、Framework名、x86版の有無、ARM64E版の有無がCSVファイルで出力されます。

AppleScript名:各Framework内のbridgesupportファイル情報の収集_v2.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2024/11/29
—
–  Copyright © 2024 Piyomaru Software, All Rights Reserved
—

use AppleScript
use framework "Foundation"
use scripting additions

script spd
  property a1Res : {}
  
property a2Res : {}
  
property a3Res : {}
  
property allList : {}
  
property fNames : {}
end script

set outPath to POSIX path of (choose file name with prompt "Input file name (with \".csv\")")

–Frameworkフォルダ1から取得
set frPath to "/System/Library/Frameworks/"
set s1Text to "find " & frPath & " -name *.framework"
set (a1Res of spd) to paragraphs of (do shell script s1Text)

set osV to my numToHex((system attribute "sysv"), 4)

if osV ≥ "1200" then
  –Frameworkフォルダ2から取得
  
set frPath to "/System/DriverKit/System/Library/Frameworks"
  
set s1Text to "find " & frPath & " -name *.framework"
  
set (a2Res of spd) to paragraphs of (do shell script s1Text)
  
  
–合成
  
set (a3Res of spd) to (a1Res of spd) & (a2Res of spd)
else
  copy (a1Res of spd) to (a3Res of spd)
end if

–合成して重複を除去
set aRes to uniquify1DList((a3Res of spd)) of me

–フレームワークでループして、bridgesupportファイルをx64とApple Silicon版を検索
set (fNames of spd) to {}
repeat with i in aRes
  set t1Path to (current application’s NSString’s stringWithString:(i))
  
set t2Path to t1Path’s stringByResolvingSymlinksInPath() –リンクを解消
  
set tName to t2Path’s lastPathComponent()’s stringByDeletingPathExtension() as string
  
  
–Find x64 bridgesupport
  
set s1Text to "find " & t2Path & " -name " & tName & ".bridgesupport"
  
try
    set a1Res to do shell script s1Text
  on error
    set a1Res to ""
  end try
  
  
–Find Apple Silicon (ARM64E) bridgesupport
  
set s2Text to "find " & t2Path & " -name " & tName & ".arm64e.bridgesupport"
  
try
    set a2Res to do shell script s2Text
  on error
    set a2Res to ""
  end try
  
  
–Check result of x64 bridgesupport  
  
set ttList to {tName}
  
if a1Res is not equal to "" then
    set the end of ttList to "●"
  else
    set the end of ttList to ""
  end if
  
  
–Check result of Apple Silicon (ARM64E) bridgesupport   
  
if a2Res is not equal to "" then
    set the end of ttList to "●"
  else
    set the end of ttList to ""
  end if
  
  
–Store Results
  
if tName is not in (fNames of spd) then –重複出力を防ぐ
    set the end of (allList of spd) to ttList
    
set the end of (fNames of spd) to tName
  end if
end repeat

–結果のCSV書き出し
set sRes to saveAsCSV((allList of spd), outPath) of me

on numToHex(theNumber, stringLength)
  set hexString to {}
  
repeat with i from stringLength to 1 by -1
    set hexString to ((theNumber mod 16) as string) & hexString
    
set theNumber to theNumber div 16
  end repeat
  
return (hexString as string)
end numToHex

on getFileSizeFromPath(aPath)
  set aaPath to current application’s NSString’s stringWithString:(aPath)
  
set aaaPath to aaPath’s stringByResolvingSymlinksInPath() –リンクを解消
  
set aFM to current application’s NSFileManager’s defaultManager()
  
set anAttr to aFM’s attributesOfItemAtPath:(aaaPath) |error|:(missing value)
  
set sRes to anAttr’s fileSize()
  
return sRes as string
end getFileSizeFromPath

–文字置換
on repChar(origText as string, targChar as string, repChar as string)
  set curDelim to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to targChar
  
set tmpList to text items of origText
  
set AppleScript’s text item delimiters to repChar
  
set retText to tmpList as string
  
set AppleScript’s text item delimiters to curDelim
  
return retText
end repChar

–2D List to CSV file
on saveAsCSV(aList, aPath)
  –set crlfChar to (ASCII character 13) & (ASCII character 10)
  
set crlfChar to (string id 13) & (string id 10)
  
set LF to (string id 10)
  
set wholeText to ""
  
  
repeat with i in aList
    set newLine to {}
    
    
–Sanitize (Double Quote)
    
repeat with ii in i
      set jj to ii as text
      
set kk to repChar(jj, string id 34, (string id 34) & (string id 34)) of me –Escape Double Quote
      
set the end of newLine to kk
    end repeat
    
    
–Change Delimiter
    
set aLineText to ""
    
set curDelim to AppleScript’s text item delimiters
    
set AppleScript’s text item delimiters to "\",\""
    
set aLineList to newLine as text
    
set AppleScript’s text item delimiters to curDelim
    
    
set aLineText to repChar(aLineList, return, "") of me –delete return
    
set aLineText to repChar(aLineText, LF, "") of me –delete lf
    
    
set wholeText to wholeText & "\"" & aLineText & "\"" & crlfChar –line terminator: CR+LF
  end repeat
  
  
if (aPath as string) does not end with ".csv" then
    set bPath to aPath & ".csv" as Unicode text
  else
    set bPath to aPath as Unicode text
  end if
  
  
return writeToFileAsUTF8(wholeText, bPath) of me
end saveAsCSV

on writeToFileAsUTF8(aStr, aPath)
  set cStr to current application’s NSString’s stringWithString:aStr
  
set thePath to POSIX path of aPath
  
set aRes to cStr’s writeToFile:thePath atomically:false encoding:(current application’s NSUTF8StringEncoding) |error|:(missing value)
  
return aRes as boolean
end writeToFileAsUTF8

on uniquify1DList(theList as list)
  set theSet to current application’s NSOrderedSet’s orderedSetWithArray:theList
  
return (theSet’s array()) as list
end uniquify1DList

★Click Here to Open This Script 

More from my site

  • Keynoteで選択中のtext itemの冒頭のフォントを太くする v2Keynoteで選択中のtext itemの冒頭のフォントを太くする v2
  • iCalendarファイルの作成iCalendarファイルの作成
  • デフォルトインストールされたフォント名を取得するAppleScriptデフォルトインストールされたフォント名を取得するAppleScript
  • 国民の祝日を求める v7国民の祝日を求める v7
  • 国民の祝日を求める v6国民の祝日を求める v6
  • 相対年月を計算(月の相対指定)v4相対年月を計算(月の相対指定)v4
(Visited 4 times, 4 visits today)
Posted in System | Tagged 12.0savvy 13.0savvy 14.0savvy 15.0savvy | Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • 開発機としてM2 Mac miniが来たのでガチレビュー
  • macOS 13.6.5 AS系のバグ、一切直らず
  • CotEditorで2つの書類の行単位での差分検出
  • Apple純正マウス、キーボードのバッテリー残量取得
  • macOS 15, Sequoia
  • 初心者がつまづきやすい「log」コマンド
  • ディスプレイをスリープ状態にして処理続行
  • Adobe AcrobatをAppleScriptから操作してPDF圧縮
  • 指定のWordファイルをPDFに書き出す
  • 与えられた文字列の1D Listのすべての順列組み合わせパターン文字列を返す v3(ベンチマーク用)
  • メキシカンハットの描画
  • macOS 13 TTS環境の変化について
  • 2023年に書いた価値あるAppleScript
  • Pixelmator Pro v3.6.4でAppleScriptからの操作時の挙動に違和感が
  • Pages本執筆中に、2つの書類モード切り替えに気がついた
  • AdobeがInDesign v19.4からPOSIX pathを採用
  • 可変次元のベクトルに対応したコサイン類似度計算
  • Safariで「プロファイル」機能を使うとAppleScriptの処理に影響
  • Cocoa Scripting Course 続刊計画
  • macOS 13.6.2アップデート Cocoa-AppleScript Applet修正はなし

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1391) 10.14savvy (586) 10.15savvy (437) 11.0savvy (281) 12.0savvy (202) 13.0savvy (143) 14.0savvy (91) 15.0savvy (67) CotEditor (63) Finder (51) iTunes (19) Keynote (112) NSAlert (60) NSArray (51) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (51) NSDictionary (27) NSFileManager (23) NSFont (19) NSImage (41) NSJSONSerialization (21) NSMutableArray (62) NSMutableDictionary (21) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (117) NSURL (97) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (67) Pages (51) Safari (44) Script Editor (26) WKUserContentController (21) WKUserScript (20) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • Beginner
  • Benchmark
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • Clipboard
  • Cocoa-AppleScript Applet
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • diff
  • drive
  • Droplet
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Localize
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • parallel processing
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • rectangle
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年6月
  • 2024年5月
  • 2024年4月
  • 2024年3月
  • 2024年2月
  • 2024年1月
  • 2023年12月
  • 2023年11月
  • 2023年10月
  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC