xcoder 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/spec/TestProject/TestProject.xcodeproj/project.pbxproj +801 -433
  2. data/spec/build_phase_spec.rb +1 -1
  3. data/spec/builder_spec.rb +54 -32
  4. data/spec/configuration_list_spec.rb +38 -0
  5. data/spec/configuration_spec.rb +5 -6
  6. data/spec/group_spec.rb +43 -32
  7. data/spec/integration/builder_spec.rb +60 -0
  8. data/spec/integration/cedar_install_spec.rb +107 -0
  9. data/spec/integration/pull_to_refresh_install_spec.rb +36 -0
  10. data/spec/integration/reachability_install_spec.rb +43 -0
  11. data/spec/keychain_spec.rb +2 -2
  12. data/spec/project_spec.rb +55 -6
  13. data/spec/scheme_spec.rb +1 -2
  14. data/spec/spec_helper.rb +2 -1
  15. data/spec/target_spec.rb +93 -3
  16. data/spec/test_report_spec.rb +2 -2
  17. data/spec/workspace_spec.rb +1 -2
  18. metadata +25 -48
  19. data/.gitignore +0 -7
  20. data/.rvmrc +0 -4
  21. data/Gemfile +0 -11
  22. data/Guardfile +0 -13
  23. data/README.md +0 -125
  24. data/Rakefile +0 -16
  25. data/lib/xcode/build_file.rb +0 -22
  26. data/lib/xcode/build_phase.rb +0 -46
  27. data/lib/xcode/builder.rb +0 -182
  28. data/lib/xcode/buildfile.rb +0 -101
  29. data/lib/xcode/configuration.rb +0 -129
  30. data/lib/xcode/core_ext/array.rb +0 -23
  31. data/lib/xcode/core_ext/boolean.rb +0 -21
  32. data/lib/xcode/core_ext/fixnum.rb +0 -5
  33. data/lib/xcode/core_ext/hash.rb +0 -27
  34. data/lib/xcode/core_ext/string.rb +0 -11
  35. data/lib/xcode/file_reference.rb +0 -29
  36. data/lib/xcode/group.rb +0 -118
  37. data/lib/xcode/info_plist.rb +0 -41
  38. data/lib/xcode/keychain.rb +0 -77
  39. data/lib/xcode/parsers/plutil_project_parser.rb +0 -20
  40. data/lib/xcode/project.rb +0 -190
  41. data/lib/xcode/provisioning_profile.rb +0 -53
  42. data/lib/xcode/registry.rb +0 -120
  43. data/lib/xcode/resource.rb +0 -187
  44. data/lib/xcode/scheme.rb +0 -36
  45. data/lib/xcode/shell.rb +0 -21
  46. data/lib/xcode/target.rb +0 -94
  47. data/lib/xcode/test/report_parser.rb +0 -172
  48. data/lib/xcode/testflight.rb +0 -56
  49. data/lib/xcode/variant_group.rb +0 -8
  50. data/lib/xcode/version.rb +0 -3
  51. data/lib/xcode/workspace.rb +0 -40
  52. data/lib/xcoder.rb +0 -105
  53. data/xcoder.gemspec +0 -26
@@ -32,7 +32,7 @@ describe Xcode::BuildPhase do
32
32
 
33
33
  describe "#add_build_file" do
34
34
  it "should add the specified file to the build phase" do
35
- source_file = project.groups.add_file 'NewFile.m'
35
+ source_file = project.groups.create_file 'NewFile.m'
36
36
  subject.add_build_file source_file
37
37
  subject.build_file('NewFile.m').should_not be_nil
38
38
  end
data/spec/builder_spec.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'rspec'
2
- require 'xcoder'
1
+ require_relative 'spec_helper'
3
2
 
4
3
  describe Xcode::Builder do
5
4
 
@@ -11,21 +10,6 @@ describe Xcode::Builder do
11
10
 
12
11
  describe "#build" do
13
12
 
14
- it "should be able to build" do
15
- subject.clean
16
- subject.build
17
- File.exists?(subject.app_path).should==true
18
- File.exists?(subject.dsym_path).should==true
19
- end
20
-
21
- it "should be able to package" do
22
- subject.clean
23
- subject.build
24
- subject.package
25
- File.exists?(subject.dsym_zip_path).should==true
26
- File.exists?(subject.ipa_path).should==true
27
- end
28
-
29
13
  let(:default_build_parameters) do
