I'm just wondering if this is possible: I have a playground opened on Xcode with multiple .swift source files in it and accessible via a public accessor. Can the same be possible on iPad's Swift Playgrounds?
Yes, this is possible.
On Apple's website they state:
Because you’re working with real code, you can import and export
directly between Swift Playgrounds and Xcode. So you can try out your
ideas with the tool pros use to develop iOS and Mac apps.
Tech Republic provide advice on how to achieve this:
Importing existing Playgrounds from Xcode
Importing Playgrounds from Xcode can be nice when you want to try your hand at coding on the go. To do this, you have two simple options.
Store your documents in iCloud Drive. This is the easiest method and
lets you access your iCloud Drive documents by tapping the + icon in
Swift Playgrounds and selecting iCloud Drive or your other favorite
cloud document storage solution, e.g., Dropbox. Email your documents.
Once you've emailed a Swift document to yourself, open the email on
the iPad, and tap the Playground file. You'll be prompted to select a
share location—select the Copy To Playgrounds option.
Related
My goal is to allow my app user write and read files created by my app. For example, write and then allow the user to email a .CSV file of data, or a .GPX file of location data. And on the other end, import a file back into my application.
I have successfully deployed an Android version of my app (Plant List GPS) which uses Flutter plugin path_provider 1.6.10. On Android, I successfully use external directories, but this external directories solution is not available/allowed for iOS. I find on iOS I can create subfolders and write to the getApplicationDocumentsDirectory, but when I try to find/read that file from a file picker solution, it cannot be seen. I understand this is proper behavior to protect sensitive app files in this folder location.
I also understand that iOS has the concept of an app Sandbox and appreciate its objectives. I'm not trying to defeat it, but find a way to access/use it in my Flutter app. I have played around in writing test data files to various places on the iOS file system using the iPhone 11 simulator on my MacBook, but can not get any file to appear in the phone "Find on my phone" dialog.
Any help in solution approach or technique is appreciated.
I think you need to add both the keys into info.plist, and then files from your app directory will be visible on Files app!
LSSupportsOpeningDocumentsInPlace
UIFileSharingEnabled
As per the documentation, both UIDocumentPickerViewController and UIDocumentBrowserViewController can be used for importing documents outside an apps sandbox.
For selecting & importing a document from local document providers/cloud locations, which one for the above is best suited.Can i still use UIDocumentPickerViewController in iOS 11 ?
As per the following documentation Apple documentation for document picker , Before your app can use the document picker, you must turn on the iCloud Documents capabilities in Xcode and an iCloud container should be mapped to the appId.Is this mandatory if i'm only doing import operation ? I have tried using UIDocumentPickerViewController and it seems to be returning selected file path correctly even without the above mentioned entitlements.
You do not need the entitlement if you do not need your own iCloud container. If you just want to import files, you can use UIDocumentPickerViewController without adding an entitlement.
Yes, UIDocumentPickerViewController works on iOS 11.
The UIDocumentBrowserViewController has to be the rootview of your app, therefore from my experience you can't use within an existing APP and be part of a NavigationControl (you will not be able to get the back buttons properly). In these cases we need to use the UIDocumentPickerViewController. Hope this helps.
I have started a beginning Swift programming class, which is going well so far, but I do not have access to a Mac for Xcode. I do have Swift Playgrounds for iPad, which allows me to complete the assignments and test that they work, but when I try to share the .playground file, it exports a blank file. Is there a solution for this problem?
Failing that, is there a way to save a text file containing Swift code as a .playground file on a PC? Buying a Mac (even a used one) is not an option at the moment, and using the on-campus computer lab takes over 3 hours round trip, so even a very convoluted workaround would be preferable.
You can share the playground from the iOS app to Working Copy, an iOS Git client.
Save in Working Copy > Save as .playground dir
It's free to try and you can export the repository as a zip file. So you can save it to Dropbox, or e-mail it to yourself. If you get the paid version, or in-app purchase, you can push it up to Github, or Bitbucket, which would make it easier to share any changes back. Working Copy can be added to the list of locations you can import Playgrounds from so that would probably be a worthwhile investment.
The enterprise version is the same price as the in-app purchase on the free app and includes the features the in-app unlocks.
Working Copy - Powerful Git client by Anders Borum
https://appsto.re/gb/xONC1.i
Working Copy Enterprise by Anders Borum
https://appsto.re/gb/aEqH5.i
In testing the exporting of a zip file I found the Dropbox support a little glitchy. I had more luck doing 'Import to Evernote' which created a *-playground.zip in Evernote. I could then save that to Dropbox. I've not had a chance to confirm the e-mailed version but it looks okay.
Pushing the .playground up to Github works just fine.
I have an app that downloads files from a web server. Our customer wants the ability to edit those files on their mobile devices and upload the edited version to our servers. Is this possible in iOS? I have figured out how to allow users to view the files in external apps, but I don't see a way to bring back their changes if the file was modified as it seems to copy the file into the other app's space, so my app is left with the unaltered version.
iOS has a sandbox mechanism, so for sure you can not modify any file in another app.
The only way to transfer data from different app is using sharing.
This is a sample project I wrote for implement sharing on iOS, check it:
Sample for sharing on iOS
Hope it can help you.
How can I find out programmatically all the files present in iOS device and list them out to user? Also I need to download the file in my local application database?
How this can be achieved with Objective-C.
You cannot access all files in an iOS device outside the sandbox of the app. But there are other ways you can achieve this. What you can do is:
Access all the files in Gallery using UIImagePickerController.
Access all the user files in network- Dropbox/Google drive/iCloud. They all have separate public APIs that can be downloaded and used to download/upload files in network.
In this way, you can access most of the user files and use the same in your application.
Simple answer : you can't (on a non-jailbroken device).
Each app is launched is in own sandbox and can't interact with the others apps, expect using API provided by Apple for app-communication (ex: extension)
You should look at that Apple guide about App Sandboxing, which is valid for OSX and iOS apps.
The main difference between these two OS, as quoted directly from the doc :
iOS Note: Because it is not for user documents, an OS X container
differs from an iOS container—which, in iOS, is the one and only
location for user documents. In addition, an iOS container contains
the app itself. This is not so in OS X.
You cannot access all the files outside the app sandbox. But, if they are available at some shared location(network), you can use third party libraries to access them. For eg.
1. For iCloud- iOS provides inbuilt framework of UIDocument
2. For dropbox- DropBoxAPI is available
3. For Google drive- there is a separate library to access files in the drive.
Hope this helps :)