2011-01-20 54 views
9

我在使用AppleScript將文件夾複製到XCode項目時遇到了一些麻煩。沒有Applescript我將文件夾拖入Xcode。蘋果將文件夾複製到Xcode中?

我已經使用了類似的Applescript處理程序,如下所示,使用「wrapper.library」將文件類型複製到XCode中。下面我使用「wrapper.folder」嘗試將文件夾複製到XCode中,但它不起作用。

on addFolder(fname, fpath) 
    tell application "Xcode" 
    tell project "Unity-iPhone" 
    set my_targets to targets 
    set s_target to item 1 of my_targets 
    set compile_phase to compile sources phase of s_target 
    set link_phase to get link binary with libraries phase of s_target 
    tell root group 
    set a to make new file reference with properties {full path:fpath & fname, name:fname, file type:"wrapper.folder"} 
    add a to link_phase 
    end tell 
    end tell 
    end tell 
    end addFolder 

有沒有人有任何想法,我缺少什麼或如何編寫一個Applescript複製到XCode文件夾?

+0

我很想知道你是怎麼解決這個問題的...... – 2012-01-12 17:17:20

+0

這個Xcode插件可能有幫助:https://github.com/larsxschneider/Xcode-Scripting-Interface – 2011-11-28 08:23:29

回答

1

這是爲我工作:

--this is for xcode 3.x 
tell application "Xcode" 
    tell active project document 
     tell root group 
      --Note: Large folders make it seems that the script is hanging. Give it some time to list all items in the given folder. 
      make new file reference with properties {name:"My Desktop Folder", full path:(POSIX path of (path to desktop folder)), file type:"wrapper.folder"} 
     end tell 
    end tell 
end tell 

的Xcode的4中的代碼是不同的一點

--this is for Xcode 4.x 
tell application "Xcode" 
    tell project 1 
     tell root group 
      --Note: big folders make it seems that the application (not the script like in Xcode 3) is hanging. Give it some time to list all items in the given folder. 
      make new file reference with properties {name:"My Desktop Folder", full path:(POSIX path of (path to desktop folder)), file kind:"folder"} 
     end tell 
    end tell 
end tell 

選項只是將文件複製到該項目如果需要複製到目標文件夾「 (如果它們不在那裏),然後對複製的文件進行文件引用而不是原始文件。您可以使用Finder或cp或ditto等shell命令執行相同的操作,然後對複製的文件進行引用。然後我不會使用完整路徑,而是使用相對路徑。使用相對路徑將項目移動到另一個文件夾不會給您帶來任何問題。

相關問題