Reputation: 2245
I have a problem in Swift... but let me first describe Objective-C solution that worked fine:
In Objective-C I created header file Developer.h which had some developer specific #defines
#define DEV_USERNAME @"dev_username"
#define DEV_PASSWORD @"dev_password"
This filled up login fields with default values so I didn't need to type username and password each time.
Developer.h was excluded from GIT repository, so each developer working on the project could enter their own login details and that wouldn't be overwritten on each commit/push.
If repo was newly cloned Developer.h was not present in the project (red color of file in Xcode) but project still successfully built since header files are not required for a successful build.
So I tried to do same thing in Swift by creating Developer.swift file with to constants
let DEV_USERNAME = "dev_username"
let DEV_PASSWORD = "dev_password"
Now I'm facing the problem of file not being present when project is newly cloned. That means newly cloned build fails in Xcode since .swift sources are required for a successful build.
Just wanted to ask if anyone has a solution for this problem. Either make particular swift file "optional" to compile ... or some GIT solution (that pulls Developer.swift file only first time at clone and then it doesn't touch it anymore)
Upvotes: 2
Views: 574
Reputation: 2170
As this answer :
https://stackoverflow.com/a/1753078/1616513
Notes you can ignore a file only locally. So after a dev pulls the code he needs to navigate to .git/info/exclude
and add the file to that file. It's syntax is same as the git ignore file.
This command may not immediately take effect so run
git update-index --assume-unchanged /path/to/nameOfTheFile.swift
Now you can have the file added to the project and version control but once they devs do this they dont have to worry about accidentally committing it to master.
Upvotes: 2