Out of the blue I can't get security scoped bookmarks - macos

Blimey, this Sandboxing makes me despair: I have an app that's been released on Apple's store (so, in theory, it's gone through review...), it's a slide show player - nothing too fancy - the user can drag and drop images onto an NSTableView or select through NSOpenPanel. Anyway, I thought I'd use it myself so I recompiled a copy onto my laptop and all of a sudden I'm not allowed security bookmarking:
QuickSlide(1412) deny mach-lookup com.apple.scopedbookmarksagent.xpc
The above appears whenever I drag and drop images or select them through the NSOpenPanel.
I have the following entitlements:
The code I'm using to generate the bookmarks is:
-(NSData*)genSec:(NSURL*)aURL
{
NSError *error;
NSData *secData = [aURL bookmarkDataWithOptions:(NSURLBookmarkCreationWithSecurityScope | NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess | NSURLBookmarkCreationPreferFileIDResolution)
includingResourceValuesForKeys:nil relativeToURL:nil error:&error];
if (error) {
[self setReport: [NSString stringWithFormat:#"Can't access %# due to SandBoxing",aURL]];
return nil;
}
return secData;
}
Sure enough, the report method is also fired along with the Console logging.
It's never done this before in the months I did of development. I've also tried it on my dev Mac Pro crate, tried code-signing with different or no signing, and even downloaded it from the App Store (tried twice with 2 different accounts); all with the same result. I've also used the very handy Receigen app to check the entitlements in the compiled bundle. I'm running 10.7.5. The only thing that stops it from throwing errors is if I un-check the 'enable sandboxing' option in Xcode and compile.
Argghhh. Can someone point out the blindingly obvious mistake that somehow has slipped through 2 beta-testers, me, and an App Store reviewer...?!!!!
It has to be something obvious doesn't it?
UPDATE: I got a colleague to download a fresh copy to his laptop and there was no problem with sandboxing. I'd still appreciate it if anyone can shed some light on what's happening to my installs...
Todd.

Sure enough it seems from your entitlements that it is something obivous. You need to add this one as well:
com.apple.security.files.bookmarks.app-scope
I don't know why it was working before and now isn't, but I'm positive you need to declare this entitlement for security scoped bookmarks to work.

Related

Share extension working on simulator but not on device

I have a share-extension bounded with my app. I have all the required app-ids and provisioning-profiles related to the extension, for both development and distribution. When I run the extension in the simulator, it works perfectly fine. On device (i.e. iPhone 6), for example, when choose my app's share extension within Safari, Safari freezes and nothing opens. I cannot even debug it, not because that I don't know how to do it but because it runs and immediately stops running afterwards on Xcode.
I think that something might be wrong with the provisioning-profiles or app-ids or it might be a bug or a 'missing functionality prior to distribution' caused by Apple.
I would very much appreciate it if someone has any solution to or explanation about it.
EDIT:
I changed the background-color of the extension's view on storyboard to see if it does not work at all. It does open, but SLComposeServiceViewController did not show up. Thus, the problem must be caused by it.
If there is anyone still having this issue, please check your Share Extension deployment info and ensure your target OS is lower than your phone's OS
I finally solved my problem. It was not a provisioning-profile nor an app-id issue. I had written
override func viewDidAppear(animated: Bool) {}
method in the SLComposeServiceViewController class. It turns out that the only culprit was this method. I removed that and the share extension worked perfectly.

How can I make a Rate-Button in iOS7?

I want to add a rate-button to my application. How can I do this?
- (IBAction)rateGame {
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:#"itms-apps://itunes.apple.com/app/idYOUR_APP_ID"]];
}
In the simulator, this doesn't work. (Can't test it on a real device right now)
Is this the correct way to do this or should I try something else?
Your code is correct for launching the App Store with the app page open; I use the same code in my shipping app. This is the best you can achieve on iOS 7. It doesn't work on the iOS Simulator because the simulator doesn't have the App Store or iTunes apps installed, so there's nothing to launch.
Try using iRate. Handle all network connection and other related issues. And easy to implement. Just drag and drop files to your AppDelegate. It automatically configures all the required terms(like app store id, etc) from the info.plist files, and gets all the required information from app store.
NOTE: iRate can be used without any configuration, just by dragging and adding the files to project. See this example.
#import "iRate.h"
#implementation AppDelegate
+ (void)initialize
{
//configure iRate
[iRate sharedInstance].previewMode = YES;// yes for testing
}

Main window doesn't run properly on Snow Leopard

My app developed in Xcode 4.5 on Mountain Lion runs flawlessly on Lion and ML.
My Snow Leopard tester reports that when the app starts, it is disabled. By that he means none of the controls are active and the red, yellow, green 'traffic light' is greyed out. If another app is opened that covers my app, when the covering app is moved, any control, or part of a control it covered is not there.
The menu bar is responsive, and my preferences panel works. The app can be shut down from the menu, I don't know if it can be shut from the keyboard.
Another app that uses the same serial code works fine.
I need help with putting together a plan to solve it. I don't know how to trace this.
Fundamentally, the problem is that you're expecting data to be in NSUserDefaults. On first launch, NSUserDefaults returns nil for the keys you access, and passing this nil result through later code causes exceptions to be thrown. The solution is to register defaults with NSUserDefaults upon application startup:
#implementation AppController
+ (void)initialize
{
NSDictionary *defaultValues = #{#"SomeKey" : #"DefaultValue"};
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
}
#end

ibtool failed when compiling storyboard

I just downloaded a project from a git repository on two different Macbooks. On the first, it runs without problem.
On the second Macbook shows me the following message:
Command /Applications/Xcode.app/Contents/Developer/usr/bin/ibtool
failed with exit code 255
When trying to compile the file MainStoryboard.storyboard.
When I click the MainStoryboard.storyboard on XCode, it crashes and doesn't open it.
On the other computer, everything works fine.
I tried the following things to fix this problem, without success:
1) Upgraded XCode from 4.5 to 4.5.2
2) Removed the project directory and cloned the repository again.
3) Deleted the contents of my project on ~/Library/Developer/Xcode/DerivedData
4) purge
Any ideas on how to fix this problem?
Found this issue using XCode 5.
I've solved the issue, but it required a hard reset.
Some said it was because I installed XCode outside of the App Store, or because the simluator was buggy, or because XCode was pointing at the wrong version of the Simulator, or a resoruce was missing a target membership, or whatever. I tried all of that.
I downloaded XCode from the App Store, re-installed the Simulators, and still no luck. So I just rolled back my repository to an earlier date, and lost some work in the process. Not much though, because I always commit little and often.
Since ever starting to use storyboards back in 2011, I have always committed little AND OFTEN. Storyboards are fragile.
EDIT
After adding the new components back in, the problem re-surfaced.
I noticed that I put a static table view, within a UIViewController. I was doing this before.
I was using a subclass of UITableViewController in code, but the storyboard scene, was a UIViewController. I dragged out a UITableViewController instead, and moved the table view cells into that, and it solved the issue.
All thanks to missing error messages. Where have they all gone since XCode 5?
Do a
which ibtool
At the command line on both Macs. Chances are they are different.
Before Xcode was bundled in a single .app bundle it would install command line tools in folders like /usr/local.
I would recommend you remove those local copies to avoid interference with Xcode's built in version, i.e. that it uses the old version. If you still want to be able to use ibtool from the command line, here's an explanation about xcrun: http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/
Almost half year later I finally succeeded to discover what was causing this problem and fixed the bug.
Now, with XCode 4.6.3 it gives me another clue about the problem:
2013-06-28 18:15:32.606 Interface Builder Cocoa Touch Tool[7894:f07] CFPreferences: user home directory at file://localhost/Users/[myusername]/Library/Application%20Support/iPhone%20Simulator/User/ is unavailable. User domains will be volatile.Command /Applications/Xcode.app/Contents/Developer/usr/bin/ibtool failed with exit code 255
After receiving this new message, I searched for this User folder inside "iPhone Simulator" and there were no folder named "User".
I created the "User" folder, did a clean and after this I was able to build the project again!
the fix for me in Xcode 6.4 was to ... restart my computer. sad, but true.
I was getting the same error. It turned out I had miswired some of the outlets in the tableview cell.
I don't know if someone is still struggling with this error but today was my turn to confront it. I just solved it. This is the context:
I had a UITableViewCell with half of it cover by a simple UIVIEW. Inside this UIVIEW i had many other view (UILables, UITextField, etc etc)
Just where the UIVIEW ended (Again it covered the middle of the entire UITableViewCell) i placed an UIImageView. Half of the UIImageView covered the UIView and the other half was on the UITableView itself. In the Hierarchy the UIImageView was on the UITableVIewCell and not inside the UIView.
The problem was when i was applying autolayout i put a constraint between a view inside the UIView and the UIImageView that was outside of the UIVIEW.
When i run the app, the error came up. After half an hour deleting views and stuff i realized that the error was caused by that constraint. After deleting that constraint, the error was gone.
So bottom line, check your constraints! only "Connect" views with others that are inside the same superView.
Good luck!
Try completely reinstalling Xcode. Seems like there's something wrong with ibtool that a reinstall is probably able to fix.

