Working with files outside sandbox in Mac App (Accessing Security Scoped Resource)

I was developing an Mac application recently and came across the problem, which was quite interesting and i thought I can share my experience with you guys.

ok, let me directly get it stright. Recently I developed a Mac application for binary resigning, the functionality of the app is to take your ipa files and resign it with different certificates and provision profiles.

I developed this app successfully and tried to publish on app store using app Store connect. But when I try to push the app to App Store, Apple didn’t allow me to publish stating the reason “I am not using App Sandbox in my application”. Problem is my app needs to access resources outside of the sandbox, if I enable sandbox I won’t be able to access system directories like “~/Library/MobileDevice/’Provisioning Profiles”, which is essential for resigning. I did some research and found a solution, which is what I am about to explain below.

1) Enable sand box to your application under signing and capabilities

2) Update your entitlement files

All three items are mandatory. com.apple.security.files.bookmarks.app-scope will allow to bookmark urls outside of the sandbox and com.apple.security.files.user-selected.read-write will allow to read and write files outside of the sand box. using the combination of these three permissions we will be accessing files outside of the sand box.

  • First we will request read and write access for a specific directory
  • Then bookmark that directory and save it to local storage
  • Using startAccessingSecurityScopedResource function we will access system directories out side of sand box.

I wrote a simple code snippet for this solution.

Hope this will be helpful for you guys. Happy Coding ­čśü!!!

Lankahomes.lk – adspace.lk

adspace.lk is a online website, that helps uses to advertise their properties online for free. I started creating this project after dropping isaithuli.com, but unlike isaithuli.com now i learned a lot about web development technologies and now i am in my final year of my college, while developing this project. i had lot of college work to do in my final year, therefore i know i cant spend more time on this project, so i was looking for the easiest way to do it.

I downloaded a HTML theme form Themeforest.com and modified it according to my requirements, then using my knowledge on PHP and MYSQL database i was able to complete this project put it live within 3months. at that moment adspace.lk looked like this.

Although i completed the site successfully and running it properly, i was not happy about  the amount of customer and visitors to the site, so i thought something need to change and i decided to redevelop the website with new interface theme and latest technologies.

Now i have finished my college and i had lot of free time and i started working as a PHP developer in one of the big web development companies in Sri Lanka. But i was not paid enough to fulfill my basic needs with the salary i was getting as a fresher. So i started doing project for other people as a freelancer, this gave me a wast knowledge on Codeigniter ( A beautiful and easy learning PHP framework). With this knowledge on technologies i started redeveloping the website, as usual i download the HTML theme from themeforest.com and started modifying it to my expatiation and using my knowledge on Codeigniter i created a fully working product, where users can login and post their properties by themselves and using the admin panel i will decide weather to display the properties or not. This project took almost around 6 months to complete. Now the site looks much better than adspace.lk, ah i forget to tell, i changed the name and re-branded the site as lankahomes.lk. Now the site looks like this

with this design and function, I made lot of promotions on facebook and google ad-words. But i was still not happy about the number of users.

https://www.facebook.com/lankahomeswebsite/