unigunkan 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/bin/unigunkan +16 -2
- data/lib/unigunkan/buildfile.rb +15 -0
- data/lib/unigunkan/fileref.rb +46 -0
- data/lib/unigunkan/modifier.rb +34 -0
- data/lib/unigunkan/processor.rb +51 -0
- data/lib/unigunkan/version.rb +1 -1
- data/lib/unigunkan.rb +3 -0
- data/spec/models_spec.rb +33 -0
- data/spec/project_spec.rb +69 -0
- data/spec/spec_helper.rb +3 -0
- metadata +13 -4
data/README.md
CHANGED
@@ -22,6 +22,10 @@ To disable Retina 4 inch devices support,
|
|
22
22
|
|
23
23
|
$ unigunkan /path/to/project/Unity-iPhone.xcodeproj --disable-retina-4inch-support
|
24
24
|
|
25
|
+
Add folder references,
|
26
|
+
|
27
|
+
$ unigunkan /path/to/project/Unity-iPhone.xcodeproj --folder-refs=../../assetbundles
|
28
|
+
|
25
29
|
## Contributing
|
26
30
|
|
27
31
|
1. Fork it
|
data/bin/unigunkan
CHANGED
@@ -9,6 +9,9 @@ OPTS = {}
|
|
9
9
|
opt.on('-y') {|v| OPTS[:y] = v }
|
10
10
|
opt.on('--disable-retina-4inch-support') {|v| OPTS[:disable_retina_4inch_support] = v}
|
11
11
|
opt.on('--folder-refs VAL') {|v| OPTS[:folder_refs] = v}
|
12
|
+
opt.on('--integrate-testflight-sdk') {|v| OPTS[:integrate_testflight_sdk] = v}
|
13
|
+
opt.on('--testflight-sdk VAL') {|v| OPTS[:testflight_sdk] = v}
|
14
|
+
opt.on('--testflight-application-token VAL') {|v| OPTS[:testflight_application_token] = v}
|
12
15
|
opt.parse!(ARGV)
|
13
16
|
|
14
17
|
input = ARGV[0]
|
@@ -20,8 +23,6 @@ if input.nil?
|
|
20
23
|
exit false
|
21
24
|
end
|
22
25
|
|
23
|
-
puts "Hello Uni. #{ARGV[0]}"
|
24
|
-
|
25
26
|
input = "#{input}/project.pbxproj" if !File.exists?(input) || File::ftype(input) == "directory"
|
26
27
|
|
27
28
|
if !File.exists?(input)
|
@@ -38,10 +39,23 @@ if backup_confirmed != true
|
|
38
39
|
exit false
|
39
40
|
end
|
40
41
|
|
42
|
+
if OPTS[:integrate_testflight_sdk] == true
|
43
|
+
if OPTS[:testflight_sdk] == nil || OPTS[:testflight_application_token] == nil
|
44
|
+
STDERR.puts "To integrate testflight sdk, please set params below."
|
45
|
+
STDERR.puts "--testflight-sdk /path/to/sdk"
|
46
|
+
STDERR.puts "--testflight-application-token 123456"
|
47
|
+
exit false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
41
51
|
processor = Unigunkan::Processor.new(input, OPTS)
|
42
52
|
processor.create_backup
|
43
53
|
processor.disable_retina_4inch_support if disable_retina_4inch_support
|
44
54
|
processor.add_folder_refs
|
45
55
|
|
56
|
+
if OPTS[:integrate_testflight_sdk] == true
|
57
|
+
processor.integrate_testflight_sdk OPTS[:testflight_sdk], OPTS[:testflight_application_token]
|
58
|
+
end
|
59
|
+
|
46
60
|
processor.delete_original_project_file
|
47
61
|
processor.write
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class BuildFile
|
2
|
+
attr_accessor :id
|
3
|
+
|
4
|
+
def initialize(fileref)
|
5
|
+
@id = SecureRandom.hex(12)
|
6
|
+
@fileref = fileref
|
7
|
+
end
|
8
|
+
|
9
|
+
def key
|
10
|
+
"#{@id} /* #{@fileref.name} in #{@fileref.group} */"
|
11
|
+
end
|
12
|
+
def to_s
|
13
|
+
"#{self.key} = {isa = PBXBuildFile; fileRef = #{@fileref.id} /* #{@fileref.name} */; };"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class FileRef
|
2
|
+
attr_accessor :id, :name, :last_known_type, :path, :source_tree, :file_encoding
|
3
|
+
|
4
|
+
def initialize(hash)
|
5
|
+
@id = SecureRandom.hex(12)
|
6
|
+
@name = hash[:name]
|
7
|
+
@last_known_type = hash[:last_known_type]
|
8
|
+
@path = hash[:path]
|
9
|
+
@source_tree = hash[:source_tree]
|
10
|
+
@file_encoding = hash[:file_encoding]
|
11
|
+
end
|
12
|
+
|
13
|
+
def fields
|
14
|
+
last_known_type = @last_known_type
|
15
|
+
last_known_type = "\"#{last_known_type}\"" if last_known_type == "compiled.mach-o.dylib"
|
16
|
+
|
17
|
+
elements = ["isa = PBXFileReference", "lastKnownType = #{last_known_type}", "name = #{@name}", "path = #{@path}", "sourceTree = #{@source_tree}"]
|
18
|
+
elements << "fileEncoding = #{@file_encoding}" if @file_encoding
|
19
|
+
elements.map{|a| "#{a};"}.join(" ")
|
20
|
+
end
|
21
|
+
|
22
|
+
def key
|
23
|
+
"#{@id} /* #{@name} */"
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
"#{self.key} = {#{self.fields}};"
|
28
|
+
end
|
29
|
+
|
30
|
+
def group
|
31
|
+
FileRef.file_group(self.name)
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_file
|
35
|
+
@build_file = BuildFile.new(self) if !@build_file
|
36
|
+
return @build_file
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.file_group(filename)
|
40
|
+
ext = filename.split(".").last
|
41
|
+
case ext
|
42
|
+
when "dylib"
|
43
|
+
return "Frameworks"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Modifier
|
2
|
+
def self.add_build_files(src, files)
|
3
|
+
return add_block_after(src, "/* Begin PBXBuildFile section */", files)
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.add_file_ref(src, files)
|
7
|
+
return add_block_after(src, "/* Begin PBXFileReference section */", files)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.add_framework_build_phase(src, files)
|
11
|
+
src_ = src
|
12
|
+
target = /Frameworks \*\/ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = (.*?);\n\t\t\tfiles = \(/
|
13
|
+
mask = src_.scan(target)[0][0]
|
14
|
+
build_phases = "Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = #{mask};\n\t\t\tfiles = (\n"
|
15
|
+
return src_.gsub(build_phases, build_phases + files + ",")
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.add_file_to_tree(src, file)
|
19
|
+
target = "/* CustomTemplate */ = {
|
20
|
+
isa = PBXGroup;
|
21
|
+
children = ("
|
22
|
+
return add_block_after(src, target, file)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.add_library_search_paths(src, paths)
|
26
|
+
# TODO This won't work in non-unity projects. Fix later.
|
27
|
+
target = '$(SRCROOT)/Libraries\"",'
|
28
|
+
return add_block_after(src, target, paths)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.add_block_after(src, line, block)
|
32
|
+
src.gsub(line, line + "\n" + block)
|
33
|
+
end
|
34
|
+
end
|
data/lib/unigunkan/processor.rb
CHANGED
@@ -99,6 +99,57 @@ class Unigunkan::Processor
|
|
99
99
|
@src.gsub!(target, group + "\n" + entry_in_tree_to_add.join("\n"))
|
100
100
|
end
|
101
101
|
|
102
|
+
def new_uuid
|
103
|
+
SecureRandom.hex(10)
|
104
|
+
end
|
105
|
+
|
106
|
+
def link_library(library, path)
|
107
|
+
case library.split(".").last
|
108
|
+
when "dylib"
|
109
|
+
fileref = FileRef.new({name: library, last_known_type: "compiled.mach-o.dylib", path: path, source_tree: :SDKROOT})
|
110
|
+
@src = Modifier.add_build_files(@src, fileref.build_file.to_s)
|
111
|
+
@src = Modifier.add_file_ref(@src, fileref.to_s)
|
112
|
+
@src = Modifier.add_framework_build_phase(@src, fileref.build_file.key)
|
113
|
+
@src = Modifier.add_file_to_tree(@src, fileref.key + ",")
|
114
|
+
when "a"
|
115
|
+
fileref = FileRef.new({name: library, last_known_type: "archive.ar", path: "#{path}/#{library}", source_tree: "\"<group>\""})
|
116
|
+
@src = Modifier.add_build_files(@src, fileref.build_file.to_s)
|
117
|
+
@src = Modifier.add_file_ref(@src, fileref.to_s)
|
118
|
+
@src = Modifier.add_framework_build_phase(@src, fileref.build_file.key)
|
119
|
+
@src = Modifier.add_library_search_paths(@src, "\"\\\"#{path}\\\"\",")
|
120
|
+
@src = Modifier.add_file_to_tree(@src, fileref.key + ",")
|
121
|
+
else
|
122
|
+
puts "Unsupported: #{library}"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_header(file, path)
|
127
|
+
fileref = FileRef.new({name: file, last_known_type: "sourcecode.c.h", path: "#{path}/#{file}", source_tree: "\"<absolute>\"", file_encoding: 4})
|
128
|
+
@src = Modifier.add_file_ref(@src, fileref.to_s)
|
129
|
+
@src = Modifier.add_file_to_tree(@src, fileref.key + ",")
|
130
|
+
end
|
131
|
+
|
132
|
+
def integrate_testflight_sdk(sdk_path, token)
|
133
|
+
puts "Integrate TestFlight SDK #{sdk_path}, #{token}"
|
134
|
+
link_library "libz.dylib", "usr/lib/libz.dylib"
|
135
|
+
link_library "libTestFlight.a", sdk_path
|
136
|
+
add_header "TestFlight.h", sdk_path
|
137
|
+
|
138
|
+
# Import TestFlight.h in the precompiled header
|
139
|
+
pch_file = File.expand_path(@proj_file + "/../../Classes/iPhone_target_Prefix.pch")
|
140
|
+
pch = File.read(pch_file)
|
141
|
+
pch.gsub!("#ifdef __OBJC__","#ifdef __OBJC__\n#import \"TestFlight.h\"")
|
142
|
+
File.write(pch_file, pch)
|
143
|
+
|
144
|
+
# Insert some codes in AppController
|
145
|
+
app_controller_file = File.expand_path(@proj_file + "/../../Classes/AppController.mm")
|
146
|
+
app_controller = File.read(app_controller_file)
|
147
|
+
target = "- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions\n{"
|
148
|
+
|
149
|
+
app_controller.gsub!(target, target + "\n[TestFlight setDeviceIdentifier:[[UIDevice currentDevice] uniqueIdentifier]];[TestFlight takeOff:@\"#{token}\"];")
|
150
|
+
File.write(app_controller_file, app_controller)
|
151
|
+
end
|
152
|
+
|
102
153
|
def add_block_after(line, block)
|
103
154
|
@src.gsub!(line, line + "\n" + block)
|
104
155
|
end
|
data/lib/unigunkan/version.rb
CHANGED
data/lib/unigunkan.rb
CHANGED
data/spec/models_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
require File.expand_path(File.join('spec_helper'), File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe FileRef do
|
5
|
+
it "should be created from a hash" do
|
6
|
+
name = "libz.dylib"
|
7
|
+
path = "usr/lib/libz.dylib"
|
8
|
+
last_known_type = "compiled.mach-o.dylib"
|
9
|
+
ref = FileRef.new({name: name, last_known_type: last_known_type, path: path, source_tree: :SDKROOT})
|
10
|
+
ref.id.should_not be_nil
|
11
|
+
ref.name.should == name
|
12
|
+
ref.path.should == path
|
13
|
+
ref.last_known_type.should == last_known_type
|
14
|
+
|
15
|
+
puts ref.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should detect group correctly" do
|
19
|
+
FileRef.file_group("abc.dylib").should == "Frameworks"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe BuildFile do
|
24
|
+
it "should be created from fileref" do
|
25
|
+
name = "libz.dylib"
|
26
|
+
path = "usr/lib/libz.dylib"
|
27
|
+
last_known_type = "compiled.mach-o.dylib"
|
28
|
+
ref = FileRef.new({name: name, last_known_type: last_known_type, path: path, source_tree: :SDKROOT})
|
29
|
+
|
30
|
+
file = BuildFile.new(ref)
|
31
|
+
puts file
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
require File.expand_path(File.join('spec_helper'), File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe Modifier do
|
5
|
+
|
6
|
+
src = <<EOS
|
7
|
+
// !$*UTF8*$!
|
8
|
+
{
|
9
|
+
archiveVersion = 1;
|
10
|
+
classes = {
|
11
|
+
};
|
12
|
+
objectVersion = 46;
|
13
|
+
objects = {
|
14
|
+
|
15
|
+
/* Begin PBXBuildFile section */
|
16
|
+
1900A7F415A6DCB500DDA291 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 1900A7E015A6DCB500DDA291 /* AFHTTPClient.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
17
|
+
1900A7F515A6DCB500DDA291 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 1900A7E215A6DCB500DDA291 /* AFHTTPRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
18
|
+
1900A7F615A6DCB500DDA291 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 1900A7E415A6DCB500DDA291 /* AFImageRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
19
|
+
1900A7F715A6DCB500DDA291 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 1900A7E615A6DCB500DDA291 /* AFJSONRequestOperation.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
20
|
+
1900A7F815A6DCB500DDA291 /* AFJSONUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 1900A7E815A6DCB500DDA291 /* AFJSONUtilities.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
21
|
+
/* End PBXBuildFile section */
|
22
|
+
|
23
|
+
/* Begin PBXFileReference section */
|
24
|
+
19C7BC9D1679ECA000282DD7 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/SYViewController.xib; sourceTree = "<group>"; };
|
25
|
+
19C7BCA41679ECAE00282DD7 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
26
|
+
|
27
|
+
/* Begin PBXFrameworksBuildPhase section */
|
28
|
+
19C7BC7A1679ECA000282DD7 /* Frameworks */ = {
|
29
|
+
isa = PBXFrameworksBuildPhase;
|
30
|
+
buildActionMask = 2147483647;
|
31
|
+
files = (
|
32
|
+
19C7BC821679ECA000282DD7 /* UIKit.framework in Frameworks */,
|
33
|
+
19C7BC841679ECA000282DD7 /* Foundation.framework in Frameworks */,
|
34
|
+
19C7BC861679ECA000282DD7 /* CoreGraphics.framework in Frameworks */,
|
35
|
+
);
|
36
|
+
runOnlyForDeploymentPostprocessing = 0;
|
37
|
+
};
|
38
|
+
/* End PBXFrameworksBuildPhase section */
|
39
|
+
EOS
|
40
|
+
|
41
|
+
|
42
|
+
it "should add buildfile" do
|
43
|
+
ret = Modifier.add_build_files(src, "[buildfile]")
|
44
|
+
expected = <<EOS
|
45
|
+
/* Begin PBXBuildFile section */
|
46
|
+
[buildfile]
|
47
|
+
EOS
|
48
|
+
ret.index(expected).should_not be_nil
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should add fileref" do
|
52
|
+
ret = Modifier.add_file_ref(src, "[fileref]")
|
53
|
+
expected = <<EOS
|
54
|
+
/* Begin PBXFileReference section */
|
55
|
+
[fileref]
|
56
|
+
EOS
|
57
|
+
ret.index(expected).should_not be_nil
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should add framework build phase" do
|
61
|
+
ret = Modifier.add_framework_build_phase(src, "[framework]")
|
62
|
+
expected = <<EOS
|
63
|
+
isa = PBXFrameworksBuildPhase;
|
64
|
+
buildActionMask = 2147483647;
|
65
|
+
files = (
|
66
|
+
[framework]
|
67
|
+
EOS
|
68
|
+
end
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unigunkan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Designed for Unity based projects.
|
15
15
|
email:
|
@@ -26,8 +26,14 @@ files:
|
|
26
26
|
- Rakefile
|
27
27
|
- bin/unigunkan
|
28
28
|
- lib/unigunkan.rb
|
29
|
+
- lib/unigunkan/buildfile.rb
|
30
|
+
- lib/unigunkan/fileref.rb
|
31
|
+
- lib/unigunkan/modifier.rb
|
29
32
|
- lib/unigunkan/processor.rb
|
30
33
|
- lib/unigunkan/version.rb
|
34
|
+
- spec/models_spec.rb
|
35
|
+
- spec/project_spec.rb
|
36
|
+
- spec/spec_helper.rb
|
31
37
|
- unigunkan.gemspec
|
32
38
|
homepage: http://github.com/yokoe/unigunkan
|
33
39
|
licenses: []
|
@@ -49,8 +55,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
55
|
version: '0'
|
50
56
|
requirements: []
|
51
57
|
rubyforge_project:
|
52
|
-
rubygems_version: 1.8.
|
58
|
+
rubygems_version: 1.8.24
|
53
59
|
signing_key:
|
54
60
|
specification_version: 3
|
55
61
|
summary: A command line xcode project file modifier.
|
56
|
-
test_files:
|
62
|
+
test_files:
|
63
|
+
- spec/models_spec.rb
|
64
|
+
- spec/project_spec.rb
|
65
|
+
- spec/spec_helper.rb
|