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

Fix permissions w/out moving them into separate files #1

Closed
wants to merge 1 commit into from
Closed
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
87 changes: 87 additions & 0 deletions PermissionScope.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,91 @@ Pod::Spec.new do |s|
s.source_files = 'PermissionScope/*.swift'

s.requires_arc = true

s.default_subspec = 'Core'

s.subspec 'Core' do |core|
core.source_files = 'PermissionScope/*.{swift,h}'
end

s.subspec 'Motion' do |motion|
motion.dependency 'PermissionScope/Core'
motion.weak_framework = 'CoreMotion'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestMotionEnabled' }
motion.pod_target_xcconfig = feature_flags
motion.user_target_xcconfig = feature_flags
end

s.subspec 'Bluetooth' do |bluetooth|
bluetooth.dependency 'PermissionScope/Core'
bluetooth.weak_framework = 'CoreBluetooth'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestBluetoothEnabled' }
bluetooth.pod_target_xcconfig = feature_flags
bluetooth.user_target_xcconfig = feature_flags
end

s.subspec 'Location' do |location|
location.dependency 'PermissionScope/Core'
location.weak_framework = 'CoreLocation'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestLocationEnabled' }
location.pod_target_xcconfig = feature_flags
location.user_target_xcconfig = feature_flags
end

s.subspec 'Microphone' do |mic|
mic.dependency 'PermissionScope/Core'
mic.weak_framework = 'AVFoundation'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestMicrophoneEnabled' }
mic.pod_target_xcconfig = feature_flags
mic.user_target_xcconfig = feature_flags
end

s.subspec 'PhotoLibrary' do |photo|
photo.dependency 'PermissionScope/Core'
photo.weak_framework = 'Photos', 'AssetsLibrary'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestPhotoLibraryEnabled' }
photo.pod_target_xcconfig = feature_flags
photo.user_target_xcconfig = feature_flags
end

s.subspec 'Camera' do |cam|
cam.dependency 'PermissionScope/Core'
cam.weak_framework = 'AVFoundation'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestCameraEnabled' }
cam.pod_target_xcconfig = feature_flags
cam.user_target_xcconfig = feature_flags
end

s.subspec 'Notifications' do |note|
note.dependency 'PermissionScope/Core'
note.weak_framework = 'UIKit', 'UserNotifications'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestNotificationsEnabled' }
note.pod_target_xcconfig = feature_flags
note.user_target_xcconfig = feature_flags
end

s.subspec 'Contacts' do |contacts|
contacts.dependency 'PermissionScope/Core'
contacts.weak_framework = 'Contacts', 'AddressBook'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestContactsEnabled' }
contacts.pod_target_xcconfig = feature_flags
contacts.user_target_xcconfig = feature_flags
end

s.subspec 'Events' do |cal|
cal.dependency 'PermissionScope/Core'
cal.weak_framework = 'EventKit'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestEventsEnabled' }
cal.pod_target_xcconfig = feature_flags
cal.user_target_xcconfig = feature_flags
end

s.subspec 'Reminders' do |rem|
rem.dependency 'PermissionScope/Core'
rem.weak_framework = 'EventKit'
feature_flags = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'PermissionScopeRequestRemindersEnabled' }
rem.pod_target_xcconfig = feature_flags
rem.user_target_xcconfig = feature_flags
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool setup. 👍

Have we tested yet with mixing/matching the subspecs to make sure that the flags are combined correctly?

I wonder if there's a terser, DRY-er way to define the subspecs without duplicating the stuff they have in common, but maybe that'd be too fancy.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I wonder if i can find something.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested that installing pod PermissionScope/Motion sets the correct flag, if that's what you mean.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly meant checking that we can build with 2 of the subspecs at the same time and get both flags, without them interfering with each other somehow.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I just installed multiple subspecs and all flags were set correctly.

end
4 changes: 4 additions & 0 deletions PermissionScope.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,11 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
OTHER_SWIFT_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.thatthinginswift.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = PermissionScope;
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "PermissionScopeRequestMotionEnabled PermissionScopeRequestBluetoothEnabled PermissionScopeRequestLocationEnabled PermissionScopeRequestMicrophoneEnabled PermissionScopeRequestPhotoLibraryEnabled PermissionScopeRequestCameraEnabled PermissionScopeRequestNotificationsEnabled PermissionScopeRequestContactsEnabled PermissionScopeRequestEventsEnabled PermissionScopeRequestRemindersEnabled";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
Expand All @@ -613,9 +615,11 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
OTHER_SWIFT_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.thatthinginswift.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = PermissionScope;
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "PermissionScopeRequestMotionEnabled PermissionScopeRequestBluetoothEnabled PermissionScopeRequestLocationEnabled PermissionScopeRequestMicrophoneEnabled PermissionScopeRequestPhotoLibraryEnabled PermissionScopeRequestCameraEnabled PermissionScopeRequestNotificationsEnabled PermissionScopeRequestContactsEnabled PermissionScopeRequestEventsEnabled PermissionScopeRequestRemindersEnabled";
SWIFT_VERSION = 3.0;
};
name = Release;
Expand Down
Loading