Commit 252e6104 authored by Eloy Duran's avatar Eloy Duran

Make a MacRuby sample app build.

parent 8b9ab121
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
<FileRef
location = "group:MacRubySample.xcodeproj">
</FileRef>
</Workspace>
# Load the BridgeSupport metadata generated by CocoaPods from all dependencies.
p NSBundle.mainBundle.pathForResource("Pods", ofType:"bridgesupport")
load_bridge_support_file NSBundle.mainBundle.pathForResource("Pods", ofType:"bridgesupport")
class AppDelegate
attr_accessor :window
def applicationDidFinishLaunching(notification)
@queue = NSOperationQueue.new
end
#NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://gowalla.com/users/mattt.json"]];
#AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
#NSLog(@"Name: %@ %@", [JSON valueForKeyPath:@"first_name"], [JSON valueForKeyPath:@"last_name"]);
#} failure:nil];
#NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
#[queue addOperation:operation];
def refreshData(sender)
url = NSURL.URLWithString("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=alloy")
request = NSURLRequest.requestWithURL(url)
operation = AFJSONRequestOperation.JSONRequestOperationWithRequest(request, success:lambda { |request, response, json|
p json
}, failure:nil)
@queue.addOperation(operation)
p @queue
end
end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
//
// Prefix header for all source files of the 'MacRubySample' target in the 'MacRubySample' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
//
// main.m
// MacRubySample
//
// Created by Eloy Duran on 16-10-11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <MacRuby/MacRuby.h>
int main(int argc, char *argv[])
{
return macruby_main("rb_main.rb", argc, argv);
}
#
# rb_main.rb
# MacRubySample
#
# Created by Eloy Duran on 16-10-11.
# Copyright (c) 2011 __MyCompanyName__. All rights reserved.
#
# Loading the Cocoa framework. If you need to load more frameworks, you can
# do that here too.
framework 'Cocoa'
# Loading all the Ruby project files.
main = File.basename(__FILE__, File.extname(__FILE__))
dir_path = NSBundle.mainBundle.resourcePath.fileSystemRepresentation
Dir.glob(File.join(dir_path, '*.{rb,rbo}')).map { |x| File.basename(x, File.extname(x)) }.uniq.each do |path|
if path != main
require(path)
end
end
# Starting the Cocoa main loop.
NSApplicationMain(0, nil)
Pod::File.new do |f|
f.platform = :osx
f.dependency 'ASIHTTPRequest'
end
...@@ -35,9 +35,7 @@ module Pod ...@@ -35,9 +35,7 @@ module Pod
raise Informative, "The specified podspec `#{@podspec}' doesn't exist." raise Informative, "The specified podspec `#{@podspec}' doesn't exist."
end end
else else
if config.project_podfile unless spec = config.rootspec
spec = Specification.from_file(config.project_podfile)
else
raise Informative, "No `Podfile' or `.podspec' file found in the current working directory." raise Informative, "No `Podfile' or `.podspec' file found in the current working directory."
end end
end end
......
...@@ -10,7 +10,7 @@ module Pod ...@@ -10,7 +10,7 @@ module Pod
@instance = instance @instance = instance
end end
attr_accessor :repos_dir, :project_pods_root, :clean, :verbose, :silent attr_accessor :repos_dir, :project_pods_root, :rootspec, :clean, :verbose, :silent
alias_method :clean?, :clean alias_method :clean?, :clean
alias_method :verbose?, :verbose alias_method :verbose?, :verbose
alias_method :silent?, :silent alias_method :silent?, :silent
...@@ -40,6 +40,22 @@ module Pod ...@@ -40,6 +40,22 @@ module Pod
@project_podfile @project_podfile
end end
# Returns the spec at the pat returned from `project_podfile`.
def rootspec
unless @rootspec
@rootspec = Specification.from_file(project_podfile) if project_podfile
end
@rootspec
end
def ios?
rootspec.platform == :ios
end
def osx?
rootspec.platform == :osx
end
module Mixin module Mixin
def config def config
Config.instance Config.instance
......
...@@ -16,22 +16,6 @@ module Pod ...@@ -16,22 +16,6 @@ module Pod
dependent_specification_sets.reject(&:only_part_of_other_pod?) dependent_specification_sets.reject(&:only_part_of_other_pod?)
end end
def source_files
source_files = {}
build_specification_sets.each do |set|
spec = set.specification
source_files[spec.name] = []
spec.source_files.each do |pattern|
pattern = spec.pod_destroot + pattern
pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory?
pattern.glob.each do |file|
source_files[spec.name] << file.relative_path_from(config.project_pods_root)
end
end
end
source_files
end
def xcconfig def xcconfig
@xcconfig ||= Xcode::Config.new({ @xcconfig ||= Xcode::Config.new({
# In a workspace this is where the static library headers should be found # In a workspace this is where the static library headers should be found
......
module Pod module Pod
extend Config::Mixin
def self._eval_podspec(path) def self._eval_podspec(path)
eval(path.read, nil, path.to_s) eval(path.read, nil, path.to_s)
end end
...@@ -62,7 +64,7 @@ module Pod ...@@ -62,7 +64,7 @@ module Pod
end end
def source_files=(*patterns) def source_files=(*patterns)
@source_files = patterns.flatten.map { |p| Pathname.new(p) } @source_files = patterns.flatten
end end
attr_reader :source_files attr_reader :source_files
...@@ -92,7 +94,7 @@ module Pod ...@@ -92,7 +94,7 @@ module Pod
def libraries=(*libraries) def libraries=(*libraries)
libraries.unshift('') libraries.unshift('')
self.xcconfig = { 'OTHER_LDFLAGS' => libraries.join(' -l ').strip } self.xcconfig = { 'OTHER_LDFLAGS' => libraries.join(' -l').strip }
end end
alias_method :library=, :libraries= alias_method :library=, :libraries=
...@@ -120,8 +122,8 @@ module Pod ...@@ -120,8 +122,8 @@ module Pod
def ==(other) def ==(other)
self.class === other && self.class === other &&
@name && @name == other.name && name && name == other.name &&
@version && @version == other.version version && version == other.version
end end
def dependency_by_name(name) def dependency_by_name(name)
...@@ -129,8 +131,8 @@ module Pod ...@@ -129,8 +131,8 @@ module Pod
end end
def part_of_specification_set def part_of_specification_set
if @part_of if part_of
Set.by_specification_name(@part_of.name) Set.by_specification_name(part_of.name)
end end
end end
...@@ -154,7 +156,7 @@ module Pod ...@@ -154,7 +156,7 @@ module Pod
end end
def part_of_other_pod? def part_of_other_pod?
!@part_of.nil? !part_of.nil?
end end
def podfile? def podfile?
...@@ -162,13 +164,13 @@ module Pod ...@@ -162,13 +164,13 @@ module Pod
end end
def any_platform? def any_platform?
@platform.nil? platform.nil?
end end
# Returns all source files of this pod including header files. # Returns all source files of this pod including header files.
def expanded_source_files def expanded_source_files
files = [] files = []
source_files.each do |pattern| [*source_files].each do |pattern|
pattern = pod_destroot + pattern pattern = pod_destroot + pattern
pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory? pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory?
pattern.glob.each do |file| pattern.glob.each do |file|
...@@ -217,7 +219,7 @@ module Pod ...@@ -217,7 +219,7 @@ module Pod
end end
def to_s def to_s
"`#{@name}' version `#{@version}'" "`#{name}' version `#{version}'"
end end
def inspect def inspect
...@@ -226,17 +228,17 @@ module Pod ...@@ -226,17 +228,17 @@ module Pod
def validate! def validate!
missing = [] missing = []
missing << "`name'" unless @name missing << "`name'" unless name
missing << "`version'" unless @version missing << "`version'" unless version
missing << "`summary'" unless @summary missing << "`summary'" unless summary
missing << "`homepage'" unless @homepage missing << "`homepage'" unless homepage
missing << "`author(s)'" unless @authors missing << "`author(s)'" unless authors
missing << "either `source' or `part_of'" unless @source || @part_of missing << "either `source' or `part_of'" unless source || part_of
missing << "`source_files'" unless @source_files missing << "`source_files'" unless source_files
incorrect = [] incorrect = []
allowed = [nil, :ios, :osx] allowed = [nil, :ios, :osx]
incorrect << ["`platform'", allowed] unless allowed.include?(@platform) incorrect << ["`platform'", allowed] unless allowed.include?(platform)
unless missing.empty? && incorrect.empty? unless missing.empty? && incorrect.empty?
message = "The following #{(missing + incorrect).size == 1 ? 'attribute is' : 'attributes are'}:\n" message = "The following #{(missing + incorrect).size == 1 ? 'attribute is' : 'attributes are'}:\n"
...@@ -264,7 +266,7 @@ module Pod ...@@ -264,7 +266,7 @@ module Pod
puts "==> Installing: #{self}" unless config.silent? puts "==> Installing: #{self}" unless config.silent?
config.project_pods_root.mkpath config.project_pods_root.mkpath
require 'fileutils' require 'fileutils'
FileUtils.cp(@defined_in_file, config.project_pods_root) FileUtils.cp(defined_in_file, config.project_pods_root)
# In case this spec is part of another pod's source, we need to dowload # In case this spec is part of another pod's source, we need to dowload
# the other pod's source. # the other pod's source.
...@@ -294,7 +296,7 @@ module Pod ...@@ -294,7 +296,7 @@ module Pod
# end # end
# end # end
def download! def download!
downloader = Downloader.for_source(pod_destroot, @source) downloader = Downloader.for_source(pod_destroot, source)
downloader.download downloader.download
downloader.clean(clean_paths) if config.clean downloader.clean(clean_paths) if config.clean
end end
...@@ -309,7 +311,7 @@ module Pod ...@@ -309,7 +311,7 @@ module Pod
end end
def to_s def to_s
"podfile at `#{@defined_in_file}'" "podfile at `#{defined_in_file}'"
end end
def pod_destroot def pod_destroot
......
...@@ -190,7 +190,9 @@ ...@@ -190,7 +190,9 @@
baseConfigurationReference = 518ACD53144605B400F6BE80 /* Pods.xcconfig */; baseConfigurationReference = 518ACD53144605B400F6BE80 /* Pods.xcconfig */;
buildSettings = { buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Pods/Pods-Prefix.pch"; GCC_PREFIX_HEADER = "Pods-Prefix.pch";
OTHER_LDFLAGS = (
);
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
}; };
name = Debug; name = Debug;
...@@ -200,7 +202,9 @@ ...@@ -200,7 +202,9 @@
baseConfigurationReference = 518ACD53144605B400F6BE80 /* Pods.xcconfig */; baseConfigurationReference = 518ACD53144605B400F6BE80 /* Pods.xcconfig */;
buildSettings = { buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Pods/Pods-Prefix.pch"; GCC_PREFIX_HEADER = "Pods-Prefix.pch";
OTHER_LDFLAGS = (
);
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
}; };
name = Release; name = Release;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment