SlideShare a Scribd company logo
1 of 84
Download to read offline
The Sandbox
Container Directory
Sandbox
Bundle Container
Data Container
Tips
Summary
Sandboxing your app is a great way to protect systems 

and users by limiting the privileges of an app to its intended functionality,
increasing the difficulty for malicious software 

to compromise your users’ systems
Sandboxing your app is a great way to protect systems 

and users by limiting the privileges of an app to its intended functionality,
increasing the difficulty for malicious software 

to compromise your users’ systems
Sandboxing your app is a great way to protect systems 

and users by limiting the privileges of an app to its intended functionality,
increasing the difficulty for malicious software 

to compromise your users’ systems
Sandboxing your app is a great way to protect systems 

and users by limiting the privileges of an app to its intended functionality,
increasing the difficulty for malicious software 

to compromise your users’ systems
With Great Power Comes Great
Responsibility
I ve no great powers.
So there are no responsibilities
(Executable) , Info.plist, Resources ( , , strings )
Codesign Tool Signing Bundle Container Code Seal
Static Library - Executable
Dynamic Library Framework Frameworks
.
iTunes, iCloud
Bundle.main.bundlePath
Read,
Write, Delete, Backup
.a - Static Library ( )
.dylib - Dynamic Library
.framework - (Static / Dynamic) Framework
Data Documents
Library
System Data
Inbox
Application support
Preferences
Caches
Snapshots
tmp
[BundleID]-Inbox
…
NSHomeDirectory()
Data Container
- Documents, Library, tmp
Documents
StoreKit
iOS 11 SystemData ( , , ) -
Read
Write, Delete, Backup
• NSHomeDirectory() + “/Documents"
• FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
• NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
• , , pdf
•
• Documents 

Documents ,
• iTunes, iCloud
Read, Write, Backup
Delete
[ Directory ]
Read, Write, Delete, Backup
[ Files ]
$DocumentsPath + "Inbox"
• e.g.)
• ,
• [file-1.txt, file-2.txt]
• iOS 9.0 . 

Documents Inbx
Read, Backup
Write, Delete
[ Directory ]
Read, Delete, Backup
Write
[ Files ]
[ UIDocumentInteractionController ]
[ iTunes ]
[ Files ]
url - $HomePath/Documents/Inbox/test.pdf
sourceApplication - com.apple.mobilemail
openInPlace - false
annotation - nil
NSTemporaryDirectory() + Bundle.main.bundleIdentifier! + “-Inbox”
• LSSupportsOpeningDocumentsInPlace NO
iCloud / Files / DocumentsPicker
• Documents/Inbox
• tmp
Read, Write, Delete
Backup
[ Directory ]
Read, Write, Delete
Backup
[ Files ]
• NO - Inbox
• YES - url . File Coordinator, File Presenter
• NO - url
file:///private/var/mobile/Containers/Data/Application/[UUID]/tmp/kr.giftbot.demo-Inbox/file.key
• YES - url
file:///private/var/mobile/Library/Mobile%20Documents/com~apple~Keynote/Documents/file.key
• UIFileSharingEnabled = YES
• LSSupportsOpeningDocumentsInPlace = YES
• NSHomeDirectory() + "/Library"
• FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask)[0]
• NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true)[0]
• 

•
• Application Support Caches
• Preference, Cookies, Saved Application State, WebKit
• iTunes, iCloud
Read, Write, Backup
Delete
[ Directory ]
Read, Write, Delete, Backup
[ Files ]
• FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
• NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)[0]
•
• Documents ,
• BundleID
• CoreData
• iTunes, iCloud
Read, Write, Delete, Backup
[ Directory ]
Read, Write, Delete, Backup
[ Files ]
[ Realm ]
[ CoreData ]
• FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0]
• NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0]
• /
• / e.g.) , , , json
• , 

•
• 

•
Read, Write, Delete
Backup
[ Directory ]
Read, Write, Delete
Backup
[ Files ]
• applicationDidEnterBackground(_:)
• Background Foreground
• Restore Application State , Suspend 

