Skip to content

Commit

Permalink
fixed issue robertwijas#56 - app extension support added by defining …
Browse files Browse the repository at this point in the history
…preprocessor macro ‘UISS_APP_EXTENSIONS’ && defining in podspec file a new subspec about app extensions
  • Loading branch information
Konstantinos Tsichlis committed Jul 5, 2017
1 parent 20260c9 commit 0bd8a6c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
8 changes: 6 additions & 2 deletions Project/UISS/UISS.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,15 @@ - (void)loadStyleSynchronously {

- (void)refreshViews {
[[NSNotificationCenter defaultCenter] postNotificationName:UISSWillRefreshViewsNotification object:self];

#if !defined(UISS_APP_EXTENSIONS)
//This code is not available for app extensions (see today extension)
for (UIWindow *window in [UIApplication sharedApplication].windows) {
for (UIView *view in window.subviews) {
[view removeFromSuperview];
[window addSubview:view];
}
}

#endif
[[NSNotificationCenter defaultCenter] postNotificationName:UISSDidRefreshViewsNotification object:self];
}

Expand Down Expand Up @@ -286,6 +287,8 @@ - (void)statusWindowControllerDidSelect:(UISSStatusViewController *)statusWindow
}

- (void)presentConsoleViewController {
#if !defined(UISS_APP_EXTENSIONS)
//This code is not available for app extensions (see today extension)
UISSConsoleViewController *consoleViewController = [[UISSConsoleViewController alloc] initWithUISS:self];
consoleViewController.modalPresentationStyle = UIModalPresentationFormSheet;

Expand All @@ -302,6 +305,7 @@ - (void)presentConsoleViewController {
} else {
[presentingViewController presentViewController:consoleViewController animated:YES completion:nil];
}
#endif
}

@end
5 changes: 4 additions & 1 deletion Project/UISS/UISSSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
UISSSettingDescriptor *settingDescriptor = self.settingDescriptors[(NSUInteger) indexPath.section];

if (settingDescriptor.editorType == UISSSettingDescriptorEditorTypeText) {
#if !defined(UISS_APP_EXTENSIONS)
//This code is not available for app extensions (see today extension)
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Change Setting"
message:settingDescriptor.title
delegate:self
Expand All @@ -160,6 +162,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
textField.keyboardType = settingDescriptor.keyboardType;

[alertView show];
#endif
}
}

Expand All @@ -183,4 +186,4 @@ - (void)switchAccessoryViewValueChanged:(UISwitch *)switchAccessoryView {
settingDescriptor.valueChangeHandler(@(switchAccessoryView.on));
}

@end
@end
12 changes: 11 additions & 1 deletion Project/UISS/UISSStatusWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ - (void)dealloc

- (id)init
{
#if !defined(UISS_APP_EXTENSIONS)
//This code is not available for app extensions (see today extension)
self = [super initWithFrame:[UIApplication sharedApplication].statusBarFrame];
#else
self = [super initWithFrame:CGRectZero];
#endif
self.clipsToBounds = YES;
self.backgroundColor = [UIColor clearColor];
if (self) {
Expand All @@ -37,9 +42,14 @@ - (void)didChangeStatusBarFrame:(NSNotification *)notification;
});
}

- (void)updateLayout;
- (void)updateLayout
{
#if !defined(UISS_APP_EXTENSIONS)
//This code is not available for app extensions (see today extension)
self.frame = [self frameForOrientation:[UIApplication sharedApplication].statusBarOrientation];
#else
self.frame = [self frameForOrientation:UIInterfaceOrientationUnknown];
#endif
self.rootViewController.view.frame = self.bounds;
}

Expand Down
14 changes: 12 additions & 2 deletions UISS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ Pod::Spec.new do |s|

s.source = { :git => 'https://github.com/robertwijas/UISS.git', :tag => "#{s.version}" }

s.source_files = 'Project/UISS'
s.resources = 'Project/UISSResources.bundle'
s.prefix_header_file = 'Project/UISS/UISS-Prefix.pch'

s.frameworks = 'Foundation', 'UIKit'

s.requires_arc = true
s.default_subspec = 'Core'

s.subspec 'Core' do |core|
core.source_files = 'Project/UISS'
core.requires_arc = true
end

s.subspec 'Extensions' do |ext|
ext.dependency 'UISS/Core'
ext.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'UISS_APP_EXTENSIONS' }
end

end

0 comments on commit 0bd8a6c

Please sign in to comment.