24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/ios-box/cli.rb', line 24
def integrate(project = nil)
shell = Thor::Shell::Basic.new
if project.nil?
project = Dir["*.xcodeproj"].first
end
unless File.exists?(project) and File.directory?(project)
shell.error "Project #{project} is not valid."
exit
end
shell.say "Integrating to project #{project}"
xcode = project || Dir["*.xcodeproj"].first
raise "Cannot find project.pbxproj in #{xcode}" unless File.file? "#{xcode}/project.pbxproj"
pbx = PBXProject::PBXProject.new :file => "#{xcode}/project.pbxproj"
pbx.parse
targets = pbx.find_item :type => PBXProject::PBXTypes::PBXNativeTarget
if targets.nil? or targets.empty?
raise "XCode project does not have any targets!"
end
prebuilds = [] if prebuilds.empty?
initPhase = PBXProject::PBXTypes::PBXShellScriptBuildPhase.new(
:shellPath => '/bin/sh',
:shellScript => "\"(cd $PROJECT_DIR; ios-box build prepare)\"",
:showEnvVarsInLog => 0,
:name => '"ios-box prepare"'
)
initPhase. = "ios-box prepare"
pbx.add_item initPhase
else
initPhase = prebuilds.first
end
targets.each do |target|
if shell.yes?("Integrate with target #{target.name.value}? [yn]")
target.add_build_phase initPhase, 0
end
end
config = Config.new
config.project = project
config.targets = targets.collect{|c| c.name.value}
config.growl = true config.deploy = {'autonotes' => true} config.save(".iosbox")
send((File.exists?(".gitignore") ? :append_to_file : :create_file), ".gitignore", ".buildcache\n")
pbx.write_to :file => "#{xcode}/project.pbxproj"
end
|