我一直想弄清楚如何以編程方式將文件添加到Xcode4項目,它似乎像AppleScript將要走的路,但我遇到「缺失值」錯誤。如何以編程方式將構建文件添加到Xcode4?
下面是我得到了代碼:我已經試過被註釋掉的行,而不是附加命令以及
tell application "Xcode"
set theProject to first project
set theTarget to first target of theProject
set theBuildPhase to compile sources phase of theTarget
tell first group of theProject
set theFileRef to make new file reference with properties {full path:"/Users/jeff/Projects/XcodeTest/XcodeTest/MyViewController.h", name:"MyViewController.h", path:"XcodeTest/MyViewController.h", path type:group relative}
add theFileRef to theProject
end tell
--tell theBuildPhase to make new build file with properties {build phase:theBuildPhase, name:"MyViewController.h", file reference:theFileRef, target:theTarget, project:theProject}
end tell
,但是,這並不工作,要麼(我得到「缺失值「)。
「添加」的錯誤是:
error "Xcode got an error: file reference id \"251AD3431432472E006E300F\" of Xcode 3 group id \"251AD32C14324645006E300F\" of project \"XcodeTest\" of workspace document \"XcodeTest.xcodeproj/project.xcworkspace\" doesn’t understand the add message." number -1708 from file reference id "251AD3431432472E006E300F" of Xcode 3 group id "251AD32C14324645006E300F" of project "XcodeTest" of workspace document "XcodeTest.xcodeproj/project.xcworkspace"
「製作新的參考」不將文件添加到在Xcode文件的列表,但我也需要它被添加到該項目的目標,使我可以添加操作和插件到Xcode的文件中,無需首先選中複選框將其添加到「目標成員」中。
有時候,「你不能」表示:「我們不希望你做/知道仙大概,我相信你可以用某種方式來做,但他們會在商店裏阻止它。 – mthama