Customizable app group plugin
Shell Ruby Swift Objective-C
Switch branches/tags
Clone or download
mzp Merge pull request #2 from mzp/swift3
Update to  swift3
Latest commit 20b82c5 Dec 10, 2016

README.md

cocoapods-app_group

This plugin provide customizable app group.

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.

Requirements

  • CocoaPods 0.36

Installation

gem install cocoapods-app_group

Setup

1. Setup Podfile

Put followings to Podfile:

target 'WriteToAppGroup'
target 'ReadFromAppGroup'

plugin 'cocoapods-app_group'

Then running pod install will prompt for the keys not yet set and you can ensure everyone has the same setup.

2. Save app group name

Save group name by running following command:

pod app-group GROUP_NAME

3. Generate wrapper class

Generate wrapper class by running following command:

pod install

4. Enable app group of each target

Open *.xcworkspace and enable app group of each target. Use group.$(APP_IDENTIFIER) as app group name.

5. Write code

Write code using wrapper class:

#import <Foundation/Foundation.h>

@interface AppGroup : NSObject
+ (NSString *)appGroupID;
+ (NSString *)pathForResource:(NSString *)subpath;
+ (NSUserDefaults*)userDefaults;
@end

Using at swift project

Using the bridge header

If you want to make your keys available to your whole project:

  1. Make sure you have a bridging header already setup.
  2. In the bridging header, import the generated key file:
#import <AppGroup/AppGroup.h>

Importing the framework

If you've added the use_frameworks! and only want your Keys to be available in specific files, simply use Swift's import statement. The name of the generated module is AppGroup.

import AppGroup

Thanks

This was built with a lot of help from @banjun.

How to work

I explain how to work at Japanese document.

License

The gem is available as open source under the terms of the MIT License.