carthframie 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4562cb1a36d516505584932e448f80a00f6adc31
4
+ data.tar.gz: 40244e8b7811e84c627556f8a007f21b97e96949
5
+ SHA512:
6
+ metadata.gz: 1aa4b0b70f3f0836a1b5b413696d6092a67af2d0907911fd1ece668c44cdf8a6fe2c909e78361ea88126f2452284fc79b9aea3f58f8b0edb5d8cb1c89dc85c66
7
+ data.tar.gz: 8a3cad61abd46388cbcf12675d4b478ca6e175d0e58fa7e1e8e22a37aa9c7ce0dc143a6b15e49f50b7e0ebc618c437bb5ae4aa7aa4f6ff6b626ea3f482961019
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5.0
6
+ before_install: gem install bundler -v 1.16.4
7
+
8
+ jobs:
9
+ include:
10
+ - name: "Building carthframie"
11
+ stage: compile
12
+ script: bundle exec rake build
13
+ - name: "Testing carthframie"
14
+ stage: test
15
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in carthframie.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ carthframie (0.1.0)
5
+ thor
6
+ xcodeproj
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ CFPropertyList (3.0.0)
12
+ atomos (0.1.3)
13
+ claide (1.0.2)
14
+ colored2 (3.1.2)
15
+ diff-lcs (1.3)
16
+ nanaimo (0.2.6)
17
+ rake (10.5.0)
18
+ rspec (3.8.0)
19
+ rspec-core (~> 3.8.0)
20
+ rspec-expectations (~> 3.8.0)
21
+ rspec-mocks (~> 3.8.0)
22
+ rspec-core (3.8.0)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-expectations (3.8.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.8.0)
27
+ rspec-mocks (3.8.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.8.0)
30
+ rspec-support (3.8.0)
31
+ thor (0.20.0)
32
+ xcodeproj (1.6.0)
33
+ CFPropertyList (>= 2.3.3, < 4.0)
34
+ atomos (~> 0.1.3)
35
+ claide (>= 1.0.2, < 2.0)
36
+ colored2 (~> 3.1)
37
+ nanaimo (~> 0.2.6)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ bundler (~> 1.16)
44
+ carthframie!
45
+ rake (~> 10.0)
46
+ rspec (~> 3.2)
47
+
48
+ BUNDLED WITH
49
+ 1.16.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Gergely Nemeth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Carthframie
2
+
3
+ Welcome to **carthframie**! **carthframie** is ruby gem which makes easier to use Carthage dependeny manager for iOS.
4
+ After ```carthage update``` use **carthframie**'s ```add_frameworks``` method to add the built frameworks to the project.
5
+
6
+ |CI |Status |
7
+ |--|--|
8
+ | Master | [![Build Status](https://travis-ci.org/ngergo100/carthframie.svg?branch=master)](https://travis-ci.org/ngergo100/carthframie)|
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'carthframie'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle update
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install carthframie
25
+
26
+ ## Usage
27
+
28
+ Use add_frameworks method. Provide .xcodeproj file and target name as parameters like below
29
+
30
+ $ carthframie add_frameworks Example.xcodeproj Example
31
+
32
+ Please note that you need to run add_frameworks in the project root directory. (Contains '.xcodeproj' and 'Carthage/Build')
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ngergo100/carthframie.
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/carthframie ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'carthframie'
4
+
5
+ Carthframie::Cli.start(ARGV)
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "carthframie/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "carthframie"
7
+ spec.version = Carthframie::VERSION
8
+ spec.authors = ["Gergely Nemeth"]
9
+ spec.email = ["ngergo100@gmail.com"]
10
+
11
+ spec.summary = %q{Carthage helper ruby gem}
12
+ spec.description = %q{Makes easy to use Carthage dependency manager}
13
+ spec.homepage = "https://github.com/ngergo100/carthframie"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "bin"
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency "thor"
26
+ spec.add_dependency "xcodeproj"
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.2"
30
+ end
@@ -0,0 +1,122 @@
1
+ require "carthframie/version"
2
+ require "xcodeproj"
3
+ require "thor"
4
+
5
+ module Carthframie
6
+
7
+ class CarthageCopyFrameworks
8
+
9
+ CARTHAGE_FRAMEWORKS_PATH = "Carthage/Build/**/*.framework"
10
+ COPY_CARTHAGE_BUILD_PHASE_NAME = "Copy Carthage frameworks"
11
+ COPY_CARTHAGE_BUILD_PHASE_SHELL_SCRIPT = "/usr/local/bin/carthage copy-frameworks"
12
+ SRCROOT = "$(SRCROOT)"
13
+ BUILT_PRODUCTS_DIR_FRAMEWORKS_FOLDER_PATH = "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)"
14
+
15
+ def initialize(project_path, choosen_target_name)
16
+ puts("ℹ️ Loading #{project_path}...")
17
+ @root = File.dirname(project_path)
18
+ @project = Xcodeproj::Project.open(project_path)
19
+ puts("🎉 #{project_path} has been successfully loaded.")
20
+
21
+ puts("ℹ️ Looking for #{choosen_target_name} target in your project...")
22
+ targets = @project.targets.select { |target| target.name == choosen_target_name }
23
+ if targets.count > 1 then
24
+ puts("⚠️ Multiple targets found with name '#{choosen_target_name}'. Loaded the first one. Please check your target configuration.")
25
+ elsif targets.count == 1 then
26
+ puts("🎉 #{choosen_target_name} has been successfully loaded.")
27
+ else
28
+ puts("❌ Did not find target with the given name. Exiting now...")
29
+ exit
30
+ end
31
+ @target = targets.first
32
+ end
33
+
34
+ ## Run function
35
+
36
+ def run
37
+ get_frameworks_built_by_carthage
38
+
39
+ remove_carthage_copy_frameworks_build_phase_if_needed
40
+
41
+ add_frameworks_to_frameworks_group_if_needed
42
+
43
+ add_new_copy_frameworks_build_phase
44
+
45
+ puts("ℹ️ Saving project...")
46
+ @project.save
47
+ puts("🎉 Project saved.")
48
+ end
49
+
50
+ ## Helper functions
51
+
52
+ def get_frameworks_built_by_carthage
53
+ puts("ℹ️ Looking for frameworks in your project...")
54
+ @framework_paths = Dir[CARTHAGE_FRAMEWORKS_PATH] # Finds '.framework' files recursively
55
+ if @framework_paths.count > 0 then
56
+ @framework_names = @framework_paths.map { |file| File.basename(file) }
57
+ puts("🎉 Found #{@framework_names.count} frameworks:\n - 📦 #{@framework_names.join("\n - 📦 ")}")
58
+ else
59
+ puts("❌️ Did not find any files with '.framework' extension. Exiting now...")
60
+ exit
61
+ end
62
+ end
63
+
64
+ def remove_carthage_copy_frameworks_build_phase_if_needed
65
+ puts("ℹ️ Checking existing build phases...")
66
+ carthage_build_phases = @target.shell_script_build_phases.select { |build_phase|
67
+ build_phase.shell_script.include? " copy-frameworks" and build_phase.name.include? "Carthage"
68
+ }
69
+ carthage_build_phases.each { |carthage_build_phase|
70
+ puts("⚠️ Removing existing build phase with name '#{carthage_build_phase.name}'...")
71
+ carthage_build_phase.remove_from_project
72
+ }
73
+ end
74
+
75
+ def add_frameworks_to_frameworks_group_if_needed
76
+ puts("ℹ️ Checking existing file references in the project...")
77
+ project_file_paths = @project.files.map { |file| file.path }
78
+ linked_frameworks_build_phase = @target.frameworks_build_phase.files_references.map { |file_reference| file_reference.path }
79
+ @framework_paths.each { |framework_path|
80
+ if !project_file_paths.include? framework_path then
81
+ new_reference = @project.new_file(framework_path)
82
+ new_reference.move(@project.frameworks_group)
83
+ puts("🎉 New file created at path: #{new_reference.path}")
84
+ else
85
+ puts("ℹ️ Framework at path '#{framework_path}' is already added to the project")
86
+ end
87
+
88
+ if !linked_frameworks_build_phase.include? framework_path then
89
+ existing_reference = @project.files.select { |file| file.path == framework_path }
90
+ if existing_reference.count > 0 then # By now framework should be added to the file references
91
+ @target.frameworks_build_phase.add_file_reference(existing_reference.first, true)
92
+ puts("🎉 New framework has sucessfully linked to the target")
93
+ else
94
+ puts("❌️ Some error happened during adding existing framework to your linked binearies phase, check your framework configurations!")
95
+ end
96
+
97
+ else
98
+ puts("ℹ️ Framework at path '#{framework_path}' is already linked to the target")
99
+ end
100
+ }
101
+ end
102
+
103
+ def add_new_copy_frameworks_build_phase
104
+ puts("ℹ️ Creating '#{COPY_CARTHAGE_BUILD_PHASE_NAME}' build phase...")
105
+ newBuildPhase = @target.new_shell_script_build_phase(COPY_CARTHAGE_BUILD_PHASE_NAME)
106
+ newBuildPhase.shell_script = COPY_CARTHAGE_BUILD_PHASE_SHELL_SCRIPT
107
+ newBuildPhase.input_paths = @framework_paths.map { |framework_path| "#{SRCROOT}/#{framework_path}" }
108
+ newBuildPhase.output_paths = @framework_names.map { |framework_name| "#{BUILT_PRODUCTS_DIR_FRAMEWORKS_FOLDER_PATH}/#{framework_name}" }
109
+ puts("🎉 Successfully added new copy build phase to #{@target.name} target.")
110
+ end
111
+
112
+ end
113
+
114
+ class Cli < Thor
115
+
116
+ desc 'add_frameworks Example.xcodeproj Example', 'Adds carthage framework to Example target of Example.xcodeproj'
117
+ def add_frameworks(project, target)
118
+ CarthageCopyFrameworks.new(project, target).run
119
+ end
120
+ end
121
+
122
+ end
@@ -0,0 +1,3 @@
1
+ module Carthframie
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carthframie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gergely Nemeth
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: xcodeproj
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.2'
83
+ description: Makes easy to use Carthage dependency manager
84
+ email:
85
+ - ngergo100@gmail.com
86
+ executables:
87
+ - carthframie
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/carthframie
100
+ - carthframie.gemspec
101
+ - lib/carthframie.rb
102
+ - lib/carthframie/version.rb
103
+ homepage: https://github.com/ngergo100/carthframie
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.5.2.3
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Carthage helper ruby gem
127
+ test_files: []