xcode-pristine 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c3685f9694353ee8a8432c0df3a7b03fa8a2c0de
4
+ data.tar.gz: 30eb62bea3152f927e8339a88242553c6f2a740b
5
+ SHA512:
6
+ metadata.gz: 94956bd081dd523ac03d1a9c31ac85b891d890b678eab75ad99a87daca9684a0805e2b6b317e63611b23627c0ae0433e1be5d8a90c57c0984c4741714d722116
7
+ data.tar.gz: 6941d230e617c8d9afab23c7a5e0326fe0a1ea878716672660e59bbdf6743d6868b529d834d0ee9d63ec14f52f15d4e056e25ecfec2cb098fbcd448aa3284174
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ # Ruby
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
14
+
15
+ # Xcode
16
+ *.xcodeproj/*
17
+ !*.xcodeproj/project.pbxproj
18
+ !*.xcodeproj/xcshareddata/
19
+ !*.xcworkspace/contents.xcworkspacedata
20
+ /*.gcno
21
+ xcuserdata/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.0
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ sudo: false
2
+ language: ruby
3
+ os: osx
4
+ cache: bundler
5
+ before_install:
6
+ - gem install bundler -v 1.15.0
7
+ install:
8
+ - bundle install --path vendor/bundle
9
+ script:
10
+ - bundle exec rake spec
11
+ deploy:
12
+ provider: rubygems
13
+ api_key:
14
+ secure: K6pfF/p4eWhSKwqMGkFb1dlYA3f3i4OMr6zJS2fVRvQm3XpmH803fQanzJKY8VkAxKKE4IjfUH/sDXqXvJi2doBLBtl2q3BG3pdY9vGW6Kfv6hgJGoKpOkLNhme/N5bwY7fAnW19MD97e/3E1TUG2qpLsUwaT+Y1hnlahUayk5zPQ8GwbviPH34/5c//1FKZEkJYrM33l3Fd2E3x4+zn6eK3oU1oBxUuDdluQ0GKZU+HlbXQhIVO0SlEk4dCy7DMJoFX5NtqjfwfVV6yx0k0mwwI8VXoXAqiCeyM/Ea9EtFkcmaWlOI7uXJaOonLHAZFaIxEtvBME9g4DNauGxzbvzeHsFAkRBjpXE99jj3PHfcVeUWgIQUFCnIsjKDZQAGa0+BP3iQAvo9FOyeSCNsqdstNQ96c9sCy/c+SC5np48v2irB4Sw19hsurQf5uzD/1mKhnqJgLksPnSmKlaylLvfjXcc+cf/ngicMwt8JolFPy3OrMauuocz+5RD0/3gMWOiqc/rGOW8CxbS8fmcOYlObxrfn1G63CMwUfZJfHuBRweveILYVsk8gWYsejsPZzNHi+GddKoSsc+O9MeGbTBrmjVknN4jxYW/1tk8ZSCciKhQHTE26v/Uz38D+z1ILOeDzRPZ3YB1G2TYaGwaq01X0aqHGa/NclkoKeZnLorfM=
15
+ gem: xcode-pristine
16
+ on:
17
+ tags: true
18
+ repo: sgleadow/xcode-pristine
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in xcode-pristine.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Stewart Gleadow
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,45 @@
1
+ # xcode-pristiene (Work In Progress) [![Build Status](https://travis-ci.org/sgleadow/xcode-pristine.svg?branch=master)](https://travis-ci.org/sgleadow/xcode-pristine)
2
+
3
+ A gem to help keep your Xcode project file pristine.
4
+
5
+ When you're using `xcconfig` files to manage your Xcode build settings, you don't want those build settings being overridded inside the Xcode project files build settings editor. This gem used the [xcodeproj gem](https://github.com/CocoaPods/Xcodeproj) from cocoapods, to inspect the build settings in the project file and ensure they're empty.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'xcode-pristine'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install xcode-pristine
22
+
23
+ ## Usage
24
+
25
+ To ensure your project file is free of unwanted build settings, simply run:
26
+
27
+ $ xcpristine
28
+
29
+ By default, it finds any `.xcodeproj` files in the current directory and inspects _all build configurations_ and _all targets_.
30
+
31
+ There may be situations where you want to only inspect _some project files_ or _not all of the configurations or targets for a project_. If that's the case, raise an issue and let's discuss how to add it, I haven't found a need for that yet, as either your project is using xcconfig files or it isn't.
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sgleadow/xcode-pristine.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](http://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/exe/xcpristine ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path("../lib")
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'xcode_pristine'
6
+
7
+ result = XcodePristine::Runner.run ARGV
8
+ exit result
@@ -0,0 +1,30 @@
1
+
2
+ module XcodePristine
3
+ class Checker
4
+ def initialize(xcodeproj)
5
+ @project = xcodeproj
6
+ end
7
+
8
+ def project_name
9
+
10
+ end
11
+
12
+ def has_build_settings?
13
+ !message.empty?
14
+ end
15
+
16
+ def message indent = ""
17
+ messages.map { |msg| indent + msg }.join("\n")
18
+ end
19
+
20
+ def messages
21
+ messages = []
22
+
23
+ messages += @project.build_configurations.map { |config| config.build_settings.map { |k,v| "#{config.name}: #{k}=#{v}" } }.flatten
24
+ messages += @project.targets.map { |target| target.build_configurations.map { |config| config.build_settings.map { |k,v| "#{target.name}, #{config.name}: #{k}=#{v}" } }.flatten }.flatten
25
+
26
+ messages
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,50 @@
1
+ require 'xcodeproj'
2
+
3
+ module XcodePristine
4
+ class ProjectFinder
5
+ attr_reader :projects
6
+
7
+ def initialize args
8
+ @projects = args.map do |path|
9
+ workspaces = Dir.glob(File.join(path, '*.xcworkspace'))
10
+ projects = Dir.glob(File.join(path, '*.xcodeproj'))
11
+
12
+ if path.end_with? "xcworkspace"
13
+ projects_from_workspace path
14
+ elsif path.end_with? "xcodeproj"
15
+ project_from_file path
16
+ elsif workspaces.empty?
17
+ projects_from_files(projects)
18
+ else
19
+ projects_from_workspace_files(workspaces)
20
+ end
21
+ end.flatten
22
+ end
23
+
24
+ def project_from_file project_file
25
+ Xcodeproj::Project.open(project_file)
26
+ end
27
+
28
+ def projects_from_files files
29
+ files.map do |project_file|
30
+ project_from_file(project_file)
31
+ end
32
+ end
33
+
34
+ def projects_from_workspace workspace_file
35
+ workspace = Xcodeproj::Workspace.new_from_xcworkspace(workspace_file)
36
+ workspace.file_references.select do |file_reference|
37
+ file_reference.path.end_with? 'xcodeproj'
38
+ end.map do |project_file_reference|
39
+ project_file = File.join(workspace_file, '..', project_file_reference.path)
40
+ project_from_file(project_file)
41
+ end
42
+ end
43
+
44
+ def projects_from_workspace_files workspaces
45
+ workspaces.map do |workspace_file|
46
+ projects_from_workspace(workspace_file)
47
+ end.flatten
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ module XcodePristine
2
+ module Version
3
+ CURRENT = "0.1.2"
4
+ end
5
+ end
@@ -0,0 +1,67 @@
1
+ require 'xcodeproj'
2
+
3
+ require "xcode_pristine/version"
4
+ require "xcode_pristine/checker"
5
+ require "xcode_pristine/project_finder"
6
+
7
+ module XcodePristine
8
+ class Runner
9
+ def self.run args
10
+ finder = ProjectFinder.new args
11
+
12
+ projects = finder.projects.map do |xcodeproj|
13
+ Checker.new(xcodeproj)
14
+ end
15
+
16
+ if projects.empty?
17
+ puts USAGE_MESSAGE
18
+ return Status::USAGE
19
+ end
20
+
21
+ projects.each do |checker|
22
+ puts "Project..."
23
+
24
+ if checker.has_build_settings?
25
+ indent = " "
26
+ puts checker.message indent
27
+ puts "Project... Failed."
28
+ else
29
+ puts "Project... OK."
30
+ end
31
+ end
32
+
33
+ if projects.any? { |checker| checker.has_build_settings? }
34
+ return Status::SETTINGS
35
+ else
36
+ return Status::OK
37
+ end
38
+ end
39
+
40
+ USAGE_MESSAGE = <<-END_OUTPUT
41
+ Error: could not find any projects or workspaces to check from the arguments passed to xcpristine.
42
+
43
+ Usage:
44
+ xcpristine <path 1> <path 2> ... <path N>
45
+
46
+ Where each path can be one of:
47
+
48
+ an Xcode project
49
+ the path to a .xcodeproj, eg. ./path/to/Example.xcodeproj
50
+ (checks that project for build settings)
51
+
52
+ an Xcode workspace
53
+ the path to a .xcworkspace, eg. ./path/to/Example.xcworkspace
54
+ (checks each top level Xcode project file in the workspace for build settings)
55
+
56
+ a directory
57
+ the path to a directory containing .xcodeproj or .xcworkspace files
58
+ (if found, checks the workspace, otherwise, checks the project)
59
+ END_OUTPUT
60
+ end
61
+
62
+ class Status
63
+ OK = 0
64
+ USAGE = 1
65
+ SETTINGS = 2
66
+ end
67
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "xcode_pristine/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "xcode-pristine"
8
+ spec.version = XcodePristine::Version::CURRENT
9
+ spec.authors = ["Stewart Gleadow"]
10
+ spec.email = ["sgleadow@gmail.com"]
11
+
12
+ spec.summary = %q{Ensure your Xcode project is clean of any unwanted build settings.}
13
+ spec.description = %q{When using xcconfig files to manage Xcode project build settings, you want to make sure your Xcode project doesn't override any of those build settings in the project file. This gem uses the xcodeproj gem to read the project file and check there aren't any unwanted build settings that can creep in by accident.}
14
+ spec.homepage = "https://github.com/sgleadow/xcode-pristine"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency "xcodeproj", "~> 1.5"
27
+ spec.add_development_dependency "bundler", "~> 1.15"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xcode-pristine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Stewart Gleadow
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-10-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xcodeproj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: When using xcconfig files to manage Xcode project build settings, you
70
+ want to make sure your Xcode project doesn't override any of those build settings
71
+ in the project file. This gem uses the xcodeproj gem to read the project file and
72
+ check there aren't any unwanted build settings that can creep in by accident.
73
+ email:
74
+ - sgleadow@gmail.com
75
+ executables:
76
+ - xcpristine
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - .gitignore
81
+ - .rspec
82
+ - .ruby-version
83
+ - .travis.yml
84
+ - Gemfile
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - exe/xcpristine
89
+ - lib/xcode_pristine.rb
90
+ - lib/xcode_pristine/checker.rb
91
+ - lib/xcode_pristine/project_finder.rb
92
+ - lib/xcode_pristine/version.rb
93
+ - xcode-pristine.gemspec
94
+ homepage: https://github.com/sgleadow/xcode-pristine
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.6.12
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Ensure your Xcode project is clean of any unwanted build settings.
118
+ test_files: []