Skip to content

Commit

Permalink
add config file for Watch extension
Browse files Browse the repository at this point in the history
Because Watch extension has some different value in info_plist than other extensions.
(This patch is not change yet)
  • Loading branch information
Watson1978 committed Dec 11, 2014
1 parent ffc591b commit aa6f385
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 1 deletion.
113 changes: 113 additions & 0 deletions lib/motion/project/template/ios-watch-extension-config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# encoding: utf-8

# Copyright (c) 2012, HipByte SPRL and contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'motion/project/template/ios-extension-config'

module Motion; module Project;
class IOSWatchExtensionConfig < IOSExtensionConfig
register :'ios-watch-extension'

def info_plist_data(platform)
Motion::PropertyList.to_s({
'MinimumOSVersion' => deployment_target,
'CFBundleResourceSpecification' => 'ResourceRules.plist',
'CFBundleSupportedPlatforms' => [deploy_platform],
# TODO temp hack to get ints for Instruments, but strings for normal builds.
'UIDeviceFamily' => device_family_ints.map { |x| ENV['__USE_DEVICE_INT__'] ? x.to_i : x.to_s },
'DTXcode' => begin
vers = xcode_version[0].gsub(/\./, '')
if vers.length == 2
'0' + vers + '0'
else
'0' + vers
end
end,
'DTXcodeBuild' => xcode_version[1],
'DTSDKName' => "#{platform.downcase}#{sdk_version}",
'DTSDKBuild' => sdk_build_version(platform),
'DTPlatformName' => platform.downcase,
'DTCompiler' => 'com.apple.compilers.llvm.clang.1_0',
'DTPlatformVersion' => sdk_version,
'DTPlatformBuild' => sdk_build_version(platform),
}.merge(generic_info_plist).merge(dt_info_plist).merge(info_plist)
.merge({ 'CFBundlePackageType' => 'XPC!' }))
end

def manifest_plist_data
return nil if manifest_assets.empty?
Motion::PropertyList.to_s({
'items' => [
{ 'assets' => manifest_assets,
'metadata' => {
'bundle-identifier' => identifier,
'bundle-version' => @version,
'kind' => 'software',
'title' => @name
} }
]
})
end

def main_cpp_file_txt(spec_objs)
main_txt = <<EOS
#import <UIKit/UIKit.h>
#include <objc/message.h>
#include <dlfcn.h>
extern "C" {
void rb_define_global_const(const char *, void *);
void rb_rb2oc_exc_handler(void);
void rb_exit(int);
void RubyMotionInit(int argc, char **argv);
EOS
main_txt << <<EOS
}
EOS
main_txt << <<EOS
int
main(int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retval = 0;
EOS
if ENV['ARR_CYCLES_DISABLE']
main_txt << <<EOS
setenv("ARR_CYCLES_DISABLE", "1", true);
EOS
end
main_txt << <<EOS
RubyMotionInit(argc, argv);
EOS
main_txt << <<EOS
dlopen("/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit", 0x2);
retval = ((int(*)(id, SEL, int, char**))objc_msgSend)(NSClassFromString(@"PKService"), @selector(_defaultRun:arguments:), argc, argv);
rb_exit(retval);
[pool release];
return retval;
}
EOS
end
end
end; end
86 changes: 86 additions & 0 deletions lib/motion/project/template/ios-watch-extension.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# encoding: utf-8

# Copyright (c) 2012, HipByte SPRL and contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'motion/project/app'
require 'motion/util/version'

App = Motion::Project::App
App.template = :'ios-extension'

require 'motion/project'
require 'motion/project/template/ios-watch-extension-config'
require 'motion/project/template/ios-extension-builder'

desc "Build the simulator version"
task :default => :"build:simulator"

desc "Build everything"
task :build => ['build:simulator', 'build:device']

namespace :build do
def pre_build_actions(platform)
# TODO: Ensure Info.plist gets regenerated on each build so it has ints for
# Instruments and strings for normal builds.
rm_f File.join(App.config.app_bundle(platform), 'Info.plist')

# TODO this should go into a iOS specific Builder class which performs this
# check before building.
App.config.resources_dirs.flatten.each do |dir|
next unless File.exist?(dir)
Dir.entries(dir).grep(/^Resources$/i).each do |basename|
path = File.join(dir, basename)
if File.directory?(path)
suggestion = basename == 'Resources' ? 'Assets' : 'assets'
App.fail "An iOS application cannot be installed if it contains a " \
"directory called `resources'. Please rename the " \
"directory at path `#{path}' to, for instance, " \
"`#{File.join(dir, suggestion)}'."
end
end
end
end

desc "Build the simulator version"
task :simulator do
pre_build_actions('iPhoneSimulator')
App.build('iPhoneSimulator')
end

desc "Build the device version"
task :device do
pre_build_actions('iPhoneOS')
App.build('iPhoneOS')
App.codesign('iPhoneOS')
end
end

namespace :archive do
desc "Build for distribution (AppStore)"
task :distribution do
App.config_without_setup.build_mode = :release
App.config_without_setup.distribution_mode = true
Rake::Task["build:device"].invoke
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios-extension'
require 'motion/project/template/ios-watch-extension'

begin
require 'bundler'
Expand Down

0 comments on commit aa6f385

Please sign in to comment.