motion-swifty 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +34 -0
- data/lib/motion/project/project.rb +21 -0
- data/lib/motion/project/tasks.rb +33 -0
- data/lib/motion/swifty/cart.rb +25 -0
- data/lib/motion/swifty/swifty.rb +100 -0
- data/lib/motion-swifty.rb +10 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 813fa05d52f83aab5b418daa5d3a63ffbbfb895b
|
4
|
+
data.tar.gz: c4e2d8c746d3c5862833e5a041efd78dad2abb51
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b7fd61b1a1ae5fea2a1e25c48a8939d35f8d2ff0c99d63c0bf2f507c2b1653656c98a4062349c8db83b6185ec32914af3bf3ebb1bcb36dd87bd5edea05d9be57
|
7
|
+
data.tar.gz: d2d9aeff083df3fcb769ab6d8a42ea9313a7d32af9938a8160e660802dc6dfe5d86797cfbe00e0ac469bcade8e2c9fb06cfff201b7ec532532558200b7377239
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Swifty
|
2
|
+
|
3
|
+
A simple and clean way to use Swift dependencies in your RubyMotion project.
|
4
|
+
|
5
|
+
|
6
|
+
## Setup
|
7
|
+
|
8
|
+
- brew install carthage
|
9
|
+
- brew install swiftlint
|
10
|
+
- add 'motion-swifty' to your Gemfile
|
11
|
+
- bundle install
|
12
|
+
|
13
|
+
Define your dependencies inside your Rakefile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
###
|
17
|
+
app.cartfile do
|
18
|
+
cart 'github "nickoneill/PermissionScope" "master"'
|
19
|
+
cart '"file:///directory/to/project" "branch"', name: "MyFramework"
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
- rake swifty:install
|
24
|
+
- rake
|
25
|
+
|
26
|
+
|
27
|
+
## Todo
|
28
|
+
|
29
|
+
- Support other platforms than iOS, if you need it please open an issue
|
30
|
+
|
31
|
+
|
32
|
+
## Thanks
|
33
|
+
|
34
|
+
Thanks to [Mark Villacampa](https://twitter.com/MarkVillacampa) who did all the hard work in RubyMotion to make this possible.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
if Motion::Project::App.template != :ios
|
6
|
+
fail('This file must be required within a RubyMotion iOS project.')
|
7
|
+
end
|
8
|
+
|
9
|
+
module Motion::Project
|
10
|
+
class Config
|
11
|
+
variable :swifty
|
12
|
+
|
13
|
+
def swifty
|
14
|
+
@swifty ||= MotionSwifty::Swifty.new(self)
|
15
|
+
end
|
16
|
+
|
17
|
+
def cartfile(&block)
|
18
|
+
swifty.instance_eval(&block) if block
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
namespace :build do
|
2
|
+
task :device => 'swifty:build_device'
|
3
|
+
task :simulator => 'swifty:build_sim'
|
4
|
+
end
|
5
|
+
|
6
|
+
namespace :clean do
|
7
|
+
task :all => 'swifty:clean'
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :swifty do
|
11
|
+
desc 'Download and build dependencies'
|
12
|
+
task :install do
|
13
|
+
App.config.swifty.setup
|
14
|
+
end
|
15
|
+
|
16
|
+
task :build_sim do
|
17
|
+
App.config.swifty.configure_platform("iPhoneSimulator")
|
18
|
+
end
|
19
|
+
task :build_device do
|
20
|
+
App.config.swifty.configure_platform("iPhoneOS")
|
21
|
+
end
|
22
|
+
|
23
|
+
task :clean do
|
24
|
+
paths = ["./vendor/Carts", "./Carthage", "Cartfile"]
|
25
|
+
paths.each do |path|
|
26
|
+
if File.exist?(path)
|
27
|
+
App.info('Delete', path)
|
28
|
+
rm_rf path
|
29
|
+
end
|
30
|
+
end
|
31
|
+
App.info('Info', 'You will need to run `rake swifty:install` to reinstall your swift dependencies')
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MotionSwifty
|
2
|
+
class Cart
|
3
|
+
attr_accessor :definition
|
4
|
+
attr_accessor :options
|
5
|
+
|
6
|
+
def initialize(definition, options = {})
|
7
|
+
@definition = definition
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
self.options.fetch(:name) do
|
13
|
+
if match = @definition.match(/.* ".*\/(.*?)"/i)
|
14
|
+
match.captures.first
|
15
|
+
else
|
16
|
+
raise "Couldn’t extract cart name from its Cartfile definition"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def path(plaform = "iOS")
|
22
|
+
File.expand_path("./Carthage/Build/#{plaform}/#{name}.framework")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module MotionSwifty
|
2
|
+
class Swifty
|
3
|
+
attr_reader :config
|
4
|
+
attr_accessor :carts
|
5
|
+
|
6
|
+
def initialize(config)
|
7
|
+
@config = config
|
8
|
+
@carts = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def cartfile(&block)
|
12
|
+
self.instance_eval(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def cart(cart, options = {})
|
16
|
+
@carts << Cart.new(cart, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup
|
20
|
+
generate_cartfile(self.carts)
|
21
|
+
pull_frameworks(carthage_platform(config.template))
|
22
|
+
copy_frameworks(self.config.archs, self.carts)
|
23
|
+
end
|
24
|
+
|
25
|
+
def configure_platform(platform)
|
26
|
+
frameworks = File.join(self.config.app_bundle(platform), "Frameworks")
|
27
|
+
update_swift_dlybs("./Cartfile", frameworks) do
|
28
|
+
clean_swift_dlybs(frameworks)
|
29
|
+
copy_swift_dlybs(platform)
|
30
|
+
end
|
31
|
+
|
32
|
+
self.config.embedded_frameworks += self.carts.map(&:path)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def update_swift_dlybs(cartfile, frameworks, &block)
|
38
|
+
lib_swift = Dir.glob(File.join(frameworks, '**/libswiftCore.dylib')).first
|
39
|
+
if !lib_swift || !File.exists?(lib_swift) || File.mtime(cartfile) > File.mtime(lib_swift)
|
40
|
+
block.call
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def pull_frameworks(carthage_platform)
|
45
|
+
`carthage update --platform #{carthage_platform} --no-use-binaries`
|
46
|
+
end
|
47
|
+
|
48
|
+
def copy_frameworks(archs, carts)
|
49
|
+
ENV["TARGET_BUILD_DIR"] = File.expand_path("./vendor/Carts")
|
50
|
+
ENV["BUILT_PRODUCTS_DIR"] = File.expand_path("./vendor/Carts")
|
51
|
+
|
52
|
+
archs.each do |platform, platform_archs|
|
53
|
+
ENV["SCRIPT_INPUT_FILE_COUNT"] = carts.count.to_s
|
54
|
+
ENV["FRAMEWORKS_FOLDER_PATH"] = platform_archs.join(" ")
|
55
|
+
ENV["VALID_ARCHS"] = platform_archs.join(" ")
|
56
|
+
|
57
|
+
carts.each_with_index do |cart, index|
|
58
|
+
ENV["SCRIPT_INPUT_FILE_#{index}"] = cart.path
|
59
|
+
end
|
60
|
+
|
61
|
+
`carthage copy-frameworks`
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def clean_swift_dlybs(dlybs_folder)
|
66
|
+
FileUtils.rm(Dir.glob(File.join(dlybs_folder, '**/libswift*.dylib')))
|
67
|
+
end
|
68
|
+
|
69
|
+
def carthage_platform(platform)
|
70
|
+
case platform
|
71
|
+
when :ios
|
72
|
+
"iOS"
|
73
|
+
else
|
74
|
+
"all"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def generate_cartfile(carts)
|
79
|
+
target = File.open("Cartfile", 'w+')
|
80
|
+
target.write(carts.map(&:definition).join("\r\n"))
|
81
|
+
target.close
|
82
|
+
end
|
83
|
+
|
84
|
+
def copy_swift_dlybs(platform)
|
85
|
+
dlybs = list_swift_dlybs(platform)
|
86
|
+
frameworks_path = File.join(File.dirname(self.config.app_bundle_executable(platform)), "Frameworks")
|
87
|
+
FileUtils.mkdir_p(frameworks_path)
|
88
|
+
dlybs.each do |dlyb|
|
89
|
+
FileUtils.cp(dlyb, frameworks_path)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def list_swift_dlybs(platform)
|
94
|
+
swift_stdlib_tool = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-stdlib-tool"
|
95
|
+
archs = self.config.archs[platform].join(' ')
|
96
|
+
bundle = Shellwords.escape("./vendor/Carts/#{archs}")
|
97
|
+
`#{swift_stdlib_tool} --print --scan-folder #{bundle} --platform #{platform.downcase}`.split
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-swifty
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joffrey JAFFEUX
|
8
|
+
- Mark VILLACAMPA
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-12-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
description: Swift dependencies in RubyMotion
|
29
|
+
email:
|
30
|
+
- j.jaffeux@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- README.md
|
36
|
+
- lib/motion-swifty.rb
|
37
|
+
- lib/motion/project/project.rb
|
38
|
+
- lib/motion/project/tasks.rb
|
39
|
+
- lib/motion/swifty/cart.rb
|
40
|
+
- lib/motion/swifty/swifty.rb
|
41
|
+
homepage: https://github.com/jjaffeux/swifty
|
42
|
+
licenses:
|
43
|
+
- MIT
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.5.1
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: A simple and clean way to use Swift dependencies in your RubyMotion project.y
|
65
|
+
test_files: []
|