App Sandbox blocks creation of .sqlite-shm, .sqlite-wal files (swift) - swift

About my problem: I used https://theswiftdev.com/2017/10/27/how-to-launch-a-macos-app-at-login/ for launch my mac-OS app at login it work good. After time I found some problem in my application. My app generated sqlite files like sqlite-shm, .sqlite-wal but after added changеs as "launch" it does't work now.
problems in with "App Sendbox" it included as "on" if I change to "off" my files will be create but "launch" will not be work
How to make these two features work?
Can you help my with my problem?

Ok! i found answer to my question my self)
If it well be halpfully to another peoples i will by happy.
Ok! let's start)
First we are need delete all code as this is linc (of course if you did as in this linc) and then disable the sandbox (cause it blocks kreating sql.lite files)
and second we are need add to info.plist this:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
and thats all)

Related

Sandbox entitlement to script iTunes via NSAppleScript

I'm trying to script iTunes from NSAppleScript in my Cocoa app in order to add a file to the library.
In my entitlements file, I added the following:
<key>com.apple.security.scripting-targets</key>
<dict>
<key>com.apple.itunes</key>
<array>
<string>com.apple.itunes.library.read-write</string>
</array>
</dict>
I then call the AppleScript like this:
var error: NSDictionary? = nil
let appleScript = NSAppleScript(source: "tell application \"iTunes\" to add (POSIX file \"\(path)\") to library playlist 1")
let result = appleScript?.executeAndReturnError(&error)
but it fails with an error -10004: iTunes got an error: A privilege violation occurred.
I tried capitalizing iTunes both ways (itunes and iTunes) but nothing seems to work. I also tried adding, on top of the read-write entitlement, the read entitlement. Finally, I tried adding read and write access to the user's Music folder (where the iTunes library is stored) and this didn't help either.
Is there another required entitlement that I'm not aware of in order to script iTunes?
I found this link in my search for a solution (link) but it requires the user to select a specific folder in his Library folder to give the application user-selected file access and then it requires the script to be in a separate file which is 2 things too many for what I want to do. I don't trust the user regarding the management of the script files and I don't need a file for 1 line of AppleScript code. Another disadvantage, as I understand NSUserAppleScriptTask is that you can't persist a script's state across multiple calls, which is not a problem in my case but could be for someone else.
Thanks
After contacting the Developer Technical Support of Apple, I was able to solve this problem, which is actually 2 problems in one.
First, the entitlements need to have the bundle identifiers properly cased. For iTunes, the entitlements must be like this (note the capital T in iTunes):
<key>com.apple.security.scripting-targets</key>
<dict>
<key>com.apple.iTunes</key>
<array>
<string>com.apple.iTunes.library.read-write</string>
</array>
</dict>
Then, the privilege violation will occur unless the AppleScript code includes of source 1 at the end like this :
tell application "iTunes" to add (POSIX file "your/path/to/mp3.mp3") to library playlist 1 of source 1
There you go!

getting error in DropBox integration to the iphone app

I am trying to integrate the DropBox to my iPhone app. But I get error like
[ERROR] DropboxSDK: unable to link; app isn't registered for correct URL scheme (db-xpt9oxj57x9ftci)
Can anyone help me to solve this?
Most of the time that problem is caused by a misconfigured Info.plist file. Can you make sure you've followed the documentation/index.html about changing Info.plist file? In info plist set db-key in urltype (urlschema). That should do the trick.
I googled and the Dropbox sdk has the line specifically to add the the app key in your app plist file
Your app key is also needed in DBRoulette-Info.plist file so the app
can register for the correct url scheme. To do this, find the file
under the Resources group in the left pane, right-click it and select
Open As → Source Code. Replace the text APP_KEY with your app's key
https://www.dropbox.com/developers/start/setup#ios
I found this solution.
I am working with Xamarin in Windows Visual Studio 2015, and as presented in other queries online, there is no "URL scheme" option available. So the solution is to modify info.plist by hand. Your dropbox specific plist scheme should look like this:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>dbapi-2</string>
<string>dbapi-8-emm</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>db-APP_KEY</string>
</array>
</dict>
</array>
A great helper for me to get this information was the "info.plist" for this. This "info" modification should work for any xamarin project.
If you fix any typos or forget the "db" and are still having problems, clean & rebuild may help.
Your URL scheme should be db-<Your App key>. Example db-a7ghdtthegj6z1g
I had this issue just now and was done in by a space before the db- prefix. Hard to see in the plist editor, but very obvious when I looked at the XML.

How to associate iPhone application with _every_ file type?

There is iPhone app "Another Mail Client" that should be able to open any file to send it as attachment. So, I want to associate this application with any file with any extension.
Following the documentation, we should declare support for files with the root UTI-type public.data – any file should belong to this type. It works, but not at all. In this case, our app will not be able to open any file, but only those which have already been registered in the system. For example, if in any application (e.g., dropbox) we'll try to "open in..." file with an unknown extension (file.unknowntype) using UIDocumentInteractionController, then the answer will be negative despite the fact that we have already registered our application and it supports the root UTI-type public.data. But, if you install another application, which supports files with extension (*.unknowntype), then our application will also be able to open these files and will appear in "open in..." application list.
UPD: #Gabriel This is CFBundleDocumentTypes part of my info.plist file:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>MyMail</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>CFBundleTypeIconFiles</key>
<array>
<string>Icon29.png</string>
...
<string>Icon114.png</string>
</array>
</dict>
</array>
I've made an app with the following setup
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>name</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
</array>
</dict>
</array>
When I try to open a .pdf from Safari, this app shows up in "open in.." list. Can you make a sample app and try it?
UPD:
It seems like claim 'public.data' (tried also public.item, public.content) means file, which belongs to set "all known to system UTIs", not any file. So, you will be able to handle 99% of files, which users want to send by email , but not all. Another way would be to export UTI that you think are important, but which are not in system UTIs by default.
Friend, I read your question properly before posting the answer. I gave another thought that you will have a set of already known "any types" of files to register in a bulk. However, you want to dynamically accommodate your app to register any file type given to your app in future and make it attachable. For this as far as my knowledge is concerned, you cannot make you app to universally support any unknown file type. Let me explain what happens,
Suppose you make an application APP1 then it does not know about a file extension .XYZ and install it on iPhone.
But, later I develop another application APP2, which contains the above code and I register the .XYZ type from APP2 in whatever iPhone it installs.
So, lets say I install APP2 in your iPhone, having APP1. And when my app runs, then the .XYZ extension ( known to APP2 ahead of time) gets registered into the iPhone.
This is the reason now your app APP1 can use this .XYZ file surprisingly.
Concluding, you have to know a specific type of extensions ahead of time before making the app.
However, heres a possible solution for it.
Solution :
Decide the maximum number of characters you want to support in an extenstion. Lets say 4.
Now you can make a small Brute-Force routine to run in your app to make all the possible character combinations and register them all. This should make any file with extension upto 4 characters attachable to mail.
I hope that should do the trick.
Best of luck!
An idea for investigation...
If the installation of another app "fixes" the problem then try inspecting the other apps Info.plist file to see if it is registering or exporting any interesting UTIs or similar settings.
It sounds like your app might only be doing half the job and the other app is completing the missing setup.
You can inspect the contents of an apps ipa file from iTunes by copying it, renaming ipa to zip extracting the contents and then Show Package Contents on the app inside.

Add a file association with tiff files on iOS

I'd like to create a file associate with tiff files in my iOS app (i.e. so that my app appears as a target for opening tiff files from Mail or Safari). Adding the following to my Info.plist file doesn't seem to work:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>tiff</string>
<key>LSItemContentTypes</key>
<array>
<string>public.tiff</string>
</array>
<key>LSHandlerRank</key>
<string>Alternate</string>
</dict>
</array>
I have an app that I associate with PDFs in the same way and it works fine. I believe that it is not possible to associate an app with the tiff file type on iOS, but I can't find any documentation stating that.
Has anyone else had luck getting this to work or finding a definitive "no, you can't do that"?
I burned an Apple TSI on this (I never seem to end up using them anyway) and the official answer is: no, you can't do that.
I've logged an enhancement request on Apple's bug reporting site: http://developer.apple.com/bugreporter/ and I suggest you do too if this issue is a problem for you.
Acorn declares file associations for TIFFs, which seems to work fine.
The only differences I could see between Acorn's implementation and yours is that Gus omits CFBundleTypeName and adds LSIsAppleDefaultForType (set to true). You might want to give that a try.
LSIsAppleDefaultForType is undocumented. There's a reference to it here: http://lists.apple.com/archives/cocoa-dev/2006/Jun/msg00747.html
An general note - the Mail and Safari apps indeed does not allow you to "open with .." tiff files (still true in iOS8);
Nevertheless, a lot of other apps, such as Dropbox, GDrive, etc, does allow you to do that.

Lock-down iPhone/iPod/iPad so it can only run one app

