-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
12c1bdf
to
87b8502
Compare
87b8502
to
8f92414
Compare
@@ -61,19 +85,6 @@ typealias resultsForConfigClosure = ([PermissionResult]) -> Void | |||
public let contentView = UIView() | |||
|
|||
// MARK: - Various lazy managers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this // MARK
anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed in new pr
@@ -1003,7 +1075,8 @@ typealias resultsForConfigClosure = ([PermissionResult]) -> Void | |||
onCancel = cancelled | |||
|
|||
DispatchQueue.main.async { | |||
while self.waitingForBluetooth || self.waitingForMotion { } | |||
while | |||
self.waitingForBluetooth || self.waitingForMotion { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions here:
- Is this the preferred indentation? (Not necessarily opposed, just wondering why it was changed.)
- Is this busy-waiting on the main thread? I realize this is existing code, but it still seems strange to me. Should we be concerned about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- looks like that indent was my mistake.
- Yea, it is strange looking at it now. Is it also saying that if waitingForBluetooth is true, execute the blank
{ }
I wonder what the point of that is? The next lineself.requiredAuthorized({ areAuthorized
gets called regardless, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm understanding it correctly, it will continue looping (and doing nothing) until both the waiting vars are false.
@@ -22,6 +53,8 @@ import Foundation | |||
} | |||
|
|||
public var description: String { | |||
/* TODO: This will not compile when used in a project (unless project is asking ALL permissions) because any permission that is not used will have it's enum undefined due to the #ifendif statements around the enum definition above. | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this doesn't compile, is the goal to address that issue before merging this PR? Or merge as-is? I usually think it's best to avoid merging into master with commits that don't compile, since that can cause headaches for things like git bisect
.
Also do we have a workaround for this? The multiple if
pattern that Ying suggested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR will compile itself. But if you were to use this pod in a project, that project would not compile.
Currently working on the if
pattern.
rem.pod_target_xcconfig = feature_flags | ||
rem.user_target_xcconfig = feature_flags | ||
end | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
This is an attempt to fix issue: nickoneill#194
It is modeled after this solution used by a similar framework: https://github.com/iosphere/ISHPermissionKit/pull/80/files
In short, the problem is that the framework imports all libraries necessary for all permissions it supports (camera, location, bluetooth, etc), and any app using this library will get automatically rejected if they do not provide ALL plist descriptions - even for the permissions they are not requesting within their app.
The solution is to hack around with subspecs to define flags that will signal the pod which libraries to import.
The TODO found in this PR illustrates a potential problem with this solution and also the reason why a project using this pod won't build. Swift does not allow you to put #if #endif around switch cases. This is a documented bug: https://bugs.swift.org/browse/SR-2
A workaround for this, proposed by Ying is:
Another solution is to break each permission into it's own framework. This morning the main repo owner replied to me and said that this would be the right way to go.
Ying supports going the "ThingDetail" struct route. But after hearing from the repo owner, I think trying to break this into separate frameworks should be the route - as this would be the one he would like to merge in the end.