I have a single Xcode project with several targets, each spitting out a different app with a different icon. The icons are in their target-specific resource folders so they don't collide.
But the 'iTunesArtwork' file (i.e., the icon used for display of Ad Hoc builds in iTunes) must be placed in a specific location (Project Root), and named exactly that, so multiple versions can't coexist.
Any workarounds?
You must be able to do the same trick with the Artworks file, store several files (with the same name) at different folders, add them to the project respecting the files Target Membership (File Inspector section).
They don't have to be in the project root. If there're several icon files at different project folders, each icon is a member of it's own target, then you have different target icons with the same icon name (and naturally the only icon file is copied to the bundle root).
You might need to have one of the icons at the project root folder (e.g. it might be copied there for you by Xcode), but during the build the icons should be copied from the folders referenced in the project rather than from the project's root folder.
Related
I have a xcode project with many targets and each target has its own App Icon and Launcher Icon
It's fair to expect that each target has its own iTunesArtwork file.
But the problem here is
The name of the file can't be changed and it should be with the name iTunesArtwork
so I can't add a yet another file in the same project for a different target
The iTunesArtwork has to be in the root of the project or else it'd be ignored
I tried creating different folders for different targets and in the respective folder I dragged and dropped the respective iTunesArtwork but iTunes Completely ignored it.
so is there any way while building the app we can move a file from the respective folder to project root ?
or
is there any other way I achieve this through ?
Note:
I am using jenkins
I solved the problem using Folder references in xcode
Here are the steps
I opened my project in the finder then I created a physical folder
for each target and there I kept the iTunesArtwork and
iTunesArtwork#2x for respective targets
(This folders won't be visible in xcode since we're doing it in the finder and as we have physical directory no name collision problem)
In xcode I opened my project and I created a Group for each Target
I dragged and dropped the iTunesArtwork & iTunesArtwork2x in the
respective Group and I chose the respective target in Target list
and I chose Folder references
Create new image.xcess asset and select target- build settings find xassets replace that neme for your inageassets name for that target
The files inside of my app bundle are arranged into folders, but when I check the file layout of the bundle, it seems these files are all added to the same directory, and not sorted by folder as I have them in XCode. How can I make sure they're added to the device in the same folder structure?
The folders created in Xcode using "Group" or "Group from Selection" (yellow folders) are not true Folders, but Groups. They are only a visual way to organize your sources.
To make true folders (blue), create them on disk (using, say, the Finder).
You can then import them into Xcode using the option "Create folder references for any added folders".
In short:
Groups (yellow). Not related to the actual file/folder layout
Folders (blue). Direct representation of the OS hierarchy
I am having trouble with xamarin folders. Currently I'm writing xamarin iOS project. In Xcode I used directories for grouping images, there could be several levels of nested folders, but when I was building project for device or iOS simulator, these resources where simply being copied to main bundle, without any folder structure. I can't reach the same behaviour in xamarin studio. Whenever I create folders in my project and put pictures or other resources in them, this folder structure is recreated on the actual device, and thus, I struggle against different paths, when loading images. How can I make xamarin studio simply copy the files in the folders to main bundle, instead of recreating folder structure?
Thanks for help.
My first suggestion is to change the BuildAction property of your images to BundleResource.
Once you do that, there are multiple ways of achieving your goal:
The first option is to specify a LogicalName to be whatever you want the name to be inside of the compiled app bundle. Currently there's no way to set the Resource ID (UI name for the LogicalName property) for anything other than EmbeddedResource files (I'll work on fixing that momentarily), but you can edit the *.csproj like so:
<BundleResource Include="Icons\icon.png">
<LogicalName>icon.png</LogicalName>
</BundleResource>
Normally, that Icons\icon.png file would be copied into the iOS app bundle as Icons/icon.png, however, the LogicalName property overrides the relative path name. In this case it would be copied over as simply icon.png.
As another example, you can also do this:
<BundleResource Include="Icons\iOS\icon.png">
<LogicalName>AppIcon.png</LogicalName>
</BundleResource>
This will copy the Icons\iOS\icon.png file into the root of the iOS app bundle and also rename it to AppIcon.png.
A second option is to simply move your image file(s) into the Resources folder. The Resources folder is special directory that get stripped out of the default path names when copied over to the iOS app bundle. In other words, Resources\icon.png would be copied over into the root of the iOS app bundle as icon.png rather than Resources\icon.png as is the case with normal project directories.
A third option is to simply register other "Resource" directories of your own (and they can exist within other directories, including the default Resources directory).
For example, you could have the structure in your project:
Resources/
Icons/
icon.png
icon#2x.png
And in your *.csproj file, edit the following tag:
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
and replace it with:
<IPhoneResourcePrefix>Resources;Resources\Icons</IPhoneResourcePrefix>
This will ensure that the icon.png and icon#2x.png files are installed in the root of the iOS app bundle.
Xamarin has two ways to setup files you want present in the iOS bundle:
Put them in any folder, and mark the "Build Action" as "Content". Whatever directory structure you have in your project will be present in the main bundle.
Put them in the "Resources" folder, with a "Build Action" as "BundleResource", this does the same as #1, but removes the "Resources" folder from the path present in the bundle. This is a nice place to put all images you want in the root of your bundle but would clutter up your project.
I have created a projects witch contain two targets ( i have duplicate Target1 to have Target2). i have many images in the project. I would like to associate some images to one target and some others to the second target. I doing this by selecting one image.
my question:can i associate a fonder of images to a Target ? if yes how i can do this ?
thanks for your answers.
Yes, it's possible: well folder itself has no target membership but you can easily associate all files from one folder to one target and files from other folder to the other target. Files in these folders can have the same names of course.
You can have two separate folders on disk, let's say images_t1 and images_t2.
Drag images_t1 folder into project tree and when asked for "add to target" you only check Target1 checkbox. For images_t2 you only check Target2 checkbox - that's it.
I just retested it and target membership of imported files (inside the two folders) is correct.
But note, if you are planning to use this images with Interface Builder you might run into minor XCode bug - mixing images. There is a workaround for that, but it's not pretty. Check Xcode 4, Interface Builder, two targets with seperate .xib (image resources with same names).
This bug is visible only during .XIB editing - everything is fine once apps are compiled.
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