I have a dual language localized app that is intended for enterprise distribution and for my purposes, it would be desirable to split it into two separate apps. Some users of the app would need to use both language versions and it would be easier for them to just open a different app than to go into settings and change language each time they want to switch.
What is the easiest way to split such an app into two targets, considering it already has a couple of localized strings files (for text and for InfoPlist) and several language-specific image folders?
Create a new target (one project might have more than 1 target), with a different bundle identifier.
Add a preprocessor macro, e.g. SECONDARY_LANGUAGE=1, into the new target's Build Settings so you'll know which language is being used. You can check for language inside the code with something like
#if (SECONDARY_LANGUAGE)
...
#else
...
#endif
Related
I am trying to add localization on my project. Right now I have my main project, and all the text in the Main Storyboard and the .swift classes is in language Norwegian. I have another project where everything is in English, but I want to only use one project with both languages, so I can have one app only on the app store. I have about 20 different classes, and some classes contain multiple arrays with over 400 strings each. How exactly do I add English language to my existing project?
According to Apple guidelines, the default language of your app will be based on the user device default language settings.
To add localization to your xcode project, start by the adding the language you want from Project navigator -> Info -> Localizations tab and select the language you want to add. After selecting the language, a popup will appear to select the resource that you want to include in your localization:
You will notice that you will have a new .string file under your selected resource (for example, Main.storyboard) where you can do all the translation you want.
There are other topics like localizing strings from your code (for example, having a .string and an extension to your String) or image localization.
I have a project that I maintain for a client; let's call it MyDataAssistant. When the project goes into beta, the client likes to have a "separate app" built for them, which I create using a different provisioning profile and a modified bundle identifier (MyDataAssistant-BETA). It's a pain to always be going back and forth and changing the bundle identifier, code signature settings, and especially the icon. I understand that you can have multiple targets and multiple build settings (within each target?) in a project, but I'm not clear on what the difference is, or how to use them appropriately.
Additionally, the client would like a third version with read-only capabilities. I can accomplish this by just making a flag return from a certain part of my code, but I would like it if that flag could be toggled in the build (target?) settings.
Please advise on how to manage this kind of project with multiple "variations" of the build.
Add a new configuration to your project by duplicating the release one for example.
Give it a name "Beta"
Add a User-defined build setting
Call it MY_DATA_ASSISTANT_BUNDLE_ID_SUFFIX for example and set the value to be -BETA only for the Beta configuration.
Edit the MyDataAssistant-info.plist file by setting the bundle identifier to com.YOURCOMPANYNAME.MyDataAssistant$(MY_DATA_ASSISTANT_BUNDLE_ID_SUFFIX)
This will make it have different values for the different configurations.
You can also set the display name to have a different value by setting it to $(PRODUCT_NAME)$(MY_DATA_ASSISTANT_BUNDLE_ID_SUFFIX)
Set the right provisioning profile for each configuration. (Of course after creating the beta one in the provisioning portal as if it was for a new app with the bundle identifier having the suffix "-BETA")
Create a new scheme!
Give it a name: MyDataAssistant-BETA
Change its build configuration to "Beta" for all the actions and you should be ready to go.
If you want to have different icons for the beta version you can use the $(MY_DATA_ASSISTANT_BUNDLE_ID_SUFFIX) in the MyDataAssistant-info.plist file for the icons names and of course add them to the target.
I would recommend creating two targets. This will allow you to share what files you want between variations, as well as have custom source, or config files in each. The simplest implementation of this would be to have an identical target except for the info.plist file.
Simply right click on your current app target in project settings, and hit duplicate.
I have a project for a iOS app and wan't to make two different apps from it. I want the apps to have different skins and want the two apps to connect to two different web services. So I want a base app project from which I can select which to build.
I essentially want to fork a project but don't want to maintain two projects
Also they have to be able to be installed on the same device at the same time.
Is there some sort of "good practice advice" on how to do this?
I would also be interested in a similar solution for android projects
A project with different targets will do:
They will allow you to set different Info.plist for each target (which allow you to set different bundle ID, allowing two apps installed at the same device).
It also allows you to set C flags for each target (which allows you to put conditional statements based on the flag in your codes)
You can have the lines that should be executed in the target, in this example the copy target, with ifdef macro:
#ifdef COPY_VER
//lines of code to be executed for the copy target
#else
//lines of code to be executed for the other target(s)
#endif
I have an iphone app working just fine - it basically just displays news from a feed, but now we want to have a second app that is a clone of the first but branded a different way and displaying news from a different feed - the xml feed and the graphics/colors would be the only difference.
I'm trying to not duplicate any effort. I can easily set a define and build the app using different colors and images and the xml feed url with one codebase. But what is the preferred way to do this so that I can make a change to some common code and easily rebuild both apps and get them updated in the app store without maintaining separate xcode projects, separate files, etc?
You can do this easily by adding a new target to your project.
Create unique branded assets and configuration files with identical names, but keep them in different folders. When you're ready, add each folder to the project and set the "Target Membership" to the appropriate target. If you make a mistake, you can change it in the File Inspector pane.
When you build a specific target from the shared codebase, only those resources will be bundled with the app. As long as the filenames are identical, it should work.
You can use one project with more then one target. For each target you can add different resources (Info.plist, icon, etc.).
XML feed can be defined in settings.bundle (which also can be dependent on the target).
Layout you can read from dictionary, which also should be dependent on the target.
Is there any way to create a project/application which will have multiple targets.Its same as how we create multiple targets for an iPhone application in XCode.Basically I have an app which has to be made for different targets, with almost all the similar functionalities but with little change.
You can use Configuration Manager to add additional configurations to the list of Debug and Release. Then for each configuration go to Project/Properties/Build/Conditional compilation symbols and add a symbol used with your configuration or target, eg. make it SILVERLIGHT;WINDOWS_PHONE;CUSTOMVERSION1
Then in your code you can say
#if CUSTOMVERSION1
Debug.WriteLine("This is a CUSTOMVERSION1");
#else
Debug.WriteLine("This is not CUSTOMVERSION1");
#endif
Otherwise - if you want to make bigger changes - you would create another project and link files from one project to another project - project/Add/Existing Item//Add As Link(an option in the "Add" button menu). You can then add more files or add different versions of these files as needed. You could use Project Linker to do it faster.