Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

Fix permissions #209

Closed
wants to merge 1 commit into from

Conversation

alanscarpa
Copy link

This is an attempt to fix issue: #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:

struct ThingDetail {
    var description = ""
    var permissions: String?
}

var thingDetailOne = ThingDetail(description: "one", permissions: "")
var thingDetailTwo = ThingDetail(description: "two", permissions: "")

enum Thing {
    case one
    #if ENABLE_TWO
    case two
    #endif

    var thingDetail: ThingDetail {
        if self == .one {
            return thingDetailOne
        }
        #if ENABLE_TWO
        if self == .two {
            return thingDetailTwo
        }
        #endif
        return ThingDetail()
    }
}

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.

@alanscarpa alanscarpa closed this Nov 18, 2016
@alanscarpa alanscarpa deleted the alan/fixPermissions branch November 18, 2016 18:57
@alanscarpa alanscarpa restored the alan/fixPermissions branch November 18, 2016 18:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant