One Project For Multiple Applications in XCode - ios

I am trying to use the approach of having a single project that uses different targets with different plist files. However, each target has a different set of launch and icon images. I cant however use a duplicate set of these since adding a duplicate image when the same name gives the error that its already in use. Is there anyway around this in xcode?
To save the file, either provide a different name, or move aside or delete the existing file, and try again.

You should use Xcode 5's assets catalogs. You can define a different assets catalog for each target, and in each assets catalog you can define different launch images. Names are handled by the content generator.
You can mix asset catalogs, so you can have, for example, one shared catalog for shared images, and individual ones for each different target, where you can have distinct icons and launch images.

OK, so I have changed my approach and found the easiest and a simple solution which I ignored before. All you have to do is keep the file names same but keep the files in different folders. And when adding them to project, check the target to which the files belong to and uncheck other targets. See the image.

Related

How to use different assets with same name using multiple targets

I'm trying to build an app with multiple targets, each should have different asset versions. The business requirement is to have the same app but with different branding assets. I don't want to copy and paste the project and change icons manually because this won't be efficient.
As an example, I have a logo in the assets catalog, both Target X and Target Y need to see the asset, but both targets need to see a different version of the asset.
You can do this by creating additional Asset Catalogs, these can be named accordingly, they will need to be added to your required target, Target Membership.
Having different collections you are able to have the same asset names and the targets will work as expected.

Using XCAssets Properly (adding assets)

I had two people discuss two different approaches with me on how to add assets such as images to a project in Swift.
Person 1: "You should create a new folder within your actual project workspace and then add all of your assets to it directly (so it's within the project). Then drag & drop the assets from this project folder to XCAssets, to actually create the icons you will use."
Person 2: "Just download your images from wherever, and drag and drop them directly. They can be from different locations. When you deploy to ITunesConnect it will copy the images."
Now I'm confused - when I drag and drop an image (let's say from my Downloads folder) doesn't Xcode copy the image locally into its own private location? Once I drag it into XCAssets, does it need that source location anymore? I thought maybe approach #1 would end up forcing Xcode to store duplicate images/assets and take up more size on the app.
What is the "correct" approach to adding assets?
Thanks!
Both actually can work (drag and drop/use asset folder). But the latest method introduced by Apple by xcasset folder. XCAsset folder is superior in the way that you can see a list of assets nicely one by one, even you have multiple sizes on it (.png #2x.png #3x.png etc). Easier to manage and see which size you are missing etc.

Xcode: Exclude images in build from asset catalog according to preprocessor flag

I have two apps that share almost everything except that one shows ads according to a preprocessor macro that is configured on the Build Settings tab.
Now, following the same rule, I need to exclude images from the Asset Catalog, so this way the app with ads doesn't include things that it shouldn't, but I don't know how to do it. Any guidelines?
Thanks
Since you have two targets in your project, the simplest solution is to have three or more image assets (xcassets) in your project.
One with images common to both targets, one with images specific to target A, and one with images specific to target B.
Then ensure that the two target-specific assets are only targeted to their respective project target.

Multiple Info.plist files in MonoTouch solution

I'm trying to write two separate submittable apps: one for iPad and the other for iPhone. This necessitates having two separate plists to allow independently specifying different app icons, launch images, etc.
When I try to rename my Info.plist, MonoDevelop autocreates a new empty Info.plist and uses that instead. By the same token, I can't seem to move my Info.plist to the iPad/ subfolder and have MD pick it up there.
Currently we have 3 projects in 1 solution: iPad, iPhone, common files and libraries.
Is the only solution to have separate .sln files in the appropriate subfolders, or can I still somehow build two separate apps from one .sln?
EDIT: Project structure is below if that helps visualise the problem.
MyApp.sln
MyApp-iPad.csproj
MyApp-iPhone.csproj
MyApp-Common.csproj
Main.cs
AppDelegate-iPad.cs
AppDelegate-iPhone.cs
Info.plist (MD currently uses this for both projects)
Common/
iPad/
iPad/Info.plist (for -iPad.csproj)
iPhone/
iPhone/Info.plist (for -iPhone.csproj)
Here's my current and very ordinary solution: Add a custom command that runs Before Build
cp iPad/Info.plist Info.plist
And for iPhone:
cp iPhone/Info.plist Info.plist
I have a project where I need to be able to build the application with different icons and resources.
I use different build profiles and build scripts that copy in the correct files into a resources folder. This also changes the application name and identifier.
This is a similar solution to yours, but it would allow you to bundle different images with your application like you wanted.
You need to make 2 projects, one for iPad and one for iPhone.
You should "link-in" all the code files from one project to the other. You can have different Info.plist files, icons, images, etc. with this route.
Here is a link talking about various strategies: http://docs.xamarin.com/ios/Guides/Application_Fundamentals/Building_Cross_Platform_Applications/Sharing_Code_Options

An iOS app with multiple brandings

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.

Resources