spm_utils 0.0.1
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 +7 -0
- data/.gitignore +3 -0
- data/LICENSE +19 -0
- data/README.md +47 -0
- data/bin/spm_utils +23 -0
- data/lib/command/clean_project_command.rb +6 -0
- data/lib/command/fix_quick_command.rb +6 -0
- data/lib/command/inhibit_all_warnings_command.rb +10 -0
- data/lib/command/swift_version_command.rb +17 -0
- data/lib/project_mod.rb +57 -0
- data/lib/version.rb +3 -0
- data/spm_utils.gemspec +18 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b4ce02f74f991372beab1718fed4fde916a14e1b
|
4
|
+
data.tar.gz: 8de90016785062102c144b6bd889e43c3a66c9fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4f4c7f38bead6aafef00233b1bc7bbd5ffcb9ce1e1a3e9a9bacad26c46404d81061db8b858989b029a5a65c5b9574718d6d77e0a160c181b63c54ee4a4fc816
|
7
|
+
data.tar.gz: 38c935bdd9d180c9e3025b7961e410ab6eeedff3d97f3688bd0a66be1b58e5d7a6665a524fa219abb3f2dedbddcd062ea735390c10688420514a88d9b39e0209
|
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2017 Łukasz Mróz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# SPM fixers
|
2
|
+
Hey there! This is my repo for a bunch of fixers for SPM. All of this is mostly work in progress and written in Ruby.
|
3
|
+
Which means this is probably not the best code you'll see these days and I recommend you to do a **backup/commit before using this scripts**.
|
4
|
+
These were not tested on many projects yet, so please bear in mind that this is really experimental.
|
5
|
+
Fortunately, I accept PRs to fix anything you see that is wrong! I will be really grateful for that, actually.
|
6
|
+
|
7
|
+
## Before you use the script:
|
8
|
+
1. Go to your SPM project.
|
9
|
+
1. Backup/commit your files.
|
10
|
+
1. Clean your project if needed.
|
11
|
+
1. Run `swift build & swift package generate-xcodeproj` (make sure it passes)
|
12
|
+
1. Install this gem using `gem install spm_fixers`
|
13
|
+
|
14
|
+
## Cleaning your project
|
15
|
+
Whenever something goes wrong with building/caching/resolving, try cleaning your project:
|
16
|
+
`swift package clean && rm -rf .build && rm Package.resolved`
|
17
|
+
|
18
|
+
## Quick fixer
|
19
|
+
See issue [Quick#751](https://github.com/Quick/Quick/issues/751) and PR [swift-package-manager#955](https://github.com/apple/swift-package-manager/pull/955). TL;DR because of SPM, Quick can't set `CLANG_ENABLE_MODULES` by itself.
|
20
|
+
This script does it for you.
|
21
|
+
|
22
|
+
Steps:
|
23
|
+
1. Make sure to follow the [Before you use the script](#before-you-use-the-script) guide.
|
24
|
+
1. Run `spm_fixers quick`.
|
25
|
+
1. If everything goes correcly, your project should be fixed!
|
26
|
+
|
27
|
+
## Swift4All - update all your dependencies to Swift 4
|
28
|
+
By running `swift build & swift package generate-xcodeproj` you don't necessarily get all your dependencies built with Swift 4 (see [SR-5940](https://bugs.swift.org/browse/SR-5940)). This script fixes that for you. You might want want to use my fork of Quick as Swift 4 is currently
|
29
|
+
broken, but [PR#755](https://github.com/Quick/Quick/pull/755) is waiting for the merge :)
|
30
|
+
|
31
|
+
```swift
|
32
|
+
.package(url: "https://github.com/sunshinejr/Quick.git", .branch("fix/spm_swift4"))
|
33
|
+
```
|
34
|
+
|
35
|
+
Steps:
|
36
|
+
1. Go to your SPM project.
|
37
|
+
1. Clean your packages by using `swift package clean`
|
38
|
+
1. Run `swift build & swift package generate-xcodeproj` (make sure it passes)
|
39
|
+
1. Run `gem install xcodeproj` to install additional library for our scrip.
|
40
|
+
1. Run `ruby path/to/spm_swift4all.rb` to update your Xcodeproj.
|
41
|
+
1. If everything goes correcly, you should have your project updated.
|
42
|
+
|
43
|
+
## [WIP] Inhibit deps warnings - Basically `CocoaPods'` `inhibit_all_warnings` copy.
|
44
|
+
This currently does not work, but it would be awesome to have it working sometime in future.
|
45
|
+
|
46
|
+
# License
|
47
|
+
[MIT](https://github.com/sunshinejr/spm_fixers/blob/master/LICENSE).
|
data/bin/spm_utils
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'clamp'
|
4
|
+
require_relative '../lib/project_mod'
|
5
|
+
require_relative '../lib/command/fix_quick_command'
|
6
|
+
require_relative '../lib/command/swift_version_command'
|
7
|
+
require_relative '../lib/command/inhibit_all_warnings_command'
|
8
|
+
require_relative '../lib/command/clean_project_command'
|
9
|
+
require_relative '../lib/version'
|
10
|
+
|
11
|
+
class MainCommand < Clamp::Command
|
12
|
+
subcommand 'quick', 'Fix Quick\'s problem with SPM until it\'s resolved. See: https://github.com/Quick/Quick/issues/751', FixQuickCommand
|
13
|
+
subcommand 'swift', 'Change Swift version of a target/targets', SwiftVersionCommand
|
14
|
+
subcommand 'inhibit_all_warnings', 'Inhibit all warninigs in a target/targets', InhibitAllWarningsCommand
|
15
|
+
subcommand 'clean_project', 'Remove .build dir, Package.resolved & packages cache', CleanProjectCommand
|
16
|
+
|
17
|
+
option "--version", :flag, "Show version" do
|
18
|
+
puts SPMFixers::VERSION
|
19
|
+
exit(0)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
MainCommand.run
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class InhibitAllWarningsCommand < Clamp::Command
|
2
|
+
option ['--target'], 'TARGET', 'Target name', :multivalued => true
|
3
|
+
|
4
|
+
def execute
|
5
|
+
ProjectMod.append_or_apply_build_setting(name: 'OTHER_SWIFT_FLAGS', value: "-suppress-warnings", target_names: target_list)
|
6
|
+
|
7
|
+
targets_string = target_list.empty? ? 'All targets' : (target_list.join(", ") + " targets")
|
8
|
+
puts "#{targets_string} have inhibited warnings now!"
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class SwiftVersionCommand < Clamp::Command
|
2
|
+
parameter "VERSION", "version", :attribute_name => :swift_version
|
3
|
+
option ['--target'], 'TARGET', 'Target name', :multivalued => true
|
4
|
+
# option ['--swift-version'], 'SWIFT_VERSION', 'What Swift version to change into', :required => true
|
5
|
+
|
6
|
+
def execute
|
7
|
+
supported_swift_versions = ['3', '4']
|
8
|
+
if !supported_swift_versions.include? swift_version
|
9
|
+
signal_usage_error "'#{swift_version}' swift version is not supported. Supported values: " + supported_swift_versions.map { |v| "'#{v}'" }.join(", ")
|
10
|
+
end
|
11
|
+
|
12
|
+
ProjectMod.apply_build_setting(name: 'SWIFT_VERSION', value: "#{swift_version}.0", target_names: target_list)
|
13
|
+
|
14
|
+
targets_string = target_list.empty? ? 'All targets' : (target_list.join(", ") + " targets")
|
15
|
+
puts "#{targets_string} were updated to use Swift #{swift_version}!"
|
16
|
+
end
|
17
|
+
end
|
data/lib/project_mod.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
|
3
|
+
class ProjectMod
|
4
|
+
def self.xcodeproject(path:)
|
5
|
+
xcodeprojs = Dir.new(path).select { |a| a.include? '.xcodeproj' }
|
6
|
+
xcodeprojs_count = xcodeprojs.count
|
7
|
+
|
8
|
+
abort "No *.xcodeproj files in current directory" if xcodeprojs_count == 0
|
9
|
+
abort "Found #{xcodeprojs_count} .xcodeproj files in the directory (1 required)." if xcodeprojs_count > 1
|
10
|
+
|
11
|
+
Xcodeproj::Project.open(xcodeprojs[0])
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.get_targets(project:,target_names:)
|
15
|
+
targets = project.targets.clone
|
16
|
+
if !target_names.empty?
|
17
|
+
not_found_targets = target_names.select { |t| !targets.map { |tt| tt.name }.include? t }
|
18
|
+
abort not_found_targets.join(", ") + " targets were not found in the Xcodeproj." if !not_found_targets.empty?
|
19
|
+
|
20
|
+
targets.select! { |t| target_names.include? t.name }
|
21
|
+
end
|
22
|
+
|
23
|
+
abort "No targets selected" if targets.empty?
|
24
|
+
|
25
|
+
return targets
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.apply_build_setting(name:, value:, target_names: [])
|
29
|
+
project = xcodeproject(path: Dir.pwd)
|
30
|
+
targets = get_targets(project: project, target_names: target_names)
|
31
|
+
|
32
|
+
targets.each do |target|
|
33
|
+
target.build_configurations.each do |config|
|
34
|
+
config.build_settings[name] = value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
project.save
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.append_or_apply_build_setting(name:, value:, target_names: [])
|
42
|
+
project = xcodeproject(path: Dir.pwd)
|
43
|
+
targets = get_targets(project: project, target_names: target_names)
|
44
|
+
|
45
|
+
targets.each do |target|
|
46
|
+
target.build_configurations.each do |config|
|
47
|
+
if config.build_settings[name].nil?
|
48
|
+
config.build_settings[name] = value
|
49
|
+
else
|
50
|
+
config.build_settings[name] += " #{value}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
project.save
|
56
|
+
end
|
57
|
+
end
|
data/lib/version.rb
ADDED
data/spm_utils.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'spm_utils'
|
7
|
+
spec.version = SPMFixers::VERSION
|
8
|
+
spec.authors = ['Łukasz Mróz']
|
9
|
+
spec.email = ['thesunshinejr@gmail.com']
|
10
|
+
spec.license = 'MIT'
|
11
|
+
spec.summary = 'Bunch of utility scripts for Swift Package Manager.'
|
12
|
+
spec.homepage = 'https://github.com/sunshinejr/spm_fixers'
|
13
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.add_dependency 'xcodeproj', '~> 1.0'
|
16
|
+
spec.add_dependency 'clamp', '~> 1.0'
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spm_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Łukasz Mróz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-16 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.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: clamp
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- thesunshinejr@gmail.com
|
44
|
+
executables:
|
45
|
+
- spm_utils
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- bin/spm_utils
|
53
|
+
- lib/command/clean_project_command.rb
|
54
|
+
- lib/command/fix_quick_command.rb
|
55
|
+
- lib/command/inhibit_all_warnings_command.rb
|
56
|
+
- lib/command/swift_version_command.rb
|
57
|
+
- lib/project_mod.rb
|
58
|
+
- lib/version.rb
|
59
|
+
- spm_utils.gemspec
|
60
|
+
homepage: https://github.com/sunshinejr/spm_fixers
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.6.8
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Bunch of utility scripts for Swift Package Manager.
|
84
|
+
test_files: []
|