We'd like to 'lock-down' an iPhone/iPod/iPad so that the user can only run one app (we've developed this app internally). I'm guessing we'd be looking at jailbreaking, and then replacing (?) the default Springboard app.
Can we do this? If so, how?
EDIT: iOS 7 now includes an 'App Lock' payload as part of the device configuration profile. From the Apple docs:
"By installing an app lock payload, the device is locked to a single application until the payload is removed. The home button is disabled, and the device returns to the specified application automatically upon wake or reboot."
Read more about it here:
https://developer.apple.com/business/documentation/Configuration-Profile-Reference.pdf
It is possible to put an iPad or iPhone into 'Store Demo' mode so that the home button and swipe to home gesture is disabled. If you have seen the iPads in the Apple Store running the smart sign apps then you will know what I mean.
It is actually pretty trivial to make this work, all you need to do is install a correctly formatted mobile config plist over the air from a web server.
To deliver your config from the web all you have to do is direct the iPhone to a url containing the profile. Just open the link to your .mobileconfig file in safari. If you don't have web space you can just use dropbox public folder URLs or switch on your mac webserver.
It's possible that you can load the config using IPCU too but I have not tried this. This config file will not load in the iPhone Configuration Utility as it uses keys that IPCU doesn't know about. You can combine this with whatever other enterprise configuration profiles you have in play.
EDIT: #cocoanetics pointed out that IPCU is not required to remove the profile. However note that to get your device back to normal you would need to do the following:
Reboot
Open the settings app FIRST - don't open anything else or you will need to reboot again
Settings->General->Profiles->[your profile] remove it.
Reboot
you should be back to normal.
I have included an example plist that will disable the home button and lock your device into the app.
BEWARE
Once this profile is installed the first app that is launched when the device is rebooted will be the only app that will run until you reboot the device again.
As #Cawas has said this completely disables the ability to return to the home screen (unless your app crashes) including accessibility assistive touch.
Note that after installing the profile you must reboot the device (power off, power on) for it to take effect. To remove the profile plug the device into IPCU and delete it then reboot the device. Everything will be back to normal.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadDescription</key>
<string>Disables home</string>
<key>PayloadDisplayName</key>
<string>Home Button Lock</string>
<key>PayloadIdentifier</key>
<string>com.hbkill.kiosk</string>
<key>PayloadOrganization</key>
<string>My Org</string>
<key>PayloadType</key>
<string>com.apple.defaults.managed</string>
<key>PayloadUUID</key>
<string>B2D02E2D-BAC5-431B-8A29-4B91F71C9FC1</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadContent</key>
<array>
<dict>
<key>DefaultsDomainName</key>
<string>com.apple.springboard</string>
<key>DefaultsData</key>
<dict>
<key>SBStoreDemoAppLock</key>
<true/>
</dict>
</dict>
</array>
</dict>
</array>
<key>PayloadDescription</key>
<string>Disables Home Button</string>
<key>PayloadDisplayName</key>
<string>Home Button Lock</string>
<key>PayloadIdentifier</key>
<string>com.hbkill</string>
<key>PayloadOrganization</key>
<string>My Org</string>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadUUID</key>
<string>614D1FE3-F80D-4643-AF6B-D10C4CC8737A</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</plist>
You may well have moved on from this but I thought I would post this answer here as I came across the question while I was trying to figure out how to do the same thing.
This is a feature of iOS 6 that can be used without hacky attempts. It's called 'guided access'. I small tutorial is here.
EDIT: In case the device's battery runs empty while it's in the hands of a restricted user, the user could reload the device and it will reboot without guided access. However, if you choose to use a password for the device, this shouldn't be a problem.
An alternative to the (admittedly much simpler) approach described by Rick is to:
disable the home button (e.g. physically covering it),
disable the five-finger gesture and screen lock in the Settings, and
install a “Trampoline” to relaunch the app should it crash.
http://www.apple.com/support/ipad/enterprise/
Apple provides enterprise configuration tools which allow control over which applications are permitted etc. This is done through profile management it seems. See link for more details
I agree with a comment from some hours ago: Settings > General > Restrictions should do the trick. If the user can't install anything, can't access Safari or Mail, then there is no reason to ever quit your app.
Block internet access from device (MAC-filter on wi-fi can do the trick). Any other non-internet related problem (music, games, etc) should already be solvable by the current IT infrastructure (unless your developers plays and listen to MP3 at work).
i found one way to quit this home-lock state.
i have install "backgrounder" via cydia which make your app run in background if you press home button for one second or more.
and now, when i longpress home button, i back to the home screen.
that is all.
pay attention on longpress.
Um- wasn't sure if this is an answer or a comment but - the solution that is now part of the question has a weakness - our support staff used this and found that if you "Tap the power button to ‘soft-off’ then hold the home button as you power on and slide to unlock. Sometimes iPad will start on the home page or else XXAPPLCATIONXX will hang and then drop out to the home page. Eitherway X is able to access the home page without the passcode."