-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: configuration management #158
Conversation
…shlytics google app id, remove process_config.sh in favour of build script
…e scheme and a default config
@rnr @volodymyr-chekyrta @saeedbashir I have updated the implementation to use Xcode schemes that are currently being used. i have updated the description with these changes. |
@volodymyr-chekyrta would like your opinion here. What @rnr is proposing is more elegant and straight forward that involves less steps. I suggest we go with that. The concerns about community raised by @saeedbashir can be addressed if we make clear documentation on how to configure. @rnr can add these changes but want to make sure we are aligned. |
I and @rnr had a discussion on it, and we agreed on a structure. Today we'll be making the changes and then this PR will be ready for final pass. |
fix: fix documentation link fix: fix documentation link fix: remove type fix: remove type fix: cleanup
b57e313
to
dbb2155
Compare
@rnr @volodymyr-chekyrta i have made the changes that we agreed on, the PR is ready for review. |
|
||
extension Config: ConfigProtocol { | ||
public var baseURL: URL { | ||
return URL(string: string(for: ConfigKeys.baseURL.rawValue)!)! |
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.
Hello @mumer92
Could we avoid force unwrapping here?
Thank you
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 understand baseURL is important part and we need to have this
maybe it can be something like
public var baseURL: URL {
if let string = string(for: ConfigKeys.baseURL.rawValue),
let url = URL(string: string) {
return url
}
fatalError("Can't find baseURL in Config!")
}
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 used convention that was being followed in project, i think we can use guard let here and return URL(string "")
instead of doing fataError
, what are your thoughts?
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 am not in favour of fataError()
, i think app should handle issue gracefully.
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.
@mumer92 code we have now (with force unwrapping) will just crash if baseURL is not present in config.
URL(string: "") also returns nil and will crash with force unwrapping
I understand app can't work without baseURL - we need to try to show what is the problem exactly (fatalError show a message at least). It could be some Log etc. Just provide issue description.
I'm open to any options without force unwrapping.
What do you think?
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.
URL(string: "")! produces crash
why this Crash is better than "Crash with message"? )
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.
alright i will add fatalError("Can't find baseURL in Config!")
, in the mean time you can continue with other changes for the review.
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.
all other looks good for me. good work @mumer92 !
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.
@rnr i have updated it. please have a look.
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.
@mumer92 approved
thank you
I played around with configurations a bit and it works amazing 🚀🚀🚀 |
@volodymyr-chekyrta i have addressed the feedback. |
Green light from me 🟢 🚀 |
Project Configuration Management
This PR introduces a way to integrate and manage config files for iOS project.
process_config.py
with$CONFIGURATION
andscheme_mappings
argument.Info.plist
(e.g., Facebook, Microsoft keys).GoogleServices.plist
with Firebase keys.config.plist
fromios.yaml
and shared.yaml.Inside
Config.swift
parsing and populating relevant keys and classes are done, e.g.AgreementConfig.swift
andFirebaseConfig.swift
Get started:
Edit a
config_settings.yaml
in thedefault_config
folder.It should contain data as follows
config_directory
provides path of config directoryconfig_mappings
provides provides mappings that can be utilized to map Xcode build scheme map to a defined folder within config directory and it will be referenced.Config files are separated out in 2 files
ios.yaml
andshared.yaml
both configs should be placed under a folder which will be referenced inside
config_settings.yaml
inside of the keyconfig_mappings:{config_directory_name}
inside
config_directory
,mappings.yaml
which contains yaml files that will be used to read available yaml files and processed inside script.it is structure will be as follows:
ios.yaml
will contain config data specific to iOS, e.g.Firebase
keys,Facebook
keys, etc.shared.yaml
will contain config data that is shared, e.g.API_HOST_URL
,OAUTH_CLIENT_ID
,TOKEN_TYPE
, etcFuture Support:
ServiceNameConfig.swift
to be able to populate related fieldsextension
to Config.swift to be able to add the newly created service as a varable to main Config.ConfigProtocol
so that config is available usingConfigProtocol
service.e.g.
Note
This PR also updates
FirebaseCrashlytics
build phaseUpdated build phase script extracts
googleAppID
from the newly generatedGoogleService-Info.plist
and runs the crashlytics script with the provided id.Examples of config files:
ios.yaml
shared.yaml
default_config
directory is added to project to get an idea on how to write config yaml files.