Mac App Store Rejection and Sandboxing Requirements

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
stephenmcnutt
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 107
Joined: Fri Nov 10, 2006 8:58 pm
Contact:

Mac App Store Rejection and Sandboxing Requirements

Post by stephenmcnutt » Thu Mar 31, 2016 12:15 am

I've got an app in the Mac App Store, but I haven't been able to update it in almost a year. The sandboxing requirements have changed, I'm sure, and now I seem to be in violation. Specifically I stand accused of attempting to write to data files in the app package. My app does copy data files from the package to the proper location for data in the user library container, but I'm pretty darned sure I'm not trying to write to the files in the package.

I've heard the sandboxing requirements now forbid some "shell" commands. I use shell commands because I've read in these forums that revCopyFile still seems to have issues. Here's how I'm doing that...

local tItemDelimParking
local tPackageDefaultFolder
put the fileName of me into tPackageDefaultFolder
put the itemDelimiter into tItemDelimParking
set the itemDelimiter to "/"
put "" into the last item of tPackageDefaultFolder
set the itemDelimiter to tItemDelimParking
put "CQdata" after tPackageDefaultFolder
set the defaultFolder to tPackageDefaultFolder
put tPackageDefaultFolder & "/Questions.rev" into gPackageFilePath_Questions
put tPackageDefaultFolder & "/Settings Saver.rev" into gPackageFilePath_Settings_Saver
put tPackageDefaultFolder & "/Teams.rev" into gPackageFilePath_Teams

put specialFolderPath("Home") & "/Library/Containers/com.classroomquizshow.classroomquizshow/Data/Library/Application Support/Classroom Quizshow" into gLibraryDefaultFolder
--This folder automatically created by OS X for App Store apps.
put gLibraryDefaultFolder & "/Questions.rev" into gLibraryFilePath_Questions
put gLibraryDefaultFolder & "/Teams.rev" into gLibraryFilePath_Teams
put gLibraryDefaultFolder & "/Settings Saver.rev" into gLibraryFilePath_Settings_Saver
if there is no file gLibraryFilePath_Settings_Saver then -- if Library data files don't yet exist
local tCommand
put ("cp -n "&quote&gPackageFilePath_Questions&quote&&quote&gLibraryDefaultFolder&quote) into tCommand -- The -n means the file will not be overwritten if it already exists. http://ss64.com/osx/cp.html
get shell(tCommand)
put ("cp -n "&quote&gPackageFilePath_Teams&quote&&quote&gLibraryDefaultFolder&quote) into tCommand
get shell(tCommand)
put ("cp -n "&quote&gPackageFilePath_Settings_Saver&quote&&quote&gLibraryDefaultFolder&quote) into tCommand
get shell(tCommand)
set the destroyStack of stack gLibraryFilePath_Questions to true
set the destroyStack of stack gLibraryFilePath_Settings_Saver to true
set the destroyStack of stack gLibraryFilePath_Teams to true
close stack gLibraryFilePath_Questions
close stack gLibraryFilePath_Settings_Saver
close stack gLibraryFilePath_Teams
end if


Here's some feedback someone in the Apple app review department was kind enough to provide me:

Upon further investigation, the app is performing a "rename" command on the previously mentioned file writes which may give some insight as to how the files are being acted upon.

"Classroom Quizs" - WRITE - rename - “/Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Teams.rev~" - /Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Teams.rev
"Classroom Quizs" - WRITE - rename - “/Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Questions.rev~" - /Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Questions.rev
"Classroom Quizs" - WRITE - rename - “/Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Settings Saver.rev~" - /Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Settings Saver.rev


I know I don't have the word "rename" anywhere in my code, so this is somehow being generated in standalone creation. Any ideas? Also, it looks like the new and old names in the attempted renames only differ by that squiggle/tilde thing on the end. Might that be a clue?

Thanks in advance,
Steve

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Mac App Store Rejection and Sandboxing Requirements

Post by FourthWorld » Thu Mar 31, 2016 12:50 am

stephenmcnutt wrote:I use shell commands because I've read in these forums that revCopyFile still seems to have issues.
What problems have you encountered, and can you share the bug report numbers related to them, or the URLs to discussions here where the poster has provided the bug report number?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

tomBTG
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 73
Joined: Fri Nov 25, 2011 6:42 pm

Re: Mac App Store Rejection and Sandboxing Requirements

Post by tomBTG » Thu Mar 31, 2016 3:25 pm

Hi Steve.
"Classroom Quizs" - WRITE - rename - “/Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Teams.rev~" - /Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Teams.rev
Perhaps the clue in Apple's comment about the renaming is the ~ at the end of the file extension. Did you put it there? ("yourfile.rev~" is usually what remains of a file after a failed save operation by Livecode, so it would be unusual for an author to use that.) Apple might be seeing an aftereffect (the .rev~ file) of whatever has gone wrong earlier in the execution of your code.

In my experience, revCopyFile has worked on Mac and Windows standalones in LC 6.x and 7.x. I am using Apple's general sandboxing rules as they apply to third-party developers, which include that the app cannot write data back to itself, or anywhere in the Applications folder.

Along with revCopyFile and revCopyFolder, I often use standard stack save commands to put files in new places, like user Docs folder. And to create my app's Preferences stack files, I create empty stacks and write them to a location in the AppData library. Then I populate them with custom props or whatever else is needed. These methods have been highly reliable for me. But who knows how long that will continue with Apple's tendency to rewrite the rules!

Hope that helps.
Tom Bodine

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Mac App Store Rejection and Sandboxing Requirements

Post by jacque » Fri Apr 01, 2016 8:56 pm

You can avoid shell and the revCopy command both by using the simple URL syntax:

put url ("binfile:" & tSourceFilePath) into url ("binfile:" & tDestinationFilePath)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Mac App Store Rejection and Sandboxing Requirements

Post by Klaus » Fri Apr 01, 2016 9:06 pm

Hi Stephen,

this:
"Classroom Quizs" - WRITE - rename - “/Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Teams.rev~" - /Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Teams.rev
"Classroom Quizs" - WRITE - rename - “/Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Questions.rev~" - /Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Questions.rev
"Classroom Quizs" - WRITE - rename - “/Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Settings Saver.rev~" - /Applications/Classroom Quizshow.app/Contents/MacOS/CQdata/Settings Saver.rev
looks like your app is accessing these stacks inside of the APP package and the engine/standalone is trying to save the stacks there, which is of course TABOO!
Please check the part of your app where you open/access these stacks!

You are obviously trying to copy these stacks to somewhere else, but in the end the standalone opens these stacks inside of the APP package.


Best

Klaus

Post Reply