Snapshot
• Cover Screen
• UIApplicationExitsOnSuspend
• ignoreSnapshotOnNextApplicationLaunch
func applicationWillResignActive(_ application: UIApplication) {
coverView.backgroundColor = .black
window?.addSubview(coverView)
}
func applicationDidBecomeActive(_ application: UIApplication) {
if window!.contains(coverView) {
coverView.removeFromSuperview()
}
}
YES , Background Suspend (terminate)
( ) , .
•
•
• UserDefaults, Settings.bundle, CFPreferences API
• iTunes, iCloud
$LibraryPath + "Preferences"
Read, Write, Backup
Delete
[ Directory ]
Read, Write, Delete, Backup
[ Files ]
NSTemporaryDirectory()
•
• ,
•
•
Read, Write, Delete
Backup
[ Directory ]
Read, Write, Delete
Backup
[ Files ]
Library/Caches
Library/Cachesin Memory
Library/Caches
tmp
in Memory
Library/Caches
tmp
Library/Caches
in Memory
@discardableResult
func excludeFileFromBackup(at filePath: String) -> Bool {
var url = URL(fileURLWithPath: filePath)
do {
var values = try url.resourceValues(forKeys: [.isExcludedFromBackupKey])
let isExcluded = values.isExcludedFromBackup ?? false
guard !isExcluded else { return true }
values.isExcludedFromBackup = true
try url.setResourceValues(values)
return true
} catch {
return false
}
}
URLResourceKey.isExcludedFromBackupKey (NSURLIsExcludedFromBackupKey)
• +
•
•
• (Documents, Library)
2.23: Apps must follow the iOS Data Storage Guidelines or They Will be rejected
2.23: Apps must follow the iOS Data Storage Guidelines or They Will be rejected
updated, but …
• . 

- 

Dist I/O
• . 

- 

Dist I/O
• -> X

• . 

- 

Dist I/O
• -> X

• URL - resourceValuesForKeys(_:)
• . 

- 

Dist I/O
• -> X

• URL - resourceValuesForKeys(_:)
• - Data.ReadingOptions.uncached
• . 

- 

Dist I/O
• -> X

• URL - resourceValuesForKeys(_:)
• - Data.ReadingOptions.uncached
• , String URL
e.g.) func write(to url: URL, atomically useAuxiliaryFile: Bool, encoding enc: UInt) throws
func write(toFile path: String, atomically useAuxiliaryFile: Bool, encoding enc: UInt) throws
•
Bundle Container Data Container
Documents Application Support
•
•
•
•
•
Documents Library/Caches
Library tmp
•
•
•
•
Library/Caches tmp
The Sandbox Container Directory
The Sandbox Container Directory

More Related Content

Similar to The Sandbox Container Directory

Persistence on iOS
Persistence on iOSPersistence on iOS
Persistence on iOSMake School
 
Into The Wonderful
Into The WonderfulInto The Wonderful
Into The WonderfulMatt Wood
 
Django Overview
Django OverviewDjango Overview
Django OverviewBrian Tol
 
Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data managementPython and Oracle : allies for best of data management
Python and Oracle : allies for best of data managementLaurent Leturgez
 
Tools and Process for Streamlining Mac Deployment
Tools and Process for Streamlining Mac DeploymentTools and Process for Streamlining Mac Deployment
Tools and Process for Streamlining Mac DeploymentTimothy Sutton
 
Extending and Customizing Open Atrium
Extending and Customizing Open AtriumExtending and Customizing Open Atrium
Extending and Customizing Open AtriumNuvole
 
DSC NTUE Info Session
DSC NTUE Info SessionDSC NTUE Info Session
DSC NTUE Info Sessionssusera8eac9
 
Rapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPressRapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPressNathaniel Taintor
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart JfokusLars Vogel
 
