Opening Sibling Files in Document Based iOS App - ios

I want to have a custom project file that a user selects in a UIDocumentBrowserViewController. That project file would then reference files in the same directory which would be opened and written to programmatically. I can't seem to get access to the project's sibling files programmatically (presumably due to sandbox restrictions). What's the best way to get this to work?

I ended up making the enclosing folder a document package, i.e. a folder that shows up in the file browser as a single file. I then had access to read all the files in it.
https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/DocumentPackages/DocumentPackages.html

Related

on iOS, can apps import/export folder structures?

in an iOS app, is it possible to share a whole folder, potentially containing sub folders, with another app? On the receiving side, is there a way to import such folder structure?
Or is file handling restricted to flat lists of files & individual files?
In an app I am working on, I want to process structured folders containing files & subfolders, with the folder tree intact - a user should be able to open a folder in my app. Not sure if that's possible, couldn't find an answer, so I guess not.
clarification:
implementing support for the share sheet, it's trivial to enable an app to open specific file types using UTIs. the app will simply show up in the system Share Sheet if a user in another app shares a supported file, and you just handle URLs in the app delegate. This works for multiple files, but is it possible to do it with entire directory structures? Individual files are copied into the target app's container, should be doable with folders as well, hopefully.

Avoid Code Tempring in iOS

What are the different ways available so that We avoid code tempring in ios. Please suggest any good way that we can check at server level to avoid code tempring not in source code. And how we can check that server call from app is from authorize app.
iOS apps are most secured itself. It can not be tempered easily. While building your app no code file and XIB's kept as it is.
You can check it in these steps:
Right click on .ipa file and select Open With and then Archive Utility
Then it will create folder named Payload with .app file in it.
Now Right Click on .app file and select Show Package Contents
This will show you one folder with multiple files in it. Now try to open each file and read it. It will be in encrypted way.
For reference read this link

swift ios and geing final grip on copy bundle resources

I am currenly converting an iOS project built in another tool to xcode/swift.
I currently have an xcode swift ios project with multiple targets defined (one for each customer)
For each customer I have a folder "customerxyzassets" that I have added to "target > build phases > copy bundle resources" using the process described here Include a resource directory hierarchy into app bundle
This folder "customerxyzassets" contains subfolders with images and data files which the app is born with.
I would like to grab a path to this folder upon startup, so I can access load datafiles, images etc. from it.
However, the code I have found, e.g. NSBundle.mainBundle, seems to require speciel access to the files through the above. I would rather have raw file access to it. Am i missing something obvious?
It's not clear what you mean here by "special access" or "raw access." NSBundle just returns you paths or URLs so you can directly access the files using normal file APIs.
If you've created a directory structure, then you would generally use pathForResource(_:ofType:inDirectory:) to fetch the path to your specific file. Alternately, you can build a path using NSBundle.resourcePath and append your relative path using stringByAppendingPathComponent. The advantage of the pathForResource methods is that they handle localization for you, and this is preferred unless the resource should never be localized (which is rare).

File With Same Name From different folder in ios

I am using "xcode 6.1.1" and "cocos2dx-3.2".
I need to access same file name from different folder.
In Resource i have 3 folder "A,B and C" and all this folder contain image with same name "1.png".
If i need to access 1.png of folder "A" ,How i can do this in cocos2dx please help?
following code is working fine in Android but not working in iOS
helpImage->setTexture("A/1.png");
Thanks.
Didn't used cocos for some time now, but it is pretty easy to do.
Do this:
Prepare directory with your game data. Here lets call it "GameData". Pick name you like.
Drag and drop that directory to the xcode, probably best location is Supporting files. Dialog will show up. Select "Create folder references", deselect copy if needed.
And basically you are done. During build process all resources will be copied to bundle with paths as is in that directory "GameData". So you can have files with same name without problems.

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.

Resources