確認した環境
- iMac Late 2015 + Sonoma 14.2.1
- iPhone SE2 + iOS 17.6.1
手順
libimobiledeviceをインストールする
brew でインストール
セルフビルドは🦑などを参考
Xcodeのプロジェクトを作る
Create New Project
-> macOS
-> App -> 適当な場所に適当な名前で作成
Bridging-Header.h とか
#ifndef Bridging_Header_h
#define Bridging_Header_h
#include <libimobiledevice/libimobiledevice.h>
#include <libimobiledevice/lockdown.h>
#include <libimobiledevice/afc.h>
#endif /* Bridging_Header_h */
Build Settings -> All
-> Objective-C Bridging Header ([プロジェクト名]/Bridging-Header.h
などを入力)
Build Settings
-> Library Search Paths (/usr/local/lib
)
Build Settings
-> Header Search Paths (/usr/local/include
)
Build Settings
-> Other Linker Flags (-limobiledevice-1.0
)
Build Settings
-> Architectures
-> $(ARCHS_STANDARD)
-> x86_64
コードを書く
以下参照
ビルドして実行
D&Dするとこんな感じでコピーできる
[ContentView.swift:256] copyFromIPhoneToMac(from:to:): copy //iTunes_Control/Music/F05 -> /Users/tyano
[ContentView.swift:249] copy_inner(using:from:to:): copy done //iTunes_Control/Music/F05/TTNW.m4a -> /Users/tyano/F05/TTNW.m4a
[ContentView.swift:249] copy_inner(using:from:to:): copy done //iTunes_Control/Music/F05/CEHQ.m4a -> /Users/tyano/F05/CEHQ.m4a
[ContentView.swift:249] copy_inner(using:from:to:): copy done //iTunes_Control/Music/F05/XRGK.mp3 -> /Users/tyano/F05/XRGK.mp3
[ContentView.swift:249] copy_inner(using:from:to:): copy done //iTunes_Control/Music/F05/SOQB.m4a -> /Users/tyano/F05/SOQB.m4a
[ContentView.swift:249] copy_inner(using:from:to:): copy done //iTunes_Control/Music/F05/ZQQI.m4a -> /Users/tyano/F05/ZQQI.m4a
tyano@macnoiMac ~ % ls -alrt ~/F05
total 93168
drwxr-x---+ 27 tyano staff 864 6 10 16:57 ..
-rw-r--r-- 1 tyano staff 8460562 6 10 16:57 TTNW.m4a
-rw-r--r-- 1 tyano staff 8498602 6 10 16:57 CEHQ.m4a
-rw-r--r-- 1 tyano staff 9466819 6 10 16:57 XRGK.mp3
-rw-r--r-- 1 tyano staff 9588277 6 10 16:57 SOQB.m4a
drwxr-xr-x 7 tyano staff 224 6 10 16:57 .
-rw-r--r-- 1 tyano staff 11679783 6 10 16:57 ZQQI.m4a
その他
D&Dの反応がめちゃくちゃ悪くて10回くらい掴まないと反応しないんだけど
なんでだろう