How to remove extra linked images in ios .app bundle - ios

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

Related

How can I clean xcode build cache?

Any change I do in Xcode, build successfully but when I review it in simulator or transfer it to my iPhone, the previous successful build which was sent to the store is running.
It was a working application with history of changes in app store, then I decided to change the name and unique identifier. All went well and I was able to deploy first changes to the store, after that xcode started to show this odd behavior. I made changes, built successfully but the previous version showed up in simulator etc.
Then I found a silly workaround, every change I made, I rebuilt the environment by pull the code from my repo and
#cordova add platform ios#4.5.4
#pod update
#pod setup
#pod install
Then open the Xcode and built the project, then everything was as expected.
but unfortunately this trick stopped working as well and I stuck.
I do clean
I do clear DerivedData folder
I do use "watchdog" application to do cleaning
Did I miss anything?
How to clear Xcode cache manually
1. Clean the build
Tip: If you’re trying to fix a problem with Xcode crashing, it’s worth cleaning the project build first. This will get rid of the current build and create a new one next time you run the code.
With the project open in code, go to the menu bar, choose Product, and select Clean or:
With the project open, press Command + Shift + K.
2. Clean out the build folder
To clean out the build folder, and get rid of cache files, do the following:
In the Code project, click on the Product menu while holding down the Option (Alt) key and choose Clean build folder, or:
Press Command + Shift + Option + K.
3. Reset Simulator content and settings
If neither of the steps above resolves your problem, try resetting the simulator content and settings:
Go to the menu and choose iOS Simulator, then click Reset Content and Settings.
4. Delete derived data
If you’re still having problems, try deleting derived data, which will force Xcode to recreate it when you next run it.
In the menu, choose Window, then Organizer.
Now select Projects, and then click Select your project.
Choose the project whose derived data you want to delete.
In the window that opens, you’ll see see the Derived Data folder listed, along with its Finder path.
To the right of the folder, there’s a Delete button. Press it.
Now, delete the module cache.
Go to: ~/Library/Developer/Xcode/DerivedData/ModuleCache.
Drag the files from the ModuleCache folder to the Trash and empty it.
Source: https://macpaw.com/how-to/clear-xcode-cache
For my case, it turned out to rebuild the whole environment to get it fixed.
One basic point that needs to be highlighted is using "cordova prepare" after any changes.

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

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'.

Remove unused splash screens and icons from PhoneGap application

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.

File in folder that added using "Create folder references for any added folders" not updated

I need to make a folder in app bundle to manage my resources file, images, sounds, etc. So I add my resources folder to xcode using "Create folder references for any added folders".
Problem
I got a problem when I want to update file in this folder (add file, rename, add sub folder), after I build it (both simulator and device) the folder didn't update to reflect my change, I have to Product > Clean to make it update. I wonder if I ship my product this will cause the problem or not, force user to reinstall my app every time I update my resources won't be a good thing to do.
The resource files will be effectively copied in to your application bundle at compile time. If it is working after clean, and you see it working well on your phone, the same way the correct files will be copied to the application bundle when you Archive the App before submission. So I would not worry about this until you are sure to make a Clean also before Archiving at the time of submission.

Resources