UIAlertView with text fields not moving up

I want to display a prompt to get a user's username and password.
I am doing this by displaying a UIAlertView and adding UITextFields as subviews to it.
Recently I moved my project over to XCode 4.2 and I updated all my project settings. My base SDK is set to iOS 5.0 and my deployment target is set to 4.0.
I then noticed that it was only being built for armv7 architectures and so I changed that to include armv6 as well since I would like to support the iPhone 3G as well.
After doing this I noticed that the UIAlertView wasn't moving up as before and now it was being covered by the keyboard when it was displayed. I read in the Apple documentation that you shouldn't subclass UIAlertViews (http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html) and so I changed the way I was doing things. This didn't solve the problem.
I have noticed that I can get it to work on my phone (an iPhone 4, so armv7 architecture) by setting the Build Setting - "Build active architecture only" to YES.
I suspect that the problem is something to do with trying to build for armv6 (and indeed removing this from the architectures I am trying to build for gives me alerts which move up correctly).
I suppose I should get to my question now... I'm struggling to understand why this is behaving the way it is. I read somewhere (can't find the link now) that you don't need to move the alert up manually when adding a text field to a UIAlertView in iOS 4 and above. Since I am building for at least iOS 4 shouldn't this work on both architectures?
Also, how can I get it to build for armv6 and still have alerts which move up correctly?
Edit: Maybe I was wrong but I have noticed that I have 2 instances of my phone which I can deploy the app to. Selecting the first one and building gives me an app where the UIAlertViews don't move up when they should, but selecting the second one makes it work properly. Would post a screenshot, but I'm a new user and so I don't have the permissions necessary yet...
Oki,
I've managed to come up with a solution which works and gets the UIAlertView to be in the correct position, but I'm still not entirely sure what the root cause of the problem is.
I solved it by responding to the UIAlertViewDelegate method willPresentAlertView: and doing the following
- (void) willPresentAlertView: (UIAlertView *) alertView {
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
if (keyWindow.center.y - alertView.center.y < 0.001f) {
CGPoint center = [alertView center];
center.y = center.y - 108.0f;
[alertView setCenter:center];
}
}
It checks whether the UIAlertView is in the center of the screen and moves it up if it is (i.e. if the OS hasn't already calculated the correct position of it). Note: You would need to add a check for which specific orientation the device is in and then adjust the amount the alert is moved up accordingly if you wanted this to work for both portrait and landscape orientations.

Resources