Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share bundle between app and extension #26

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AppHub/AppHub/AHBuildManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ extern NSString *const AHBuildManagerBuildKey;
*/
- (void)fetchBuildWithCompletionHandler:(AHBuildResultBlock)completionHandler;

- (AHBuild *)currentBuildForGroupIdentifier:(NSString *)groupIdentifier;

/**
* Hook called after NSURLSessionDownloadTask has created
*
Expand Down
6 changes: 6 additions & 0 deletions AppHub/AppHub/AHBuildManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ - (NSDictionary *)currentBuildInfo
return [NSDictionary dictionaryWithContentsOfURL:AHCurrentBuildInfoDirectory()];
}

- (AHBuild *)currentBuildForGroupIdentifier:(NSString *)groupIdentifier {
ahGroupIdentifier = groupIdentifier;

return [self currentBuild];
}

- (AHBuild *)currentBuild
{
NSDictionary *currentBuildInfo = [self currentBuildInfo];
Expand Down
2 changes: 2 additions & 0 deletions AppHub/AppHub/AHPaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ extern NSURL *AHBundleDirectory(NSString *buildID);
extern NSURL *AHCurrentBuildInfoDirectory(void);
extern NSURL *AHBuildsDirectory(void);
extern NSURL *AHRootDirectory(void);

extern NSString *ahGroupIdentifier;
8 changes: 7 additions & 1 deletion AppHub/AppHub/AHPaths.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import "AHConstants.h"

NSString *ahGroupIdentifier = nil;

NSURL *AHBuildDirectory(NSString *buildID)
{
return [AHBuildsDirectory() URLByAppendingPathComponent:buildID isDirectory:YES];
Expand All @@ -31,5 +33,9 @@

NSURL *AHRootDirectory(void)
{
return [[[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject] URLByAppendingPathComponent:AHDirectoryName isDirectory:YES];
if(ahGroupIdentifier == nil) {
return [[[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject] URLByAppendingPathComponent:AHDirectoryName isDirectory:YES];
} else {
return [[[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:ahGroupIdentifier] URLByAppendingPathComponent: AHDirectoryName isDirectory:YES];
}
}