delete bundle file in iOS app - ios

Here is the problem:
I am trying to check the contents of my app's bundle. So by writing a couple of lines of code like:
NSBundle *myBundle = [NSBundle mainBundle];
NSLog(#"%#",myBundle);
I got the path that I need to locate my app's bundle. However, when I deleted the bundle, I was expecting my app to give an error saying that bundle doesn't exist. Instead, it showed that same path again. Hy doesn't it have any impact on the program. How does it work under the hoods? I am new to iOS, so any help will be appreciated.
Thanks in advance!!!

Related

Why do App store connect operation errors ITMS-90685 and ITMS-90680 happen?

The errors:
ITMS-90685: CFBundleIdentifierCollision. There is more than one bundle with the CFBundleIdentifier value com.[companyName].[className] under the iOS application [myAppName].app
ITMS-90680: invalid directory. The bundle Payload/[myAppName].app/Plugins/[myFramework].framework is not contained in a correctly named directory. It should be under "Frameworks"
Background info: Happens on the last part of uploading in Xcode. I'm using SPM and linking this framework into my app's target.
ITMS-90685:
Have you already submitted a ios app under this name before? It might be the case that you reused the id? If this is not the case, make sure your compnyName is unique.
ITMS-90680:
you need to have your framework under the Framework directory, and not the Plugins directory.
Change your app bundle (ID) and try again

iOS - How to get bundle into Bundle.main.resourcePath?

Context: Xcode Version 11.0 beta 2/Swift 5
I want to create a bundle to access on a physical iOS device. I tried all the solutions on How to make an iOS asset bundle?, but to no avail.
I have created a bundle in finder containing the file and subsequently moved to Xcode such that my directory structure looks like this:
*Project Name*
*Project Name*Tests
Products
somebundle.bundle
somefile.csv
I keep getting the error
the file "somefile.csv" couldn't be opened because there is no such file
when testing.
I am accessing the file through let text = try String(contentsOfFile: Bundle.main.resourcePath! + "/somebundle.bundle/somefile.csv")
But actually, printing the contents of Bundle.main.resourcePath (FileManager.default.contentsOfDirectory(atPath: Bundle.main.resourcePath!)) shows that the bundle is not located in Bundle.main.resourcePath, as this is the output:
["_CodeSignature", "PlugIns", "Base.lproj", "*Project Name*", "Frameworks", "Info.plist", "PkgInfo"]
So, how do I get the bundle into Bundle.main.resourcePath, as the answers to the question at the top seem to suggest should be the case?
To access the contents of a Bundle when the app is installed on a physical device you need to ensure that it is copied across during the build.
Go to your Project Settings -> Build Phases -> Copy Bundle resources and make sure that your bundle is listed there.
You will only be able to read the contents from there unless you copy it to the documents folder first before trying to edit/save.

No suitable application records were found. Verify your bundle identifier 'com.swiftyjson.SwiftyJSON' is correct

It's really bothering. I have several apps on the App Store, some of them use SwiftyJSON, but this latter one is weird. I'm trying to upload it to the App Store but I get this strange error.
No suitable application records were found. Verify your bundle
identifier 'com.swiftyjson.SwiftyJSON' is correct.
I have double checked project's bundle identifier it's correct, com.myname.appname. Also, it's correct on the iTunesConnect as well. I've read other similar questions, none of them helped. I'm using carthage and Xcode 9.
I don't know how these are related but I removed the Info.plis file, create a new project and replaced the app's plist file with this new one and the error is gone.

How to change the DisplayName of an iOS Application?

I know there are so many answers related to my question, such like.
Programmatically rename an XCode project
Renaming xcode 4 project and the actual folder
etc.
But look at following my code:
NSString *plistPath = #"...../TestingAPI-Info.plist";
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc]initWithContentsOfFile:plistPath];
[dictionary setObject:#"myTestingApp" forKey:#"CFBundleDisplayName"];
[dictionary writeToFile:plistPath atomically:YES];
I am changing the name of apps icon by above code,
Changed name "MySuperApp => myTestingApp"
SO, Is it valid to change by using above code ? I have fear of app rejection ?? I also want to set all changes through above code like, Bundle identifier, Bundle name..etc ?
Is it valid or not ?? By using above code apple reject my application or not ??
As rckoenes said correctly, this won't work on the device. Any bundle contents are readonly, including the info.plist. You can not overwrite it.
To clarify:
Just open up the Info.plist file in Xcode and rename it to whatever you want. You don't need any code for this. You will find the YourProjectName-Info.plist file within your Xcode project.
The writeToFile call will not work i.e. the contents will never get update in the Info.plist file. API call may return a false success but contents of that file will never change since application bundle is read-only (obviously the contents within it as well).
As per Appstore review guidelines there is one which suggests,
2.6 Apps that read or write data outside its designated container area will be rejected.
But whether app bundle falls under "designated container area" is a matter of speculation because only Apple can clarify this. AFAIK I have not read anywhere about app getting reject for attempting to write into application bundle.
As a side note: It may not be a good idea to change application name randomly without the users consent.
Hope that helps!
This is very unusual, app name is your brand it is finalized with lot of suggestions and thinking. What is benefits of this and why is your requirements to change name likewise.

iOS - is it possible to download bundles from the internet with updated xibs?

I want to be able to customize xibs in my app after the app is released by changing xibs, bundling them, downloading that bundle and having the client configured to look in those new bundles for the new xibs.
So far, I have added a xib to a bundle I created and am attempting to download it:
// bundle URL is NSURL to uploaded resource for bundle
NSBundle *myBundle = [[NSBundle bundleWithURL:bundleURL] retain];
I get this error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSBundle initWithURL:]: non-file URL argument'
My question: is it possible to do what I set out to do? This error suggests it is not possible.
If it isn't possible to download bundles, would it be possible to download just a xib and use that?
Thanks!
You are getting this error because a bundle is stored as a folder in the file system. You can download a file easily, but you can't download a folder. NSBundle knows this, so it only allows local file URLs for initialization. You have three options for downloading bundles:
As mentioned in the accepted answer here, you can download the bundle as a zip archive and unarchive it.
You can store an extra file on the server which lists the file names for each file in the bundle, and create it locally by downloading each file.
You can specify a format which will be used by all bundles, and download those files from the bundle. This is similar to 2, but has the list of file names built in instead of on the server.
Yes, you can load a bundle with just XIBs, images, and other assets. Don't try to load a bundle with code in it, Apple has explicit checks for their digital signature if you try to load code, which would cause the load to fail.

Resources