Where is the Launch Images XCode setting stored? - ios

I need to programmatically set the Launch Images Source setting in XCode 7 for my app project to Don't use asset catalogs. As I will be using a storyboard.
Important By "programmatically" I do not mean at runtime. It is actually at build time where I have a script file which runs some code that needs to rearrange the project. I knw you might not like this, but this is the requirement/challenge here.
I searched in my project's .plist file but it seems there is no trace of that setting. Where can I find it? Which file is hosting this setting?

It's in the project.pbxproj file.
There's a ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME property that gets set to the name of the file you select.

This isn't possible. The launch images will be stored somewhere in the main bundle and those files can not be changed at run time.

Related

Launch image and icons for iOS applications on Qt Quick

I've tried to figure out how to add the icon of app and launch image following this guide (https://doc.qt.io/qt-5/ios-platform-notes.html#launch-images), but without any success.
I do not understand several, maybe the simplest, moments:
1) Where should the folder "ios" with Info.plist file be located? In root folder of project or in "Resource" folder? A little example or screenshot would be useful.
2) Can I change Info.plist directly in .pro-file before it will be generated by Qt? Or it is necessary to compose Info.plist manually and locate it in pre-created "ios"-folder?
3) Maybe, there is another way to set the launch image and app icon? Without touching .pro-file.
Will be glad of any help. Thank in advance.
By your questions:
This folder you may create manually and then put default Info.plist into.
Also you could edit default Info.plist in Xcode and the put them into ios folder (or other).
Follow the https://doc.qt.io/qt-5/ios-platform-notes.html#information-property-list-files you need add this code to your pro-file (instead Qt Creator will replace Info.plist):
ios {
QMAKE_INFO_PLIST = ios/Info.plist
}
Yes you can.
More of that - no best-practices-way to edit it maximally right by Qt tools. In first answer I wrote that you may edit default Info.plist in Xcode directly. (but don't forget copy it in your Qt-project)
To change app-icon of launch images no need to edit .pro file. You need to edit Info.plist generally.
You can do it in Xcode directly. But you need to do it every time after you make changes in your qt-project. I don't think that is correct way.
I answered to your several, simples questions. Hope thats helps!

Getting error after changing project folder name in XCode

When I created my project, I called it "Project1". Then, later I've changed it to "Project2" from the Xcode. I changed all "Project1" to "Project2", but now, when I compile my project, it looks for files in Project2/Project1/myFile.swift and I get the next error:
<unknown>:0: error: no such file or directory: '/Users/myusername/Copy/Projects/Project2/Project1/myFile.swift'
I need to make that it will look at
/Users/myusername/Copy/Projects/Project2/myFile.swift
without Project1 in the path.
How can I solve this problem? Also, I changed from Xcode Identity and Type section Location of my project.
Today I had the same problem when I renamed the folder containing the Xcode project and some parent folders of it.
In my case there where a .swift file shown with it's name in red in the list of files of Xcode (Navigator area). I think that this means that Xcode was not capable to find that file.
I selected that file (actually it's not a real file but a representation of it).
Then, in the File Inspector (Utility area), I clicked on the Folder icon and chose the file on Finder.
This worked for me.
Renaming projects in xcode in one of the most annoying things in iOS development. I assume you want to rename your app. I faced this problem once and figured out a simple, clean way to do it.
Go back to the point where everything worked.
Open project in xcode and click on the project icon in the project structure( first file)
Go to the info tab
Search for Bundle Name. Most probably it will automatically be set to $(PRODUCT_NAME) which is a shell variable that will set your app name the same as the project name.
Set it to whatever you want your app name to be
Done
Note : If you use custom URL Schemes this might produce an error when redirecting.
ALWAYS use git or some other SVN in your projects. This will come in handy in this kind of situations
Change you folder name in you finder "Project1" to "Project2"
Remove "myFile.swift" file from project (copy on Desktop)
Restart Xcode. Copy "myFile.swift" in project select "Copy file to folder" hope this will help.

Why does Xcode say "Duplicate localized resource info.plist found" when I try to import or export localizations?

I'm sure there is something messed up in the project file but I have not been able to find it (it's a legacy project new to me).
If I remove the reference to info.plist in the project, then it will successfully import and export, which is a workaround, but not ideal (obviously, although it's easy to revert).
I have searched for duplicate info.plist files and there are none that I can see (there actually are for the watchkit extension and app, but those are named differently anyway).
The actual name of my info.plist is like myapp-info.plist, but it is correctly named in the build settings--the project builds fine.
I have googled the heck out of this and can't find any other reports so I'm really stuck. Next step is to burn an Apple tech support request and when I do, I'll report back, but I thought I would ask the SO community first.
Thank you!
I had this same error. To fix it, I had to localize the *-info.plist file. Select the info.plist file and click "Localize..." in the File Inspector pane.
I don't know if you have solved this problem but I had the same issue. I think it happens when you change the project name and the build settings do not do its job to reflect the change. The Test info.plist refers to the same target original plist and seems to cause this problem.
Go to build settings in your project>Target>Project-name-Tests>Build Settings. Then locate Packaging>Info.plist File and change the folder to project-nameTest/Info.plist.
I hope this does the trick.
My experience was different here. I have multiple targets that all use the same code base. At some point (ostensibly due to a bad manual merge) the Info.plist setting in the Build Settings tab got set to the same value for multiple targets.
Once I straightened all of those out, I was able to export the Xliff file without any issues.
I was receiving this error message in Xcode 7.3.1 and what I did was create a new empty project in Xcode and model my info.plist files after that. This involved:
renaming my [app name]-Info.plist file to Info.plist and moving it out of Supporting Files to the main folder
going to project target (General tab) and selecting the renamed file. There should be a button for 'Choose Info.plist File'
doing similarly in the Tests folder. I don't think this step is necessary to fix the error but did it for consistency.
I was looking at this question on SO - Duplicate localized resource "/Localizable.strings" found xcode 6.1 - and I was able to export to .xliff successfully when I removed reference to the ProjectName-Info.plist file.
I re-added the file, and the project compiled successfully. You have to remove the reference again every time you want to export/import and re-add the file again.
I wasn't able to import updated .xliff files successfully, but I'm thinking on using just Localizable.strings file moving forward. I'm just happy that Project -> Editor -> Export for localization finally worked!

Can I access an xcassets directory on the filesystem?

I would like to dynamically load all images in an xcassets directory. The files are named StockPhoto# where # is the number in the list. If I can access my StockPhotos.xcassets at runtime to count all the files in the directory, I won't have to manually load the files each time I add new stock photos.
If there are other solutions to this problem, I'm open to that but I'm also just very curious how xcassets are handled by the file system- whether they're just reference to a set of files, or actually their own directory. Information on this is sparse.
If there are other solutions to this problem, I'm open to that
The problem is that there is no introspection at runtime into an asset catalog: it isn't a "thing" you can "see" as far as Objective-C and Cocoa Touch are concerned.
The usual solution to this kind of problem is to drag a folder full of images into your project at the outset, and when you do, choose "Create folder references for any added folders" in the dialog - not "Create groups for any added folders". The result is that the folder is copied into your app bundle, and now you can use ordinary file system methods to say "every file in this folder".
Upon compilation of your iOS project, xcassets are compiled to produce either image files, or a proprietary .car file. In that latter case images won't be stored in a directory you can browse.
If your "Deployment Target" is less that iOS7 (meaning that your app would still be able to run on iOS6)
It will produces the same set of image files that you would have had to produce without using Assets Catalog, namely <YourImageName>.png, <YourImageName>#2x.png, <YourImageName>~ipad.png, <YourImageName>~ipad#2x.png and so on, for each image set of your xcassets.
If your "Deployment Target" is iOS7 or greater (meaning that your app would only be able to run on iOS7+)
It will produce a single big .car file in the final bundle (I don't really looked up if this file was actually an sqlite3 datatbase or some proprietary format or whatnot, but who cares, you are not supposed to manipulate it anyway). This big .car file contains all the images, with all their provided variants, and even with slicing info (if you did slice some of them for tiling or to use them as 9-patch images using the tool provided for that in the Assets Catalog editor)
Whatever the produced result you shouldn't / are not supposed to dig into internal details of your bundle like that. The format of the .car file may even change from one iOS version to another (who knows? that's internal details after all which we shouldn't have to deal with) so don't base your logic on it.
[EDIT]: If you need to be sure to have a directory with your set of images at the end of the compilation, you could instead use a folder reference (referencing a real folder in the Finder, as opposed to an Xcode "group" as only group files in Xcode's Project Navigator) then use code to browse it. But then you will have to deal with other details, like only browse files that match the current device (iPhone vs. iPad, non-retina vs. retina…), so this would only shift the problem further in your case; you really should use a constant somewhere to declare the number of images (or put this in some PLIST file for example) and iterate thru them.
As the files you provide at compile time will be in your Bundle — which cannot be altered once compiled as it is digitally signed — the number of images will never changed once the app is compiled anyway. (That's not like if you used the Documents directory and enabled iTunes File Sharing or whatever, letting the user add images himself ;-))
If you're targeting iOS 7+ then no. Xcode will package the files into a proprietary format (.car) that you can't access directly.
Either use imageNamed: methods, or don't use Image Catalogs for the files you need to access directly.
as #AliSoftware suggests you can store all assets images to plist and access them later for more details see here

Displaying the wrong launch image on my app. Tried to replace it in several ways

I have a problem with my app´s launch image. Early on in the development I added a sample image as launch image. Now when the app is ready for release, I can’t change the launch image.
I have tried changing it inside xcode in the project summary, deleting the files from the project file and replacing the files with the new image with the correct name. No luck. It still displays wrong on all devices.
I don’t even have the image in the project anymore.
Is there anyone in here who knows what’s wrong, or have experienced anything like this?
The launch image is for iPhone and iPad, portrait.
Go back to before you tried to replace the image. Replace the image file with your new one.
Ah, but that didn't work, right? Here's the catch:
Clean your build folder. The build process may not always pick up your new launch image. (Hold down Option when looking at the Product menu, or delete the contents of ~/Library/Developer/Xcode/DerivedData.)
Delete the app from the simulator and/or phone. The application installer will usually not copy the new image over.
(These steps are not always both necessary, but since they must be performed in this order if they're both needed, I just do them both as listed.)
Here's why:
When you build, Xcode copies the various files that are part of your product to DerivedData. This may not always copy changed files over existing files.
When you install to the simulator or device for debugging, this is yet another file copy which may not always copy changed files over existing files.
Note that the App Store installer on the phone does a better job of installing, and you won't get partial installs like this. However, until you can prove to yourself that your application has been built with the right image — i.e. that you're failing in #2, not #1 — I wouldn't trust this.
In addition to deleting derived data as part of the clean I found that it wasn't enough to delete the app from the test device, I also had to reboot the device.
Nothing worked for me until I did the following steps:
Go to project's files in xcode
Open the Products Folder
Right Click on your *.app product
Choose show in finder
Go up 3 levels up to Build Folder
Delete this Build folder
Build
That's it
You may also want to try both approaches of deleting the files from
~/Library/Developer/Xcode/DerivedData
Good Luck!
I'm using XCode 8.2.1, lots of targets, and asset catalogs. I could not reliably set the app icon set or launch image set for configuration of any target.
If my image sets are named globally uniquely to the workspace, I have no problem specifying the right one.
If the image sets in different catalogs have the same name, i.e. AppIcon, LaunchImage, XCode seems to pick the image set from the alphabetically first asset catalog.
So, my solution was to name each image set in every asset catalog prefixed with the asset catalog's name. That way it's organized and globally unique.
For Xamarin users, the only solution I could find to this problem was to do the following:
Remove the app from the device/simulator
Restart the device/simulator
Deploy and run the app
Deleting the app, cleaning the build, deleting the bin and obj directories, and rebuilding, doesn't work. The device/simulator has to be restarted for it to forget the old cached image.
As Steven Fisher points out, this wouldn't happen for a proper install from the App Store, where it 'does a better job of installing'.

Resources