30
14
  [ "xcodebuild",
31
15
  "-sdk #{configuration.target.project.sdk}",
@@ -42,6 +26,59 @@ describe Xcode::Builder do
42
26
  end
43
27
 
44
28
  end
29
+
30
+ describe "#testflight" do
31
+
32
+ let(:testflight_parameters) do
33
+ ['curl',
34
+ "--proxy http://proxyhost:8080",
35
+ "-X POST http://testflightapp.com/api/builds.json",
36
+ "-F file=@\"#{subject.ipa_path}\"",
37
+ "-F dsym=@\"#{subject.dsym_zip_path}\"",
38
+ "-F api_token='api_token'",
39
+ "-F team_token='team_token'",
40
+ "-F notes=\"some notes\"",
41
+ "-F notify=True",
42
+ "-F distribution_lists='List1,List2'"]
43
+ end
44
+
45
+ it "should upload ipa and dsym to testflight" do
46
+ Xcode::Shell.should_receive(:execute).with(testflight_parameters).and_return(['{}'])
47
+
48
+ subject.testflight("api_token", "team_token") do |tf|
49
+ tf.proxy = "http://proxyhost:8080"
50
+ tf.notes = "some notes"
51
+ tf.lists << "List1"
52
+ tf.lists << "List2"
53
+ end
54
+
55
+ end
56
+ end
57
+
58
+ describe "#test" do
59
+
60
+ let(:configuration) do
61
+ Xcode.project('TestProject').target('TestProjectTests').config('Debug')
62
+ end
63
+
64
+ let(:default_test_parameters) do
65
+ [ "xcodebuild",
66
+ "-sdk iphonesimulator",
67
+ "-project \"#{configuration.target.project.path}\"",
68
+ "-target \"#{configuration.target.name}\"",
69
+ "-configuration \"#{configuration.name}\"",
70
+ "OBJROOT=\"#{File.dirname(configuration.target.project.path)}/build/\"",
71
+ "SYMROOT=\"#{File.dirname(configuration.target.project.path)}/build/\"",
72
+ "TEST_AFTER_BUILD=YES",
73
+ "TEST_HOST=''",]
74
+ end
75
+
76
+ it "should be able to run the test target" do
77
+ Xcode::Shell.should_receive(:execute).with(default_test_parameters, false)
78
+ subject.test
79
+ end
80
+
81
+ end
45
82
 
46
83
  describe "#clean" do
47
84
 
@@ -73,21 +110,6 @@ describe Xcode::Builder do
73
110
 
74
111
  describe "#build" do
75
112
 
76
- it "should be able to build" do
77
- subject.clean
78
- subject.build
79
- File.exists?(subject.app_path).should==true
80
- File.exists?(subject.dsym_path).should==true
81
- end
82
-
83
- it "should be able to package" do
84
- subject.clean
85
- subject.build
86
- subject.package
87
- File.exists?(subject.dsym_zip_path).should==true
88
- File.exists?(subject.ipa_path).should==true
89
- end
90
-
91
113
  let(:default_build_parameters) do
92
114
  [ "xcodebuild",
93
115
  "-sdk iphoneos",
@@ -0,0 +1,38 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Xcode::ConfigurationList do
4
+
5
+ let(:project) { Xcode.project 'TestProject' }
6
+ let(:subject) { project.create_target('ConfigCreateTarget').build_configuration_list }
7
+
8
+ describe "#configs" do
9
+ it "should return all the configurations" do
10
+ subject.build_configurations.count.should == 0
11
+ end
12
+ end
13
+
14
+ describe "#create_config" do
15
+ it "should add additional config" do
16
+ subject.create_config('Debug2ElectricBoogaloo').should_not be_nil
17
+ end
18
+ end
19
+
20
+ describe "#default_config" do
21
+ context "when no default configuration has been specified" do
22
+ it "should return a nil" do
23
+ subject.default_config.should be_nil
24
+ end
25
+ end
26
+
27
+ context "when a default configuration has been set" do
28
+ it "it should return that configuration" do
29
+ new_config = subject.create_config('Debug2ElectricBoogaloo')
30
+ subject.set_default_config new_config.name
31
+ subject.default_config_name.should == new_config.name
32
+ subject.default_config.identifier.should == new_config.identifier
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -1,5 +1,4 @@
1
- require 'rspec'
2
- require 'xcoder'
1
+ require_relative 'spec_helper'
3
2
 
4
3
  describe Xcode::Configuration do
5
4
 
@@ -40,15 +39,15 @@ describe Xcode::Configuration do
40
39
  end
41
40
  end
42
41
 
43
- describe "#buildSettings" do
42
+ describe "#build_settings" do
44
43
  it "should return a hash of build settings" do
45
- subject.buildSettings.should_not
44
+ subject.build_settings.should_not
46
45
  end
47
46
  end
48
47
 
49
48
  describe "#set" do
50
49
 
51
- let(:settings) { subject.buildSettings }
50
+ let(:settings) { subject.build_settings }
52
51
 
53
52
  it "should set a value in the build configuration" do
54
53
  subject.set 'KEY', 'VALUE'
@@ -65,7 +64,7 @@ describe Xcode::Configuration do
65
64
 
66
65
  describe "#get" do
67
66
 
68
- let(:settings) { subject.buildSettings }
67
+ let(:settings) { subject.build_settings }
69
68
 
70
69
  it "should return the correct configuration value" do
71
70
  subject.get('OTHER_LDFLAGS').should == settings['OTHER_LDFLAGS']
data/spec/group_spec.rb CHANGED
@@ -1,27 +1,27 @@
1
- require 'rspec'
2
- require 'xcoder'
1
+ require_relative 'spec_helper'
3
2
 
4
3
  describe Xcode::Group do
5
-
6
- let(:subject) { Xcode.project('TestProject').groups }
4
+
5
+ let(:project) { Xcode.project('TestProject') }
6
+ let(:subject) { project.groups }
7
7
 
8
8
  describe "#groups" do
9
9
  context "when a group matches the name specified" do
10
10
  it "should return the group" do
11
- subject.add_group('TestGroup')
11
+ subject.create_group('TestGroup')
12
12
  subject.group('TestGroup').should_not be_nil
13
13
  end
14
14
  end
15
15
 
16
16
  context "when multiple groups match the name specified" do
17
17
  it "should return all the matching groups" do
18
- subject.add_group('TestGroup')
18
+ subject.create_group('TestGroup')
19
19
  subject.group('TestGroup').length.should == 2
20
20
  end
21
21
  end
22
22
 
23
23
  context "when a group does not match the name specified" do
24
- it "should return an e" do
24
+ it "should return an empty array" do
25
25
  subject.group('UnknownGroup').should be_empty
26
26
  end
27
27
  end
@@ -29,19 +29,19 @@ describe Xcode::Group do
29
29
 
30
30
  describe "#supergroup" do
31
31
  it "should return the owning group" do
32
- group = subject.add_group('Superman')
32
+ group = subject.create_group('Superman')
33
33
  group.supergroup.identifier.should == subject.identifier
34
34
  end
35
35
  end
36
36
 
37
37
  describe "#add_group" do
38
38
  it "should return the group" do
39
- subject.add_group('TestGroup').should_not be_nil
39
+ subject.create_group('TestGroup').should_not be_nil
40
40
  end
41
41
 
42
42
  context "when adding a group within a group" do
43
43
  it "should successfully create the subgroup" do
44
- subgroup = subject.add_group('GroupWithSubGroup').add_group('Group MED')
44
+ subgroup = subject.create_group('GroupWithSubGroup').create_group('Group MED')
45
45
 
46
46
  found_subgroup = subject.group('GroupWithSubGroup').first.group('Group MED').first
47
47
  subgroup.should_not be_nil
@@ -51,30 +51,41 @@ describe Xcode::Group do
51
51
  end
52
52
  end
53
53
 
54
- context "when saving to file" do
55
- it "should save the group to the file" do
56
-
57
- # subject.groups.add_group 'TestGroup'
58
- # framework = subject.groups.add_framework 'QuartzCore'
59
- #
60
- # # subject.target('TestProject').framework_build_phase.add_file framework
61
- #
62
- # subject.targets.each do |target|
63
- #
64
- # target.framework_build_phase.add_build_file framework
65
- #
66
- # # target.configs.each do |config|
67
- # # config.set_other_linker_flags '-ObjC'
68
- # # end
69
- # end
70
- #
71
- # subject.save!
72
-
54
+ end
55
+
56
+ describe "Files" do
57
+ let(:subject) { project.groups.group('TestProject').first }
58
+
59
+ describe "#files" do
60
+ it "should return the correct number of files within the group" do
61
+ subject.files.count.should == 2
62
+ end
63
+ end
64
+
65
+ describe "#file" do
66
+ it "should return the files that match" do
67
+ subject.file('AppDelegate.m').should_not be_empty
73
68
  end
74
-
75
-
76
69
  end
70
+
71
+ describe "#create_file" do
77
72
 
73
+ let(:new_file_params) { {'name' => 'NewFile.m', 'path' => 'NewFile.m'} }
74
+
75
+ before(:each) do
76
+ subject.create_file new_file_params
77
+ end
78
+
79
+ it "should create the files within the group" do
80
+ subject.file(new_file_params['name']).should_not be_empty
81
+ end
82
+
83
+ it "should not duplicate the file within the group" do
84
+ subject.create_file new_file_params
85
+ subject.file(new_file_params['name']).count.should == 1
86
+ end
87
+ end
88
+
78
89
  end
79
-
90
+
80
91
  end
@@ -0,0 +1,60 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Xcode::Builder, :integration => true do
4
+
5
+ context "when using a builder built from a configuration" do
6
+
7
+ let(:configuration) { Xcode.project('TestProject').target('TestProject').config('Debug') }
8
+
9
+ let(:subject) { configuration.builder }
10
+
11
+ describe "#build" do
12
+
13
+
14
+ it "should be able to build" do
15
+ subject.clean
16
+ subject.build
17
+ File.exists?(subject.app_path).should==true
18
+ File.exists?(subject.dsym_path).should==true
19
+ end
20
+
21
+ it "should be able to package" do
22
+ subject.clean
23
+ subject.build
24
+ subject.package
25
+ File.exists?(subject.dsym_zip_path).should==true
26
+ File.exists?(subject.ipa_path).should==true
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ context "when using a builder built from a scheme" do
34
+
35
+ let(:scheme) { Xcode.project('TestProject').scheme('TestProject') }
36
+
37
+ let(:subject) { scheme.builder }
38
+
39
+ describe "#build" do
40
+
41
+ it "should be able to build" do
42
+ subject.clean
43
+ subject.build
44
+ File.exists?(subject.app_path).should==true
45
+ File.exists?(subject.dsym_path).should==true
46
+ end
47
+
48
+ it "should be able to package" do
49
+ subject.clean
50
+ subject.build
51
+ subject.package
52
+ File.exists?(subject.dsym_zip_path).should==true
53
+ File.exists?(subject.ipa_path).should==true
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,107 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe "Cedar", :integration => true do
4
+
5
+ let(:project) { Xcode.project 'TestProject' }
6
+
7
+ it "should update a project with a working installation of Cedar" do
8
+
9
+ # Copy the files necessary for the project to the correct destination
10
+
11
+ FileUtils.cp_r "examples/Cedar/Vendor", "spec/TestProject"
12
+ FileUtils.cp_r "examples/Cedar/Specs", "spec/TestProject"
13
+
14
+ #
15
+ # The following block of code will generate the target with all the neccessary
16
+ # parameters and properties to get a full working 'Cedar' spec to build.
17
+ #
18
+
19
+ project.create_target 'Specs' do |target|
20
+
21
+ target.name = 'Specs'
22
+ target.product_name = 'Specs'
23
+
24
+ # @todo create the following files within the project file
25
+
26
+ # E21EB9D614E357CF0058122A /* Specs.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Specs.app; sourceTree = BUILT_PRODUCTS_DIR; };
27
+ # Adding an application needs to set the productReference in the target
28
+ # productReference = E21EB9D614E357CF0058122A /* Specs.app */;
29
+
30
+ application_file = target.create_product_reference 'Specs'
31
+
32
+ # Create the Specs group
33
+
34
+ specs_group = project.groups.create_group('Specs')
35
+ supporting_group = specs_group.create_group('Supporting Files')
36
+
37
+
38
+ # E21EB9E114E357CF0058122A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
39
+ main_source = supporting_group.create_file 'name' => 'main.m', 'path' => 'Specs/main.m'
40
+
41
+ target.create_build_phase :sources do |source|
42
+ source.add_build_file main_source
43
+ end
44
+
45
+ # E21EB9DD14E357CF0058122A /* Specs-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Specs-Info.plist"; sourceTree = "<group>"; };
46
+
47
+ supporting_group.create_file 'name' => 'Specs-Info.plist', 'path' => 'Specs/Specs-Info.plist'
48
+
49
+ # E2B8B9F214E395B400D08897 /* InfoPlist.strings */ = {
50
+ # isa = PBXVariantGroup;
51
+ # children = (
52
+ # E2B8B9F314E395B400D08897 /* en */,
53
+ # );
54
+ # name = InfoPlist.strings;
55
+ # path = Specs/en.lproj;
56
+ # sourceTree = "<group>";
57
+ # };
58
+
59
+ infoplist_file = supporting_group.create_infoplist 'name' => 'InfoPlist.strings', 'path' => 'Specs'
60
+ infoplist_file.create_file 'name' => 'en', 'path' => 'en.lproj/InfoPlist.strings'
61
+
62
+ # E21EB9DF14E357CF0058122A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
63
+ # infofile = supporting_group.create_file 'name' => 'en', 'path' => 'en.lproj/InfoPlist.strings'
64
+
65
+ target.create_build_phase :resources do |resources|
66
+ resources.add_build_file infoplist_file
67
+ end
68
+
69
+ # E21EB9E314E357CF0058122A /* Specs-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Specs-Prefix.pch"; sourceTree = "<group>"; };
70
+ prefix_file = supporting_group.create_file 'name' => 'Specs-Prefix.pch', 'path' => 'Specs/Specs-Prefix.pch'
71
+
72
+ # E21EB9D814E357CF0058122A /* UIKit.framework in Frameworks */,
73
+ # 7165D454146B4EA100DE2F0E /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
74
+ # E21EB9D914E357CF0058122A /* Foundation.framework in Frameworks */,
75
+ # E21EB9DA14E357CF0058122A /* CoreGraphics.framework in Frameworks */,
76
+
77
+ # E21EB9EE14E359840058122A /* Cedar-iPhone.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "Cedar-iPhone.framework"; path = "Vendor/Frameworks/Cedar-iPhone.framework"; sourceTree = "<group>"; };
78
+ cedar_framework = target.project.frameworks_group.create_framework 'name' => 'Cedar-iPhone.framework', 'path' => 'Vendor/Frameworks/Cedar-iPhone.framework', 'sourceTree' => '<group>'
79
+
80
+ # @todo this is dumb to have the first being called. There must be a more clear way
81
+
82
+ target.create_build_phase :framework do |frameworks|
83
+ frameworks.add_build_file cedar_framework
84
+ frameworks.add_build_file target.project.frameworks_group.file('UIKit.framework').first
85
+ frameworks.add_build_file target.project.frameworks_group.file('Foundation.framework').first
86
+ frameworks.add_build_file target.project.frameworks_group.file('CoreGraphics.framework').first
87
+ end
88
+
89
+ target.create_configurations :debug, :release do |config|
90
+ config.set 'GCC_PREFIX_HEADER', 'Specs/Specs-Prefix.pch'
91
+ config.set 'INFOPLIST_FILE', 'Specs/Specs-Info.plist'
92
+ config.set 'OTHER_LDFLAGS', '-ObjC -all_load -lstdc++'
93
+ config.set 'FRAMEWORK_SEARCH_PATHS', [ "$(inherited)", "\"$(SRCROOT)/Vendor/Frameworks\"" ]
94
+ config.save!
95
+ end
96
+
97
+ end
98
+
99
+ project.save!
100
+
101
+ expect { project.target('Specs').config('Debug').builder.build }.to_not raise_error
102
+
103
+ project.save!
104
+
105
+ end
106
+
107
+ end