When we write some code, we don’t think about reusable code.Just start to create multiple copies of that project. Many of times we need same code or classes in different projects then we start making copies of that files and moving that copies here and there. There is the solution to use single project creates multiple targets for that.Here question arises what are targets.So here are the steps to create and use multiple targets in Xcode:-
1 2 3 4 5 6 7 8 9 10 11 |
enum EnvironmentType { case normal, marketplace } #if MARKETPLACE static let serverUrl = "Your Url" static let environment:EnvironmentType = .marketplace #else static let serverUrl = "Your Url" static let environment:EnvironmentType = .normal #endif |
1 2 3 4 5 6 7 8 9 10 11 12 |
switch environment { case .marketplace: let filePath = Bundle.main.path(forResource: "GoogleService-InfoMP", ofType: "plist") if let options = FirebaseOptions(contentsOfFile: filePath!) { FirebaseApp.configure(options: options) } case .mobikul: let filePath = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")! if let options = FirebaseOptions(contentsOfFile: filePath) { FirebaseApp.configure(options: options) } } |
So you have successfully added a stretchy header in your app.
Thanks for go through this blog. Stay cool and stay updated.
Be the first to comment.