Ho trascorso anche un paio di giorni a scrivere una soluzione per questo problema. Ecco uno script ruby che è possibile aggiungere alla destinazione del progetto come fase di esecuzione dello script. Questo è stato testato con XCode 3.2.4 e ruby 1.8.7.
Per far funzionare questo, è necessario installare rb-appscript ruby gem. (Ad es: sudo gem install RB-appscript)
C'è poco messa a punto da fare:
- In primo luogo ha bisogno di una lista di obiettivi di compilazione per i file aggiunti.
- In secondo luogo, si aspetta un nome di gruppo di progetto che verrà sincronizzato con la cartella del disco associata ('objc' nel mio caso). Ovviamente questo gruppo deve esistere e puntare a una vera cartella.
Ecco lo script:
require 'rubygems'
require 'appscript'
target_names = ['MinitSample'] # Put your target names here
group_name = 'objc' # Name of Xcode project group where to add the generated files
project_name = ENV["PROJECT_NAME"]
project_dir = ENV["PROJECT_DIR"]
xcode = Appscript.app('Xcode')
project = xcode.projects[project_name]
group = project.groups[group_name]
group_path = group.real_path.get
generated_files = Dir.glob(group_path+"/*.m")
missing_files = Array.new(generated_files)
group.item_references.get.each {|item|
item_path = item.real_path.get
missing_files.delete(item_path)
if ! generated_files.include?(item_path) then
group.file_references[item.name.get].delete
puts "Deleting #{File.basename(item_path)} from group #{group_name}, as it is not in generated files list"
end
}
if missing_files.empty? then
puts "There are no new files to add. "
exit
end
# holds the compile targets for generated files
targets = []
project.targets.get.each{ |target|
targets << target if target_names.include?(target.name.get)
}
if targets.empty? then
puts "Unable to find #{target_names.inspect} in project targets ! Aborting"
exit
end
missing_files.each{ |path|
file_name = File.basename(path)
msg = "Adding #{file_name} to group #{group_name} and to targets: "
item = xcode.make(:new => :file_reference,
:at => group.item_references.after,
:with_properties => {:full_path => path,
:name => file_name})
targets.each {|target|
xcode.add(item,{:to=>target})
msg += target.name.get
}
puts msg
}
Questo è ancora caldo, specialmente quando si pensa alla generazione di codice swagger e API. Hai qualche progresso su questo? –