iOS Beginners Lesson 3
iOS Beginners Lesson 3iOS Beginners Lesson 3
iOS Beginners Lesson 3Calvin Cheng
 
Amazon WorkSpaces – Fully Managed Desktops in the Cloud
Amazon WorkSpaces – Fully Managed Desktops in the CloudAmazon WorkSpaces – Fully Managed Desktops in the Cloud
Amazon WorkSpaces – Fully Managed Desktops in the CloudAmazon Web Services
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsPetr Dvorak
 
Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Subhransu Behera
 
03 programmation mobile - android - (stockage, multithreads, web services)
03 programmation mobile - android - (stockage, multithreads, web services)03 programmation mobile - android - (stockage, multithreads, web services)
03 programmation mobile - android - (stockage, multithreads, web services)TECOS
 

Similar to The Sandbox Container Directory (20)

Armsec 2017 | 2 bugs 1 safari
Armsec 2017 | 2 bugs 1 safariArmsec 2017 | 2 bugs 1 safari
Armsec 2017 | 2 bugs 1 safari
 
Persistence on iOS
Persistence on iOSPersistence on iOS
Persistence on iOS
 
Into The Wonderful
Into The WonderfulInto The Wonderful
Into The Wonderful
 
Django Overview
Django OverviewDjango Overview
Django Overview
 
Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data managementPython and Oracle : allies for best of data management
Python and Oracle : allies for best of data management
 
Tools and Process for Streamlining Mac Deployment
Tools and Process for Streamlining Mac DeploymentTools and Process for Streamlining Mac Deployment
Tools and Process for Streamlining Mac Deployment
 
Extending and Customizing Open Atrium
Extending and Customizing Open AtriumExtending and Customizing Open Atrium
Extending and Customizing Open Atrium
 
DSC NTUE Info Session
DSC NTUE Info SessionDSC NTUE Info Session
DSC NTUE Info Session
 
Rapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPressRapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPress
 
Ext 0523
Ext 0523Ext 0523
Ext 0523
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
 
iOS Beginners Lesson 3
iOS Beginners Lesson 3iOS Beginners Lesson 3
iOS Beginners Lesson 3
 
Amazon WorkSpaces – Fully Managed Desktops in the Cloud
Amazon WorkSpaces – Fully Managed Desktops in the CloudAmazon WorkSpaces – Fully Managed Desktops in the Cloud
Amazon WorkSpaces – Fully Managed Desktops in the Cloud
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
 
Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1
 
Dspace software
Dspace softwareDspace software
Dspace software
 
Storage 8
Storage   8Storage   8
Storage 8
 
Data Science
Data ScienceData Science
Data Science
 
03 programmation mobile - android - (stockage, multithreads, web services)
03 programmation mobile - android - (stockage, multithreads, web services)03 programmation mobile - android - (stockage, multithreads, web services)
03 programmation mobile - android - (stockage, multithreads, web services)
 
Edubooktraining
EdubooktrainingEdubooktraining
Edubooktraining
 

More from Bongwon Lee

DeprecatedAPI로 알아보는 SwiftUI
DeprecatedAPI로 알아보는 SwiftUIDeprecatedAPI로 알아보는 SwiftUI
DeprecatedAPI로 알아보는 SwiftUIBongwon Lee
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUIBongwon Lee
 
GraphQL over REST
GraphQL over RESTGraphQL over REST
GraphQL over RESTBongwon Lee
 
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9Bongwon Lee
 
LetSwift 2017 - ARKit
LetSwift 2017 - ARKitLetSwift 2017 - ARKit
LetSwift 2017 - ARKitBongwon Lee
 
Realm, Mobile Database
Realm, Mobile DatabaseRealm, Mobile Database
Realm, Mobile DatabaseBongwon Lee
 
Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)Bongwon Lee
 

More from Bongwon Lee (8)

DeprecatedAPI로 알아보는 SwiftUI
DeprecatedAPI로 알아보는 SwiftUIDeprecatedAPI로 알아보는 SwiftUI
DeprecatedAPI로 알아보는 SwiftUI
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 
App Lifecycle
App LifecycleApp Lifecycle
App Lifecycle
 
