motion-objc-runtime 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +2 -0
- data/lib/motion-objc-runtime.rb +48 -0
- data/motion-objc-runtime.gemspec +20 -0
- metadata +53 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Dave Lee
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# motion-objc-runtime
|
2
|
+
|
3
|
+
motion-objc-runtime gives RubyMotion some of the metaprogramming
|
4
|
+
capabilities currently lacking. By exposing the Objective-C runtime,
|
5
|
+
#define_method and other metaprogramming staples can be used from
|
6
|
+
within RubyMotion apps.
|
7
|
+
|
8
|
+
The Objective-C runtime is exposed the same way RubyMotion exposes
|
9
|
+
other UIKit and other iOS frameworks, via BrideSupport files created
|
10
|
+
by the `gen_bridge_metadata` command.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your RubyMotion app's Rakefile:
|
15
|
+
|
16
|
+
require 'motion-objc-runtime'
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
See Apple's [Objective-C Runtime Reference](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html)
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
1. Fork it
|
25
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
26
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
27
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
28
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
unless defined? Motion::Project::App
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
# TODO: Find a good home for the .bridgesupport file
|
6
|
+
BRIDGESUPPORT_FILE = './objc-runtime.bridgesupport'
|
7
|
+
|
8
|
+
SDK_DIR = "Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator%s.sdk"
|
9
|
+
OBJC_INCLUDE_DIR = 'usr/include/objc'
|
10
|
+
|
11
|
+
# TODO: Regenerate bridgesupport when relevant settings have changed
|
12
|
+
def generate_bridgesupport(config)
|
13
|
+
return BRIDGESUPPORT_FILE if File.exist? BRIDGESUPPORT_FILE
|
14
|
+
|
15
|
+
sdk = File.join(config['xcode_dir'], SDK_DIR % config['sdk_version'])
|
16
|
+
objc_include_dir = File.join(sdk, OBJC_INCLUDE_DIR)
|
17
|
+
gen_bridge_metadata = '/usr/bin/gen_bridge_metadata'
|
18
|
+
opts = '--format complete --no-64-bit'
|
19
|
+
cflags = "-I#{objc_include_dir}"
|
20
|
+
cflags << " -miphoneos-version-min=#{config['deployment_target']}"
|
21
|
+
opts << %' --cflags "#{cflags}"'
|
22
|
+
header = "#{objc_include_dir}/runtime.h"
|
23
|
+
|
24
|
+
# see man gen_bridge_metadata
|
25
|
+
`#{gen_bridge_metadata} #{opts} #{header} > #{BRIDGESUPPORT_FILE}`
|
26
|
+
end
|
27
|
+
|
28
|
+
# Tap into App::setup to appropriately generate the Objective-C
|
29
|
+
# runtime bridgesupport file after completion of the project's setup
|
30
|
+
# block. Performing post-setup allows access to the project's config
|
31
|
+
# settings.
|
32
|
+
#
|
33
|
+
# This depends on the RubyMotion toolchain. If it changes structure,
|
34
|
+
# the technique used here will break.
|
35
|
+
class << Motion::Project::App
|
36
|
+
real_setup = instance_method(:setup).bind(Motion::Project::App)
|
37
|
+
|
38
|
+
# Define a new setup method that calls the real setup method and
|
39
|
+
# then, if necessary, generate the bridgesupport file and add it to
|
40
|
+
# the configuration.
|
41
|
+
define_method :setup do |&block|
|
42
|
+
real_setup.call(&block)
|
43
|
+
generate_bridgesupport(config.variables)
|
44
|
+
configs.each_value do |app|
|
45
|
+
app.bridgesupport_files << BRIDGESUPPORT_FILE
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.name = 'motion-objc-runtime'
|
4
|
+
gem.description = 'Exposes Objective-C runtime in RubyMotion'
|
5
|
+
gem.homepage = "https://github.com/kastiglione/#{gem.name}"
|
6
|
+
gem.version = '0.0.1'
|
7
|
+
|
8
|
+
gem.authors = ['Dave Lee']
|
9
|
+
gem.email = ['dave@kastiglione.com']
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.require_paths = ['lib']
|
13
|
+
|
14
|
+
gem.summary = <<-END.gsub(/^ +/, '')
|
15
|
+
motion-objc-runtime gives RubyMotion some of the metaprogramming
|
16
|
+
capabilities currently lacking. By exposing the Objective-C
|
17
|
+
runtime, #define_method and other metaprogramming staples can be
|
18
|
+
used from within RubyMotion apps.
|
19
|
+
END
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-objc-runtime
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dave Lee
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-29 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Exposes Objective-C runtime in RubyMotion
|
15
|
+
email:
|
16
|
+
- dave@kastiglione.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/motion-objc-runtime.rb
|
26
|
+
- motion-objc-runtime.gemspec
|
27
|
+
homepage: https://github.com/kastiglione/motion-objc-runtime
|
28
|
+
licenses: []
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 1.8.24
|
48
|
+
signing_key:
|
49
|
+
specification_version: 3
|
50
|
+
summary: ! 'motion-objc-runtime gives RubyMotion some of the metaprogramming capabilities
|
51
|
+
currently lacking. By exposing the Objective-C runtime, #define_method and other
|
52
|
+
metaprogramming staples can be used from within RubyMotion apps.'
|
53
|
+
test_files: []
|