diff --git a/lib/motion/project/builder.rb b/lib/motion/project/builder.rb index 272929f8..769410e2 100644 --- a/lib/motion/project/builder.rb +++ b/lib/motion/project/builder.rb @@ -89,13 +89,13 @@ module Motion; module Project; end # Build targets + target_frameworks = [] unless config.targets.empty? config.targets.each do |target| target.build(platform) end # Prepare target frameworks - target_frameworks = [] config.targets.select { |t| t.type == :framework && t.load? }.each do |target| target_frameworks << target.framework_name end diff --git a/lib/motion/project/template/ios-action-extension/files/.gitignore b/lib/motion/project/template/ios-action-extension/files/.gitignore new file mode 100644 index 00000000..ae6aa4dd --- /dev/null +++ b/lib/motion/project/template/ios-action-extension/files/.gitignore @@ -0,0 +1,17 @@ +.repl_history +build +tags +app/pixate_code.rb +resources/*.nib +resources/*.momd +resources/*.storyboardc +.DS_Store +nbproject +.redcar +#*# +*~ +*.sw[po] +.eprj +.sass-cache +.idea +.dat*.* diff --git a/lib/motion/project/template/ios-action-extension/files/Gemfile b/lib/motion/project/template/ios-action-extension/files/Gemfile new file mode 100644 index 00000000..764be634 --- /dev/null +++ b/lib/motion/project/template/ios-action-extension/files/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'rake' +# Add your dependencies here: diff --git a/lib/motion/project/template/ios-action-extension/files/Rakefile.erb b/lib/motion/project/template/ios-action-extension/files/Rakefile.erb index b003fc92..698986ec 100644 --- a/lib/motion/project/template/ios-action-extension/files/Rakefile.erb +++ b/lib/motion/project/template/ios-action-extension/files/Rakefile.erb @@ -1,15 +1,32 @@ # -*- coding: utf-8 -*- +$:.unshift("/Library/RubyMotion/lib") +require 'motion/project/template/ios-extension' + +begin + require 'bundler' + Bundler.require +rescue LoadError +end Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. - app.extension do |ext| - ext.name = '<%= extension_name %>' - ext.type = 'ui-services' - ext.attributes = { - "NSExtensionActivationRule" => "TRUEPREDICATE", - "NSExtensionPointName" => "com.apple.ui-services", - "NSExtensionPointVersion" => "1.0" - } - ext.frameworks << "MobileCoreServices" - end -end + app.name = '<%= name %>' + app.frameworks << 'MobileCoreServices' + app.info_plist['NSExtension'] = { + 'NSExtensionAttributes' => { + 'NSExtensionActivationRule' => { + 'NSExtensionActivationSupportsFileWithMaxCount' => 0, + 'NSExtensionActivationSupportsImageWithMaxCount' => 1, + 'NSExtensionActivationSupportsMovieWithMaxCount' => 0, + 'NSExtensionActivationSupportsText' => false, + 'NSExtensionActivationSupportsWebURLWithMaxCount' => 0 + }, + 'NSExtensionPointName' => 'com.apple.ui-services', + 'NSExtensionPointVersion' => '1.0' + }, + # Use 'NSExtensionPrincipalClass' if you want to setup the UI in code + # 'NSExtensionPrincipalClass' => 'ActionViewController', + 'NSExtensionMainStoryboard' => 'MainInterface', + 'NSExtensionPointIdentifier' => 'com.apple.ui-services' + } +end \ No newline at end of file diff --git a/lib/motion/project/template/ios-action-extension/files/app/action_view_controller.rb b/lib/motion/project/template/ios-action-extension/files/app/action_view_controller.rb index 24367769..19e179df 100644 --- a/lib/motion/project/template/ios-action-extension/files/app/action_view_controller.rb +++ b/lib/motion/project/template/ios-action-extension/files/app/action_view_controller.rb @@ -20,13 +20,14 @@ class ActionViewController < UIViewController if itemProvider.hasItemConformingToTypeIdentifier(KUTTypeImage) # This is an image. We'll load it, then place it in our image view. imageView = WeakRef.new(self.imageView) - itemProvider.loadItemForTypeIdentifier(KUTTypeImage, options:nil, completionHandler: proc { |image, error| - if image + itemProvider.loadItemForTypeIdentifier(KUTTypeImage, options:nil, completionHandler: proc { |url, error| + if url + image = UIImage.alloc.initWithData(NSData.dataWithContentsOfURL(url)) NSOperationQueue.mainQueue.addOperationWithBlock(proc { imageView.setImage(image) - }.weak!) + }) end - }.weak!) + }) imageFound = true break diff --git a/lib/motion/project/template/ios-action-extension/files/resources/.gitkeep b/lib/motion/project/template/ios-action-extension/files/resources/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/lib/motion/project/template/ios-action-extension/files/resources/MainInterface.storyboard b/lib/motion/project/template/ios-action-extension/files/resources/MainInterface.storyboard new file mode 100644 index 00000000..160d4ac4 --- /dev/null +++ b/lib/motion/project/template/ios-action-extension/files/resources/MainInterface.storyboard @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/motion/project/template/ios-custom-keyboard/files/.gitignore b/lib/motion/project/template/ios-custom-keyboard/files/.gitignore new file mode 100644 index 00000000..ae6aa4dd --- /dev/null +++ b/lib/motion/project/template/ios-custom-keyboard/files/.gitignore @@ -0,0 +1,17 @@ +.repl_history +build +tags +app/pixate_code.rb +resources/*.nib +resources/*.momd +resources/*.storyboardc +.DS_Store +nbproject +.redcar +#*# +*~ +*.sw[po] +.eprj +.sass-cache +.idea +.dat*.* diff --git a/lib/motion/project/template/ios-custom-keyboard/files/Gemfile b/lib/motion/project/template/ios-custom-keyboard/files/Gemfile new file mode 100644 index 00000000..764be634 --- /dev/null +++ b/lib/motion/project/template/ios-custom-keyboard/files/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'rake' +# Add your dependencies here: diff --git a/lib/motion/project/template/ios-custom-keyboard/files/resources/.gitkeep b/lib/motion/project/template/ios-custom-keyboard/files/resources/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/lib/motion/project/template/ios-document-picker/files/.gitignore b/lib/motion/project/template/ios-document-picker/files/.gitignore new file mode 100644 index 00000000..ae6aa4dd --- /dev/null +++ b/lib/motion/project/template/ios-document-picker/files/.gitignore @@ -0,0 +1,17 @@ +.repl_history +build +tags +app/pixate_code.rb +resources/*.nib +resources/*.momd +resources/*.storyboardc +.DS_Store +nbproject +.redcar +#*# +*~ +*.sw[po] +.eprj +.sass-cache +.idea +.dat*.* diff --git a/lib/motion/project/template/ios-document-picker/files/Gemfile b/lib/motion/project/template/ios-document-picker/files/Gemfile new file mode 100644 index 00000000..764be634 --- /dev/null +++ b/lib/motion/project/template/ios-document-picker/files/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'rake' +# Add your dependencies here: diff --git a/lib/motion/project/template/ios-document-picker/files/Rakefile.erb b/lib/motion/project/template/ios-document-picker/files/Rakefile.erb index a3e4f916..da908718 100644 --- a/lib/motion/project/template/ios-document-picker/files/Rakefile.erb +++ b/lib/motion/project/template/ios-document-picker/files/Rakefile.erb @@ -1,11 +1,18 @@ # -*- coding: utf-8 -*- +$:.unshift("/Library/RubyMotion/lib") +require 'motion/project/template/ios-extension' + +begin + require 'bundler' + Bundler.require +rescue LoadError +end Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. - app.extension do |ext| - ext.name = '<%= extension_name %>' - ext.type = "fileprovider-ui" - ext.attributes = { + app.name = '<%= name %>' + app.info_plist['NSExtension'] = { + 'NSExtensionAttributes' => { "UIDocumentPickerModes" => [ "UIDocumentPickerModeImport", "UIDocumentPickerModeOpen", @@ -15,6 +22,11 @@ Motion::Project::App.setup do |app| "UIDocumentPickerSupportedFileTypes" => [ "public.content" ] - } - end -end + }, + # 'NSExtensionPrincipalClass' => 'DocumentPickerViewController', + 'NSExtensionMainStoryboard' => 'MainInterface', + 'NSExtensionPointIdentifier' => 'com.apple.fileprovider-ui' + } + # + app.entitlements['com.apple.security.application-groups'] = '<%= name %>' +end \ No newline at end of file diff --git a/lib/motion/project/template/ios-document-picker/files/app/document_picker_view_controller.rb b/lib/motion/project/template/ios-document-picker/files/app/document_picker_view_controller.rb index 7189c803..787b147a 100644 --- a/lib/motion/project/template/ios-document-picker/files/app/document_picker_view_controller.rb +++ b/lib/motion/project/template/ios-document-picker/files/app/document_picker_view_controller.rb @@ -1,4 +1,4 @@ -class DocumentPickerViewController < UIDocumentPickerExtensionViewController +class DocumentPickerViewController < UIDocumentPickerExtensionViewController def openDocument(sender) documentURL = self.documentStorageURL.URLByAppendingPathComponent("Untitled.txt") diff --git a/lib/motion/project/template/ios-document-picker/files/document.entitlements b/lib/motion/project/template/ios-document-picker/files/document.entitlements deleted file mode 100644 index 632d21b1..00000000 --- a/lib/motion/project/template/ios-document-picker/files/document.entitlements +++ /dev/null @@ -1,10 +0,0 @@ - - - - - com.apple.security.application-groups - - group.sdf.Extension-Test - - - diff --git a/lib/motion/project/template/ios-document-picker/files/resources/.gitkeep b/lib/motion/project/template/ios-document-picker/files/resources/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/lib/motion/project/template/ios-document-picker/files/resources/MainInterface.storyboard b/lib/motion/project/template/ios-document-picker/files/resources/MainInterface.storyboard new file mode 100644 index 00000000..cc377324 --- /dev/null +++ b/lib/motion/project/template/ios-document-picker/files/resources/MainInterface.storyboard @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/motion/project/template/ios-extension-builder.rb b/lib/motion/project/template/ios-extension-builder.rb index 9046d2d5..9128d156 100644 --- a/lib/motion/project/template/ios-extension-builder.rb +++ b/lib/motion/project/template/ios-extension-builder.rb @@ -314,7 +314,7 @@ EOS ib_resources.each do |src, dest| if !File.exist?(dest) or File.mtime(src) > File.mtime(dest) App.info 'Compile', src - sh "/usr/bin/ibtool --compile \"#{dest}\" \"#{src}\"" + sh "/usr/bin/ibtool --compile \"#{File.expand_path(dest)}\" \"#{File.expand_path(src)}\"" end end end diff --git a/lib/motion/project/template/ios-file-provider/files/Rakefile.erb b/lib/motion/project/template/ios-file-provider/files/Rakefile.erb index fd8c719b..a3791dc4 100644 --- a/lib/motion/project/template/ios-file-provider/files/Rakefile.erb +++ b/lib/motion/project/template/ios-file-provider/files/Rakefile.erb @@ -1,13 +1,24 @@ # -*- coding: utf-8 -*- +$:.unshift("/Library/RubyMotion/lib") +require 'motion/project/template/ios-extension' + +begin + require 'bundler' + Bundler.require +rescue LoadError +end Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. - app.extension do |ext| - ext.name = '<%= extension_name %>' - ext.type = "fileprovider-nonui" - # TODO: its not inside attributes! - ext.attributes = { - "NSExtensionFileProviderDocumentGroup" => "group.sdf.Extension-Test" - } - end + app.name = '<%= name %>' + app.info_plist['NSExtension'] = { + 'NSExtensionAttributes' => { + "NSExtensionFileProviderDocumentGroup" => "<%= name %>" + }, + 'NSExtensionPrincipalClass' => 'FileProvider', + 'NSExtensionPointIdentifier' => 'com.apple.fileprovider-nonui' + } + app.entitlements['com.apple.security.application-groups'] = '<%= name %>' end + + diff --git a/lib/motion/project/template/ios-file-provider/files/documentFileProvider.entitlements b/lib/motion/project/template/ios-file-provider/files/documentFileProvider.entitlements deleted file mode 100644 index 632d21b1..00000000 --- a/lib/motion/project/template/ios-file-provider/files/documentFileProvider.entitlements +++ /dev/null @@ -1,10 +0,0 @@ - - - - - com.apple.security.application-groups - - group.sdf.Extension-Test - - - diff --git a/lib/motion/project/template/ios-file-provider/files/resources/.gitkeep b/lib/motion/project/template/ios-file-provider/files/resources/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/lib/motion/project/template/ios-photo-editing/files/.gitignore b/lib/motion/project/template/ios-photo-editing/files/.gitignore new file mode 100644 index 00000000..ae6aa4dd --- /dev/null +++ b/lib/motion/project/template/ios-photo-editing/files/.gitignore @@ -0,0 +1,17 @@ +.repl_history +build +tags +app/pixate_code.rb +resources/*.nib +resources/*.momd +resources/*.storyboardc +.DS_Store +nbproject +.redcar +#*# +*~ +*.sw[po] +.eprj +.sass-cache +.idea +.dat*.* diff --git a/lib/motion/project/template/ios-photo-editing/files/Gemfile b/lib/motion/project/template/ios-photo-editing/files/Gemfile new file mode 100644 index 00000000..764be634 --- /dev/null +++ b/lib/motion/project/template/ios-photo-editing/files/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'rake' +# Add your dependencies here: diff --git a/lib/motion/project/template/ios-photo-editing/files/Rakefile.erb b/lib/motion/project/template/ios-photo-editing/files/Rakefile.erb index 03c1e89f..172422cf 100644 --- a/lib/motion/project/template/ios-photo-editing/files/Rakefile.erb +++ b/lib/motion/project/template/ios-photo-editing/files/Rakefile.erb @@ -1,14 +1,23 @@ # -*- coding: utf-8 -*- +$:.unshift("/Library/RubyMotion/lib") +require 'motion/project/template/ios-extension' + +begin + require 'bundler' + Bundler.require +rescue LoadError +end Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. - app.extension do |ext| - ext.name = '<%= extension_name %>' - ext.type = "photo-editing" - ext.attributes = { + app.name = '<%= name %>' + app.frameworks << "Photos" + app.frameworks << "PhotosUI" + app.info_plist['NSExtension'] = { + 'NSExtensionAttributes' => { "PHSupportedMediaTypes" => ["Image"] - } - ext.frameworks << "Photos" - ext.frameworks << "PhotosUI" - end -end + }, + 'NSExtensionPrincipalClass' => 'PhotoEditingViewController', + 'NSExtensionPointIdentifier' => 'com.apple.photo-editing' + } +end \ No newline at end of file diff --git a/lib/motion/project/template/ios-photo-editing/files/app/photo_editing_view_controller.rb b/lib/motion/project/template/ios-photo-editing/files/app/photo_editing_view_controller.rb index cc42d8e3..c6d001eb 100644 --- a/lib/motion/project/template/ios-photo-editing/files/app/photo_editing_view_controller.rb +++ b/lib/motion/project/template/ios-photo-editing/files/app/photo_editing_view_controller.rb @@ -4,7 +4,18 @@ class PhotoEditingViewController < UIViewController def viewDidLoad super - # Do any additional setup after loading the view. + + self.view.backgroundColor = UIColor.whiteColor + + label = UILabel.alloc.init + label.text = "Hello World" + label.textColor = UIColor.blackColor + label.textAlignment = NSTextAlignmentCenter + label.setTranslatesAutoresizingMaskIntoConstraints(false) + self.view.addSubview(label) + + self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("|-[label]-|", options:0, metrics:nil, views:{"label" => label})) + self.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-[label]-|", options:0, metrics:nil, views:{"label" => label})) end def didReceiveMemoryWarning diff --git a/lib/motion/project/template/ios-photo-editing/files/resources/.gitkeep b/lib/motion/project/template/ios-photo-editing/files/resources/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/lib/motion/project/template/ios-share-extension/files/.gitignore b/lib/motion/project/template/ios-share-extension/files/.gitignore new file mode 100644 index 00000000..ae6aa4dd --- /dev/null +++ b/lib/motion/project/template/ios-share-extension/files/.gitignore @@ -0,0 +1,17 @@ +.repl_history +build +tags +app/pixate_code.rb +resources/*.nib +resources/*.momd +resources/*.storyboardc +.DS_Store +nbproject +.redcar +#*# +*~ +*.sw[po] +.eprj +.sass-cache +.idea +.dat*.* diff --git a/lib/motion/project/template/ios-share-extension/files/Gemfile b/lib/motion/project/template/ios-share-extension/files/Gemfile new file mode 100644 index 00000000..764be634 --- /dev/null +++ b/lib/motion/project/template/ios-share-extension/files/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'rake' +# Add your dependencies here: diff --git a/lib/motion/project/template/ios-share-extension/files/Rakefile.erb b/lib/motion/project/template/ios-share-extension/files/Rakefile.erb index ec350838..466fb094 100644 --- a/lib/motion/project/template/ios-share-extension/files/Rakefile.erb +++ b/lib/motion/project/template/ios-share-extension/files/Rakefile.erb @@ -1,15 +1,31 @@ # -*- coding: utf-8 -*- +$:.unshift("/Library/RubyMotion/lib") +require 'motion/project/template/ios-extension' + +begin + require 'bundler' + Bundler.require +rescue LoadError +end Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. - app.extension do |ext| - ext.name = '<%= extension_name %>' - ext.type = "share-services" - ext.attributes = { - "NSExtensionActivationRule" => "TRUEPREDICATE" - "NSExtensionPointName" => "1.0" - "NSExtensionPointVersion" => "1.0" - } - ext.frameworks << "MobileCoreServices" - end + app.name = '<%= name %>' + app.frameworks << 'Social' + app.info_plist['NSExtension'] = { + 'NSExtensionAttributes' => { + 'NSExtensionActivationRule' => { + 'NSExtensionActivationSupportsFileWithMaxCount' => 0, + 'NSExtensionActivationSupportsImageWithMaxCount' => 1, + 'NSExtensionActivationSupportsMovieWithMaxCount' => 0, + 'NSExtensionActivationSupportsText' => false, + 'NSExtensionActivationSupportsWebURLWithMaxCount' => 0 + }, + 'NSExtensionPointName' => 'com.apple.share-services', + 'NSExtensionPointVersion' => '1.0' + }, + 'NSExtensionPrincipalClass' => 'ShareViewController', + 'NSExtensionPointIdentifier' => 'com.apple.share-services' + } end + diff --git a/lib/motion/project/template/ios-share-extension/files/resources/.gitkeep b/lib/motion/project/template/ios-share-extension/files/resources/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/lib/motion/project/template/ios-today-extension/files/Rakefile.erb b/lib/motion/project/template/ios-today-extension/files/Rakefile.erb index e51dd8b0..04480220 100644 --- a/lib/motion/project/template/ios-today-extension/files/Rakefile.erb +++ b/lib/motion/project/template/ios-today-extension/files/Rakefile.erb @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- $:.unshift("/Library/RubyMotion/lib") -require 'motion/project/template/ios-extension.rb' +require 'motion/project/template/ios-extension' begin require 'bundler'