Remove unused splash screens and icons from PhoneGap application - ios

I have a very big app size. I tried to remove the default image files for unncesary splash screens and icons (i don´t support ipad). But i get a PBXCp error (like /icon-72.png: No such file or directory), even if i have configurated the proyect only for iphone, and i have removed ipad icons references on -Info.plist.
Anyone knows why i´m getting this error?
I want also to reduce the file size as possible. I have already removed the files of Capture.bundle, which i don´t need. Any other idea?
Thank you very much

1)
You still have a reference in your project to an "icon-72.png" file.
Check your project's build phases (e.g. the "Copy Bundle Resources" phase, especially) and also open up all the folders in your project to make sure there isn't a red (i.e. missing) file listed there.
2)
For larger graphics files, host the images or whatever on one of your servers and then have the app download and cache it. That will help to reduce the initial download size.

Related

Unused Bundle Resource, not found on disk, after deleting it?

I'm trying to delete all the unused assets, to decrease the app size (icons, launch screens, etc), I started with the iOS project, but now I'm getting errors like this:
Bundle Resource 'Icon-Small#3x.png' not found on disk (should be at
'D:\Work\MyProj\MyProj\MyProj\MyProj.iOS\Resources\Icon-Small#3x.png')
I deleted the specified file, but it's not used in the project, at least it's not visually used. Some of the missed files are the default Xamarin X icons.
I deleted the array items in CFBundleIconFiles key, which pointed to all the missing files, but still getting the same error.
I don't know well about xamarin. But in Xcode, the images files are removed from Xcode better than from Find file utilities.
The project has a directory, .xcodeproj. And a file project.pbxproj will describe how many files will be compiled, and how many images resources in this project.
If a image file was deleted from file system, but it is still in this project.pbxproj. Then the compiler will argue this problem about it failed to find the image resource file.
So, deleting a image file in Xcode, will remove the entry from project.pbxproj and remove it from file system.
In Xcode, it will mark red colors for those missed files, I think xamarin should has similar feature too.
In iOS , some icons are required . Items marked with "Required" must be included.Refer the following image.
As we can seen ,Icon-Small#3x.png is required.It used for seetings on device (such as iPhoneX and iPhoneXs Max).Such as the icon in the following image.
So ,though you have deleted the array items in CFBundleIconFiles key.You will still get the error .
The reason you are getting this error is chances are you deleted the source files, but Xamarin still keeps on referencing them.
So resolve this error go to each folder, Resources and Resources/Drawables on android and delete each image separately. This should fix your issue

How to remove extra linked images in ios .app bundle

When I checked my app size its going approx 120MB right now. Out of which mostly was taken my extra resources. Later on I removed all extras and added compressed version of launch images also 2 extra pods. All this reduced my app size my 30 MB. But still When I checked my .app package contents its showing some extra LaunchImages which I may have added earlier and are still somehow connected to my code. I am unable to find out their source. Please help me how to remove these extra linked images from my code.
Delete unwanted file from bundle resources
Go to your Project settings
Select your application target under Targets
Select the Build Phases Tab
Expand the step Copy Bundle Resources
Remove and unwanted Files that shall not be copied into your bundle
Delete unwanted file from Assets.xcassets
Also, check if your project contains an Assets.xcassets assets library and look if you find your unwanted image within.
Sanity check
When sometimes everything you try fails and Xcode behaves strangely, make sure your problem is not already fixend and only caused by cached resources.
As sanity check you can
Clean Build (Product -> Clean)
Delete Derived Data (Delete ~/Library/Developer/Xcode/DerivedData folder in Finder or via Terminal command rm -rf ~/Library/Developer/Xcode/DerivedData)
Remove App from Device by long-pressing and deleting.
Afterwards build your app again and check if the problem persists.
Remove the items from Assets catalog if it is an image.
Remove unwanted files from respective directories.
Remove the Derive Data.
Clean the project. Then archive.
How to remove Derive Data:
Xcode-> Prefrences-> Locations-> Derive Data.
Remove content of Derive Data folder.
iOS 9 has got a new feature called App thinning. Xcode and Appstore handles downloading of images that are relevant to specific iPhones thereby reducing the size of the app. You can just enable App thinning while moving your App to the Appstore. This is one of the method to reduce your app size.
you can check this App thinning

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

Some files are located outside of "MyApp" directory in my iOS app - why?

I'm now developing my first iOS app, and I found that two of my classes (hence, four files) are located outside of my MyApp/.
So in my filesystem, here's the current situation:
My App
- ClassA.h
- ClassA.m
- ClassB.h
- ClassB.m
MyApp/
MyApp.xcodeproj/
MyAppTests/
Other than the two classes, all of my class files are located in MyApp subdirectory. The other resources, such as Core Data model file or images are saved in the same directory.
However, why are the two classes, and only the two classes, located in the outside of MyApp subdirectory? When I move those files to the supposedly correct location, those files are no more "valid" in Xcode with the color of the file name is converted to red.
So here's my question:
Why are those two files located there?
Do they have any issues if they remain to be located there?
Should I fix this issue and save it correctly? I think I haven't had any issues so far with the Simulator and the actual iPhone...
I use iOS 7 and Xcode 5.
•Why are those two files located there?
A: When you have created these files or imported from external directory, you may have not taken care of the group/folder these files are getting created/imported into. Hence they are inside the main app folder in the file system.
•Do they have any issues if they remain to be located there?
A: No, this is certainly not an issue in the correct functioning of your app, but it is always good to manage your files under groups/folders for better file structure and it is easier to find files when they become large in number.
•Should I fix this issue and save it correctly? I think I haven't had any issues so far with the Simulator and the actual iPhone...
A : This depends on you. If you like to keep your files in folders and like everythin arranged in some pattern, then yes you can divide the app into different folders. When you move the files in a folder, the reference of those in XCODE should change as well, and thats why you see those files in red in XCode. No worries. Just delete the files and add them again. Make sure you uncheck the option "Copy files under detsination group's folder".
Now, you may seem the option of creating New Groups inside XCode. But it is good to be aware that these groups do not create separate folders inside file system. These are just for Xcode refernce. So, a neat way is to create folders outside of XCode, and then import these folders(can be empty) in Xcode. Now when you add any file in these imported folders, even from XCode, it will go inside the correct folder in file system.
I am sorry I am not on my MAC right now, so cannot paste actual images, showing how to do it. Feel free to comment, if I have instead of solving the issue, have rather confused you more:D
You can put your source files wherever you want, as long as Xcode knows where to find them. You can leave them here, or organize it in another way, as you seem to be willing to do.
So, if you want to move these files in your Myapp/ subfolder, just move them there, and when Xcode complains it can't find them, highlight all those files in red in the navigator, and in the "File inspector" pane (right hand side of the window), click on the little Folder icon to browse to the new location. If you selected all files you don't need to do that 4 times, Xcode will find it out by itself.

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