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.
Related
I am writing an iOS 15 app (no need to worry about anything prior to iOS 15) that operate will between other processes in a workflow.
I need to be able to list/find files whose names will start with a known pattern. These files will reside in one of two places: 1) The User's Downloads folder and 2) A folder titled XYZFolder under the Shortcuts folder.
The XYZFolder folder already exists as it was created by an iOS Shortcut. That same Shortcut also created the files in that folder which my application needs to locate at a later date/time.
I am assuming that I can obtain a URL fairly easily to the Downloads folder since it belongs to the User.
How do I go about obtaining a URL to the Shortcuts folder??
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
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.
I'm trying to write two separate submittable apps: one for iPad and the other for iPhone. This necessitates having two separate plists to allow independently specifying different app icons, launch images, etc.
When I try to rename my Info.plist, MonoDevelop autocreates a new empty Info.plist and uses that instead. By the same token, I can't seem to move my Info.plist to the iPad/ subfolder and have MD pick it up there.
Currently we have 3 projects in 1 solution: iPad, iPhone, common files and libraries.
Is the only solution to have separate .sln files in the appropriate subfolders, or can I still somehow build two separate apps from one .sln?
EDIT: Project structure is below if that helps visualise the problem.
MyApp.sln
MyApp-iPad.csproj
MyApp-iPhone.csproj
MyApp-Common.csproj
Main.cs
AppDelegate-iPad.cs
AppDelegate-iPhone.cs
Info.plist (MD currently uses this for both projects)
Common/
iPad/
iPad/Info.plist (for -iPad.csproj)
iPhone/
iPhone/Info.plist (for -iPhone.csproj)
Here's my current and very ordinary solution: Add a custom command that runs Before Build
cp iPad/Info.plist Info.plist
And for iPhone:
cp iPhone/Info.plist Info.plist
I have a project where I need to be able to build the application with different icons and resources.
I use different build profiles and build scripts that copy in the correct files into a resources folder. This also changes the application name and identifier.
This is a similar solution to yours, but it would allow you to bundle different images with your application like you wanted.
You need to make 2 projects, one for iPad and one for iPhone.
You should "link-in" all the code files from one project to the other. You can have different Info.plist files, icons, images, etc. with this route.
Here is a link talking about various strategies: http://docs.xamarin.com/ios/Guides/Application_Fundamentals/Building_Cross_Platform_Applications/Sharing_Code_Options
I'm working on a iOS application that will contain around ~6000 mp3 of sounds files.
Each one is around 1 second (2 max) long and rather low quality (24K bitrate) weighting in at around 2-3KB each. (Please do not comment on the quality, it's as it should be)
Since this is a large amount of files I was wondering what we be the best approach for packing these into the bundle? Should I just throw them together in a group? Is there someway of storing them in a single "package" file then reading them out separately as needed?
Also, what would be the best place to place them: Library/ ? Documents/?
As I'm rather new to iOS development and kick in the right direction will be greatly appreciated.
Thanks in advance,
Ken.
You can create a bundle which will contain all your mp3 files. Your files will be in the ressources of your application, no need to store them in the Documents or Library path of your application sandbox.
The way to create and access a bundle is illustrated here.
Hope this helps
There is no package type that were meant for resource files. There are ones for static and dynamic libraries, custom frameworks and so on, but purely for resources I know of none.
Instead of adding them in bulk into a Group in Xcode's project hierarchy, you should add the containing folder as a folder reference to the project. (Appears in the file navigator in blue.) This way any external modifications you make to the contents of the folder, like adding/removing files will automatically be picked up when you next compile your project.
You can do this by dragging the folder from within Finder to the project browser in Xcode and when asked choose "Create folder references for any added folders".