commond line add frameworks 敷待、library and tbd (text-based stub libraries)
XCode 7之后apple有了一種新的動(dòng)態(tài)庫tbd济似;有些新的項(xiàng)目中需要添加比如忠蝗,GotyAPI該工程就需要添加stdc++.6.0.9.tbd
為了可以在jenkins中能自動(dòng)構(gòu)建摄咆,就需要自動(dòng)編輯xcodeproj中BuildPhase中Framework添加需要應(yīng)用的庫
原來的XCodeproj是可以直接支持Framework 和 dylib 兩類文件裤翩。
操作方法可以見 下面具體代碼
對(duì)于系統(tǒng)級(jí)引用的接口分別為:
add_system_framework
add_system_library
但是新的tbd類型的文件忘衍,是沒有接口支持的
為了能達(dá)到目的蛹稍,就新增加一個(gè)接口 add_system_tbd 實(shí)現(xiàn)參考了library
https://github.com/typedef/Xcodeproj/commit/925280230c8d591d9b3e02ed9d1b0438b8d1e413
關(guān)于xcodeproj的了解還不夠,就先用這種笨辦法解決了氛濒。里面的絕對(duì)路徑還是有點(diǎn)問題产场。不過能解決眼前的問題。
先記錄下舞竿,作為備忘京景。
#!/usr/bin/env ruby
require 'rubygems'
# The lower version of xcodeproj is not available because the API has changed.
gem "xcodeproj", ">=0.14.0"
require 'xcodeproj'
projpath = ARGV[0] + "/Unity-iPhone.xcodeproj"
proj = Xcodeproj::Project.open(projpath)
proj.targets.each do |target|
next unless target.name == "Unity-iPhone"
# Add Frameworks
target.add_system_framework("MessageUI")
target.add_system_library("stdc++")
target.add_system_tbs("stdc++.6.0.9")
# Add Other Linker Flags
target.build_settings("Debug")["OTHER_LDFLAGS"] << "-ObjC"
target.build_settings("Release")["OTHER_LDFLAGS"] << "-ObjC"
end
end
proj.save(projpath)