GraphQL over REST
GraphQL over RESTGraphQL over REST
GraphQL over REST
 
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
 
LetSwift 2017 - ARKit
LetSwift 2017 - ARKitLetSwift 2017 - ARKit
LetSwift 2017 - ARKit
 
Realm, Mobile Database
Realm, Mobile DatabaseRealm, Mobile Database
Realm, Mobile Database
 
Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)
 

Recently uploaded

CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceanilsa9823
 
9892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x79892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x7Pooja Nehwal
 
哪里有卖的《俄亥俄大学学历证书+俄亥俄大学文凭证书+俄亥俄大学学位证书》Q微信741003700《俄亥俄大学学位证书复制》办理俄亥俄大学毕业证成绩单|购买...
哪里有卖的《俄亥俄大学学历证书+俄亥俄大学文凭证书+俄亥俄大学学位证书》Q微信741003700《俄亥俄大学学位证书复制》办理俄亥俄大学毕业证成绩单|购买...哪里有卖的《俄亥俄大学学历证书+俄亥俄大学文凭证书+俄亥俄大学学位证书》Q微信741003700《俄亥俄大学学位证书复制》办理俄亥俄大学毕业证成绩单|购买...
哪里有卖的《俄亥俄大学学历证书+俄亥俄大学文凭证书+俄亥俄大学学位证书》Q微信741003700《俄亥俄大学学位证书复制》办理俄亥俄大学毕业证成绩单|购买...wyqazy
 
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceanilsa9823
 
Chandigarh Call Girls Service ❤️🍑 9115573837 👄🫦Independent Escort Service Cha...
Chandigarh Call Girls Service ❤️🍑 9115573837 👄🫦Independent Escort Service Cha...Chandigarh Call Girls Service ❤️🍑 9115573837 👄🫦Independent Escort Service Cha...
Chandigarh Call Girls Service ❤️🍑 9115573837 👄🫦Independent Escort Service Cha...Niamh verma
 
Model Call Girl in Shalimar Bagh Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Shalimar Bagh Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Shalimar Bagh Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Shalimar Bagh Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Pooja Nehwal
 

Recently uploaded (7)

CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
 
9892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x79892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x7
 
哪里有卖的《俄亥俄大学学历证书+俄亥俄大学文凭证书+俄亥俄大学学位证书》Q微信741003700《俄亥俄大学学位证书复制》办理俄亥俄大学毕业证成绩单|购买...
哪里有卖的《俄亥俄大学学历证书+俄亥俄大学文凭证书+俄亥俄大学学位证书》Q微信741003700《俄亥俄大学学位证书复制》办理俄亥俄大学毕业证成绩单|购买...哪里有卖的《俄亥俄大学学历证书+俄亥俄大学文凭证书+俄亥俄大学学位证书》Q微信741003700《俄亥俄大学学位证书复制》办理俄亥俄大学毕业证成绩单|购买...
哪里有卖的《俄亥俄大学学历证书+俄亥俄大学文凭证书+俄亥俄大学学位证书》Q微信741003700《俄亥俄大学学位证书复制》办理俄亥俄大学毕业证成绩单|购买...
 
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
 
Chandigarh Call Girls Service ❤️🍑 9115573837 👄🫦Independent Escort Service Cha...
Chandigarh Call Girls Service ❤️🍑 9115573837 👄🫦Independent Escort Service Cha...Chandigarh Call Girls Service ❤️🍑 9115573837 👄🫦Independent Escort Service Cha...
Chandigarh Call Girls Service ❤️🍑 9115573837 👄🫦Independent Escort Service Cha...
 
Model Call Girl in Shalimar Bagh Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Shalimar Bagh Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Shalimar Bagh Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Shalimar Bagh Delhi reach out to us at 🔝8264348440🔝
 
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
 

The Sandbox Container Directory