cocoapods-app_group 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Example/.cocoapods_appgroup +1 -0
  7. data/Example/Example.xcodeproj/project.pbxproj +524 -0
  8. data/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  9. data/Example/Example.xcodeproj/project.xcworkspace/xcuserdata/mzp.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  10. data/Example/Example.xcodeproj/xcuserdata/mzp.xcuserdatad/xcschemes/Example.xcscheme +91 -0
  11. data/Example/Example.xcodeproj/xcuserdata/mzp.xcuserdatad/xcschemes/xcschememanagement.plist +32 -0
  12. data/Example/Example.xcworkspace/contents.xcworkspacedata +10 -0
  13. data/Example/Example/AppDelegate.swift +46 -0
  14. data/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +38 -0
  15. data/Example/Example/Base.lproj/LaunchScreen.storyboard +27 -0
  16. data/Example/Example/Base.lproj/Main.storyboard +25 -0
  17. data/Example/Example/Info.plist +40 -0
  18. data/Example/Example/ViewController.swift +28 -0
  19. data/Example/Podfile +6 -0
  20. data/Example/Podfile.lock +14 -0
  21. data/Example/Pods/CocoaPodsAppGroup/AppGroup.h +7 -0
  22. data/Example/Pods/CocoaPodsAppGroup/AppGroup.m +23 -0
  23. data/Example/Pods/CocoaPodsAppGroup/AppGroup.podspec.json +24 -0
  24. data/Example/Pods/Headers/Private/AppGroup/AppGroup.h +7 -0
  25. data/Example/Pods/Local Podspecs/AppGroup.podspec.json +24 -0
  26. data/Example/Pods/Manifest.lock +14 -0
  27. data/Example/Pods/Pods.xcodeproj/project.pbxproj +505 -0
  28. data/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/AppGroup.xcscheme +62 -0
  29. data/Example/Pods/Target Support Files/AppGroup/AppGroup-Private.xcconfig +6 -0
  30. data/Example/Pods/Target Support Files/AppGroup/AppGroup-dummy.m +5 -0
  31. data/Example/Pods/Target Support Files/AppGroup/AppGroup-prefix.pch +4 -0
  32. data/Example/Pods/Target Support Files/AppGroup/AppGroup-umbrella.h +7 -0
  33. data/Example/Pods/Target Support Files/AppGroup/AppGroup.modulemap +6 -0
  34. data/Example/Pods/Target Support Files/AppGroup/AppGroup.xcconfig +1 -0
  35. data/Example/Pods/Target Support Files/AppGroup/Info.plist +26 -0
  36. data/Example/Pods/Target Support Files/Pods/Info.plist +26 -0
  37. data/Example/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown +7 -0
  38. data/Example/Pods/Target Support Files/Pods/Pods-acknowledgements.plist +37 -0
  39. data/Example/Pods/Target Support Files/Pods/Pods-dummy.m +5 -0
  40. data/Example/Pods/Target Support Files/Pods/Pods-frameworks.sh +59 -0
  41. data/Example/Pods/Target Support Files/Pods/Pods-resources.sh +95 -0
  42. data/Example/Pods/Target Support Files/Pods/Pods-umbrella.h +6 -0
  43. data/Example/Pods/Target Support Files/Pods/Pods.debug.xcconfig +7 -0
  44. data/Example/Pods/Target Support Files/Pods/Pods.modulemap +6 -0
  45. data/Example/Pods/Target Support Files/Pods/Pods.release.xcconfig +7 -0
  46. data/Example/ReadFromAppGroup/AppDelegate.swift +46 -0
  47. data/Example/ReadFromAppGroup/Assets.xcassets/AppIcon.appiconset/Contents.json +38 -0
  48. data/Example/ReadFromAppGroup/Base.lproj/LaunchScreen.storyboard +27 -0
  49. data/Example/ReadFromAppGroup/Base.lproj/Main.storyboard +25 -0
  50. data/Example/ReadFromAppGroup/Info.plist +40 -0
  51. data/Example/ReadFromAppGroup/ReadFromAppGroup.entitlements +10 -0
  52. data/Example/ReadFromAppGroup/ViewController.swift +26 -0
  53. data/Example/WriteToAppGroup.entitlements +10 -0
  54. data/Gemfile +6 -0
  55. data/LICENSE.txt +21 -0
  56. data/README.md +90 -0
  57. data/Rakefile +6 -0
  58. data/bin/console +14 -0
  59. data/bin/setup +7 -0
  60. data/cocoapods-app_group.gemspec +25 -0
  61. data/lib/cocoapods/app_group.rb +6 -0
  62. data/lib/cocoapods/app_group/hook.rb +18 -0
  63. data/lib/cocoapods/app_group/setup.rb +58 -0
  64. data/lib/cocoapods/app_group/store.rb +41 -0
  65. data/lib/cocoapods/app_group/template.rb +27 -0
  66. data/lib/cocoapods/app_group/version.rb +5 -0
  67. data/lib/cocoapods_plugin.rb +1 -0
  68. data/lib/pod/command/app_group.rb +31 -0
  69. data/templates/AppGroup.h +7 -0
  70. data/templates/AppGroup.m +23 -0
  71. data/templates/AppGroup.podspec.json +24 -0
  72. metadata +158 -0
