Skip to content

Commit 04c3363

Browse files
committed
Added keys to Info.plist that make the Documents directory of this app visible to the new iOS 11 Files app and to other apps on the device.
1 parent d2ec28d commit 04c3363

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

iOS File Management.xcodeproj/project.pbxproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@
100100
BC925FDC2088EFEF00E52984 = {
101101
CreatedOnToolsVersion = 9.2;
102102
ProvisioningStyle = Automatic;
103+
SystemCapabilities = {
104+
com.apple.BackgroundModes = {
105+
enabled = 1;
106+
};
107+
};
103108
};
104109
};
105110
};
@@ -282,7 +287,7 @@
282287
DEVELOPMENT_TEAM = "";
283288
INFOPLIST_FILE = "iOS File Management/Info.plist";
284289
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
285-
PRODUCT_BUNDLE_IDENTIFIER = "com.yourDomain.iOS-File-Management";
290+
PRODUCT_BUNDLE_IDENTIFIER = "us.microit.iOS-File-Management";
286291
PRODUCT_NAME = "$(TARGET_NAME)";
287292
SWIFT_VERSION = 4.0;
288293
TARGETED_DEVICE_FAMILY = "1,2";
@@ -297,7 +302,7 @@
297302
DEVELOPMENT_TEAM = "";
298303
INFOPLIST_FILE = "iOS File Management/Info.plist";
299304
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
300-
PRODUCT_BUNDLE_IDENTIFIER = "com.yourDomain.iOS-File-Management";
305+
PRODUCT_BUNDLE_IDENTIFIER = "us.microit.iOS-File-Management";
301306
PRODUCT_NAME = "$(TARGET_NAME)";
302307
SWIFT_VERSION = 4.0;
303308
TARGETED_DEVICE_FAMILY = "1,2";

iOS File Management/FileSystemManager.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ struct AppFile : AppFileManipulation, AppFileStatusChecking, AppFileSystemMetaDa
272272
{
273273
self.fileName = fileName
274274
}
275+
276+
init()
277+
{
278+
fileName = "N/A"
279+
}
275280

276281
func moveToDocuments()
277282
{
@@ -285,8 +290,9 @@ struct AppFile : AppFileManipulation, AppFileStatusChecking, AppFileSystemMetaDa
285290

286291
func write() -> Bool
287292
{
288-
writeFile(containing: "We were talking\nAbout the space\nBetween us all", to: .Documents, withName: "karma.txt")
289-
writeFile(containing: "And the people\nWho hide themselves\nBehind a wall", to: .Documents, withName: "dharma.txt")
293+
_ = writeFile(containing: "This file was written on 5/23/18.\n\nThis file should show up in the Files app.", to: .Documents, withName: "myFileApp.txt")
294+
//writeFile(containing: "We were talking\nAbout the space\nBetween us all", to: .Documents, withName: "karma.txt")
295+
// writeFile(containing: "And the people\nWho hide themselves\nBehind a wall", to: .Documents, withName: "dharma.txt")
290296
return true
291297
}
292298

iOS File Management/Info.plist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
<string>1</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
23+
<key>UIBackgroundModes</key>
24+
<array/>
25+
<key>UIFileSharingEnabled</key>
26+
<true/>
27+
<key>LSSupportsOpeningDocumentsInPlace</key>
28+
<true/>
2329
<key>UILaunchStoryboardName</key>
2430
<string>LaunchScreen</string>
2531
<key>UIMainStoryboardFile</key>

iOS File Management/ViewController.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ViewController: UIViewController {
2424
super.viewDidLoad()
2525
// Do any additional setup after loading the view, typically from a nib.
2626

27-
let file = AppFile(fileName: "iOS file management in Swift 4.txt")
27+
//let file = AppFile(fileName: "iOS file management in Swift 4.txt")
2828
//file.write()
2929
//file.deleteTempFile()
3030
//file.rename()
@@ -33,12 +33,17 @@ class ViewController: UIViewController {
3333
//file.write()
3434
//let exists = file.doesExist()
3535
//print("karma.txt: \(exists)")
36-
file.getAttribs()
36+
//file.getAttribs()
3737
//file.changeExtension()
3838
//file.move()
3939
//file.delete()
40-
print()
41-
file.list()
40+
//print()
41+
//DispatchQueue.main.asyncAfter(deadline: .now() + 60.0) {
42+
let file = AppFile()
43+
_ = file.writeFile(containing: "This file was written for my tutorial on the iOS 11 Files app.\n\nThe text file was written to this app\'s Documents folder.", to: .Documents, withName: "textFile1.txt")
44+
_ = file.list()
45+
print("file written...")
46+
//}
4247
//print()
4348
//print(file.getURL(for: .Temp))
4449
}

0 commit comments

Comments
 (0)