Xcode project name spaces, what's the best practice?

I am creating a new Xcode project and the name will contain a space, for example "Foo Bar". I tend to call it "Foo Bar" because it is the actual name of the application, as it appears in the top menu, file system ("Foo Bar.app"), command tab, etc. But then I end up with odd folders and objects like "Foo BarTest".

What is the best practice here?

+5
source share
3 answers

I use one word camelCase, for example, "FooBar" for development: file names, paths, etc. It makes sense for me to make my life a little easier when I need to write some kind of shell script or something else, since there is no need to worry about the interior spaces. Of course, the make utility is terribly choking on spaces ...

But actually, because I do not see a flaw: the name of my FooBar.app will be localized one way or another, both in English and in any other language, so the application in Finder looks like "Foo Bar", and in the menu " program, "etc.

So, this is FooBar for me in all my encodings and Foo Bar everywhere for the user.


How to localize the name of your application:

Start with the newly created Xcode Cocoa application called "FooBar". Initially, everything is "FooBar", everywhere: the Xcode $ {PRODUCT_NAME} and $ {EXECUTABLE_NAME} variables, as well as the name of your embedded application in Finder.

Now we only want to change the name as it appears in the Finder.
That's right, it is no more or less than localization.

In the Info.plist application file, add the key "CFBundleDisplayName" and make its value identical to the value for the existing key "CFBundleName".

The initial CFBundleName value is "$ {PRODUCT_NAME}", an Xcode variable, and you can simply copy and paste it. Alternatively, you can hardcode each of these keys in a literal string, but if you do, you must also update the Product Name value in the Build Settings panel for the application.

Then you need to do the actual localization.

If it already does not exist (maybe it does), create and add to the project the localization file "InfoPlist.strings", id est (provided that English is the main language), the file that is in the application resources folder copied to the folder "in a subfolder named" en.lproj ".

In this file, add the same two keys that appear in the Info.plist file in this format, indicating the value that you want your application to appear in Finder:

/* Localized versions of Info.plist keys */ CFBundleName = "Foo & Bar"; CFBundleDisplayName = "Foo & Bar"; 

What is it! Now the application "FooBar.app" refers to UNIX, but it appears to the user as "Foo and Bar" in the Finder.

+3
source

I stopped using spaces in Xcode project names.

There are circumstances (*) when you need to import a module into your unit test module, so in Swift you end up writing

 import Foo Bar 

in your Foo BarTest module that the Swift compiler doesn't like.

(*) this is at least necessary when you use basic data, and want to use your basic data model and classes in your unit tests.

+1
source

The only "best practices" to designate your project are common sense. It is probably best to combine the project name with the name of the application that it will produce, or vice versa.

I prefer just one word mostly - and short, especially if it's a CLI project. Obviously, this is not the case here, so name it, but best for you.

0
source

Source: https://habr.com/ru/post/1214881/


All Articles