@@ -0,0 +1,38 @@
1
+ {
2
+ "images" : [
3
+ {
4
+ "idiom" : "iphone",
5
+ "size" : "29x29",
6
+ "scale" : "2x"
7
+ },
8
+ {
9
+ "idiom" : "iphone",
10
+ "size" : "29x29",
11
+ "scale" : "3x"
12
+ },
13
+ {
14
+ "idiom" : "iphone",
15
+ "size" : "40x40",
16
+ "scale" : "2x"
17
+ },
18
+ {
19
+ "idiom" : "iphone",
20
+ "size" : "40x40",
21
+ "scale" : "3x"
22
+ },
23
+ {
24
+ "idiom" : "iphone",
25
+ "size" : "60x60",
26
+ "scale" : "2x"
27
+ },
28
+ {
29
+ "idiom" : "iphone",
30
+ "size" : "60x60",
31
+ "scale" : "3x"
32
+ }
33
+ ],
34
+ "info" : {
35
+ "version" : 1,
36
+ "author" : "xcode"
37
+ }
38
+ }
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
3
+ <dependencies>
4
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
5
+ </dependencies>
6
+ <scenes>
7
+ <!--View Controller-->
8
+ <scene sceneID="EHf-IW-A2E">
9
+ <objects>
10
+ <viewController id="01J-lp-oVM" sceneMemberID="viewController">
11
+ <layoutGuides>
12
+ <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
13
+ <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
14
+ </layoutGuides>
15
+ <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
16
+ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
17
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18
+ <animations/>
19
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
20
+ </view>
21
+ </viewController>
22
+ <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
23
+ </objects>
24
+ <point key="canvasLocation" x="53" y="375"/>
25
+ </scene>
26
+ </scenes>
27
+ </document>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
3
+ <dependencies>
4
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
5
+ </dependencies>
6
+ <scenes>
7
+ <!--View Controller-->
8
+ <scene sceneID="tne-QT-ifu">
9
+ <objects>
10
+ <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
11
+ <layoutGuides>
12
+ <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
13
+ <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
14
+ </layoutGuides>
15
+ <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
16
+ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
17
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
19
+ </view>
20
+ </viewController>
21
+ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
22
+ </objects>
23
+ </scene>
24
+ </scenes>
25
+ </document>
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>en</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>APPL</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleSignature</key>
20
+ <string>????</string>
21
+ <key>CFBundleVersion</key>
22
+ <string>1</string>
23
+ <key>LSRequiresIPhoneOS</key>
24
+ <true/>
25
+ <key>UILaunchStoryboardName</key>
26
+ <string>LaunchScreen</string>
27
+ <key>UIMainStoryboardFile</key>
28
+ <string>Main</string>
29
+ <key>UIRequiredDeviceCapabilities</key>
30
+ <array>
31
+ <string>armv7</string>
32
+ </array>
33
+ <key>UISupportedInterfaceOrientations</key>
34
+ <array>
35
+ <string>UIInterfaceOrientationPortrait</string>
36
+ <string>UIInterfaceOrientationLandscapeLeft</string>
37
+ <string>UIInterfaceOrientationLandscapeRight</string>
38
+ </array>
39
+ </dict>
40
+ </plist>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>com.apple.security.application-groups</key>
6
+ <array>
7
+ <string>group.$(APP_IDENTIFIER)</string>
8
+ </array>
9
+ </dict>
10
+ </plist>
@@ -0,0 +1,26 @@
1
+ //
2
+ // ViewController.swift
3
+ // ReadFromAppGroup
4
+ //
5
+ // Created by mzp on 9/22/15.
6
+ // Copyright © 2015 mzp. All rights reserved.
7
+ //
8
+
9
+ import UIKit
10
+ import AppGroup
11
+
12
+ class ViewController: UIViewController {
13
+ override func viewDidLoad() {
14
+ super.viewDidLoad()
15
+ NSLog("%@", AppGroup.appGroupID())
16
+ NSLog("%d", AppGroup.userDefaults().integerForKey("answer"))
17
+ }
18
+
19
+ override func didReceiveMemoryWarning() {
20
+ super.didReceiveMemoryWarning()
21
+ // Dispose of any resources that can be recreated.
22
+ }
23
+
24
+
25
+ }
26
+
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>com.apple.security.application-groups</key>
6
+ <array>
7
+ <string>group.$(APP_IDENTIFIER)</string>
8
+ </array>
9
+ </dict>
10
+ </plist>
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-app_group.gemspec
4
+ gemspec
5
+
6
+ gem 'cocoapods'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 mzp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # cocoapods-app_group
2
+
3
+ This plugin provide customizable app group.
4
+
5
+ Because app group is strong bound to AppleID, it is hard to distribute iOS project using app group. This plugin enable each user to customize app group name at setup phase. This make easy to distribute your iOS project.
6
+
7
+ ## Requirements
8
+
9
+ * CocoaPods 0.36
10
+
11
+ ## Installation
12
+
13
+ ```
14
+ gem install cocoapods-app_group
15
+ ```
16
+
17
+ ## Setup
18
+ ### 1. Setup Podfile
19
+ Put followings to `Podfile`:
20
+
21
+ ```ruby
22
+ plugin 'cocoapods-app_group'
23
+
24
+ # or specify targets
25
+ # plugin 'cocoapods-app_group', targets: ['Foo', 'Bar']
26
+ ```
27
+
28
+ Then running `pod install` will prompt for the keys not yet set and you can ensure everyone has the same setup.
29
+
30
+ ### 2. Save app group name
31
+ Save group name by running following command:
32
+
33
+ ```
34
+ pod app-group GROUP_NAME
35
+ ```
36
+
37
+ ### 3. Generate wrapper class
38
+ Generate wrapper class by running following command:
39
+
40
+ ```
41
+ pod install
42
+ ```
43
+
44
+ ### 4. Enable app group of each target
45
+ Open `*.xcworkspace` and enable app group of each target. Use `group.$(APP_IDENTIFIER)` as app group name.
46
+
47
+ ### 5. Write code
48
+ Write code using wrapper class:
49
+
50
+ ```objc
51
+ #import <Foundation/Foundation.h>
52
+
53
+ @interface AppGroup : NSObject
54
+ + (NSString *)appGroupID;
55
+ + (NSString *)pathForResource:(NSString *)subpath;
56
+ + (NSUserDefaults*)userDefaults;
57
+ @end
58
+ ```
59
+
60
+ ## Using at swift project
61
+ ### Using the bridge header
62
+
63
+ If you want to make your keys available to your whole project:
64
+
65
+ 1. Make sure you have a [bridging header](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html) already setup.
66
+ 2. In the bridging header, import the generated key file:
67
+ ```objectivec
68
+ #import <AppGroup/AppGroup.h>
69
+ ```
70
+
71
+ ### Importing the framework
72
+
73
+ If you've added the `use_frameworks!` and only want your Keys to be available in
74
+ specific files, simply use Swift's `import` statement. The name of the generated
75
+ module is `AppGroup`.
76
+
77
+ ```swift
78
+ import AppGroup
79
+ ```
80
+
81
+ ## Thanks
82
+ This was built with a lot of help from [@banjun](https://github.com/banjun).
83
+
84
+ ## How to work
85
+ I explain how to work at [Japanese document](http://qiita.com/mzp/items/b5a9dda2d01e18655cbf).
86
+
87
+ ## License
88
+
89
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
90
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cocoapods/app_group"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods/app_group/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cocoapods-app_group"
8
+ spec.version = Cocoapods::AppGroup::VERSION
9
+ spec.authors = ["mzp"]
10
+ spec.email = ["mzpppp@gmail.com"]
11
+
12
+ spec.summary = "Customizable app group plugin"
13
+ spec.description = "Because app group is strong bound to AppleID, it is hard to distribute iOS project using app group. This plugin enable each user to customize app group name at setup phase. This make easy to distribute your iOS project."
14
+ spec.homepage = "https://github.com/mzp/cocoapods-app_group"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ end
@@ -0,0 +1,6 @@
1
+ require 'cocoapods/app_group/hook'
2
+ require 'cocoapods/app_group/setup'
3
+ require 'cocoapods/app_group/store'
4
+ require 'cocoapods/app_group/template'
5
+ require 'cocoapods/app_group/version'
6
+ require 'pod/command/app_group'
@@ -0,0 +1,18 @@
1
+ module CocoaPods
2
+ module AppGroup
3
+ module Hook
4
+ def install!
5
+ Setup.new.call if enabled?
6
+ super
7
+ end
8
+
9
+ private
10
+
11
+ def enabled?
12
+ podfile && podfile.plugins && !podfile.plugins['cocoapods-app_group'].nil?
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ Pod::Installer.prepend CocoaPods::AppGroup::Hook
@@ -0,0 +1,58 @@
1
+ module CocoaPods
2
+ module AppGroup
3
+ class Setup
4
+ def call
5
+ FileUtils.mkdir_p pod_path
6
+
7
+ %w(AppGroup.podspec.json AppGroup.h AppGroup.m).each do |name|
8
+ Template.new(template(name)).call pod_path.join(name)
9
+ end
10
+
11
+ add_to_targets pod_path.relative_path_from(root)
12
+ end
13
+
14
+ private
15
+
16
+ def add_to_targets(path, targets: nil)
17
+ if targets
18
+ # Iterate through each target specified in the Keys plugin
19
+ targets.each do |target|
20
+ # Find a matching Pod target
21
+ pod_target = podfile.root_target_definitions.flat_map(&:children).find do |target|
22
+ target.label == "Pods-#{target}"
23
+ end
24
+
25
+ if pod_target
26
+ pod_target.store_pod 'AppGroup', path: pod_path.to_path
27
+ else
28
+ Pod::UI.puts "Could not find a target named '#{target}' in your Podfile. Stopping keys".red
29
+ end
30
+ end
31
+ else
32
+ # otherwise let it go in global
33
+ podfile.pod 'AppGroup', path: pod_path.to_path
34
+ end
35
+ end
36
+
37
+ def root
38
+ Pod::Config.instance.installation_root
39
+ end
40
+
41
+ def pod_path
42
+ root.+('Pods/CocoaPodsAppGroup/')
43
+ end
44
+
45
+ def template(name)
46
+ Pathname(__dir__) + '../../../templates' + name
47
+ end
48
+
49
+ def podfile
50
+ Pod::Config.instance.podfile
51
+ end
52
+
53
+ def options
54
+ podfile.plugins['cocoapods-app_group']
55
+ end
56
+ end
57
+ end
58
+ end