App not showing same result as Xcode simulator - xcode

I am new to Xcode and app programming and developed a small app to get certain calendar events and present them in a NSTableview.
The program is working fine in my Xcode simulator.
However when I build for running and start the App on my iMac, is is not returning any calendar events. Just runs and ends without any errors.
What am I missing here?

Problem was solved by adding [store requestAccessToEntityType:(EKEntityTypeEvent) completion:^(BOOL granted, NSError *error) after the allocation of the EKEventStore.

Related

Not getting APNS Device token on ios 13

I have issue related to APNS device token . Before I was using Xcode 10.2 and iOS 12.1. At this moment I used to get the device token in delegate method
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
I am registering for APNS like this and it was working fine.
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if(!error){
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}];
Now when installed iOS 13 to my iPhone device and using Xcode 11 , the delegate method didRegisterForRemoteNotificationsWithDeviceToken is not called. Unable to understand this problem .
I have already done research over this , I know there are some changes in getting token from the delegate method but in my case delegate method is not even called. Again it's working fine for iOS 12.
Just reboot your iPhone. It's as simple as that and in 90% of cases it will solve your problem.
Logon on https://appleid.apple.com/, then open url "https://developer.apple.com/account/ios/identifier/bundle"
or "https://developer.apple.com/account/resources/certificates/list".
First, Create two New Certificates:
(1)Apple Development
Sign development versions of your iOS, macOS, tvOS, and watchOS apps. For use in Xcode 11 or later.
(2)Apple Distribution
Sign your apps for submission to the App Store or for Ad Hoc distribution. For use with Xcode 11 or later.
Then find menu "Identifiers" via url "https://developer.apple.com/account/resources/identifiers/list".
Edit your Identifiers of your app, make sure that Development SSL Certificate & Production SSL Certificate is added to the Push Notifications.
Next, open menu "Profiles" via url "https://developer.apple.com/account/resources/profiles/list".
Make sure that the Certificates as type of DistributionFor which will be used in Xcode 11 or late, and save
Lastly, download the Provisioning Profile file and the CA Certificates files created to your MAC, which will be added to XCode and key-chain application by double click the files separately.
What's more, remember to reboot your cell phone, and make sure that you had setup the remote notification correctly.
I also faced the same problem. I tried many scenarios. I got success after doing the below steps:
Restarted device
Called the registerForRemoteNotifications
method in the main thread.
In my case, I was getting a device token, but there is a delay in response (I think due to registering remote notifications in a background thread). But after moving [[UIApplication sharedApplication] registerForRemoteNotifications] in the main thread, all works fine.
Here is my code:
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = delegate;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if(!error){
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
[self callCompletion:TRUE completion:completion];
});
}
}];
Hope this will help.
I just solved this problem this way following below steps.
Add some print in didRegisterForRemoteNotificationsWithDeviceToken method and keep devices connected.
Went to the target capabilities.
Turn the Push Notification Off
Build & Run the app on device and wait.
Then check the console you got Fail push notification error message.
Stop running the app.
Turn the Push Notification On again.
Goto https://developer.apple.com/ Choose Account -> Certificates, Identifiers & Select your project ProvisionalProfiles -> Keys ->click on edit and save after that download provisonal profile and double click on it.
Build & Run the app on device.
Then its working fine.
I hope this help someone.
It is related to DeviceSupport missing in your XCode installation, for platform version used by your deploy device.
In my case, the 13.1 platform were missing.
To solve, just add the DeviceSupports in folder
Xcode.app/Contents/Develper/Platforms/iPhoneOS.platform/DeviceSupport
You can download missing DeviceSupport from:
https://github.com/iGhibli/iOS-DeviceSupport/tree/master/DeviceSupport
Try this.
Remove your application.
Reboot your phone.
Build and Run(reinstall your application) on your device.
It worked for me.

MKMapView not Rendering in iOS 8 or later

I'm having an issue in MKMapView in iOS 8.x.x. Application works fine iOS 7.x.x but not in iOS 8.x.x. On device it shows only annotations but no map behind.
I tried to forcefully Reset my Device as well but no luck.
I added these 2 Values in info.plist as well as it was a requirement for iOS 8 and onwards
<key>NSLocationAlwaysUsageDescription</key>
<string>Location is required to find out where you are</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is required to find out where you are</string>
and added this lines of code in my Viewdidload.
// Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.
if ([self.locationManager respondsToSelector:#selector(requestWhenInUseAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
//[self.locationManager requestAlwaysAuthorization];
self.myMapView.showsUserLocation = YES;
}
By adding these 2 values in info.plist and the above lines of code, I'm able to get the User's Location and annotation in showing on map for user's location but Map is Blank.
Similar to this post:
MKMapView showing blank screen in iOS 8
Had the very same thing on IOS8.3 both sim and device.
Solved by running the system Maps App (it displayed empty grid as well) for a minute till it downloaded maps. After that my MKMapView started rendering as normal.
try add the delegate methods: - (void)mapViewWillStartLoadingMap:(MKMapView *)mapView;
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView;
- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error;
and check the solution for you error message.
also check this solution i don't got rid of the grind but at least i got rid of the didFail error.
but seems to be an issue of iOS8 because on iOS8.3 works fine the same code.

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
}

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

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.

Xcode Instruments throwing error "Could not start script, target application is not frontmost."

I am currently adding UIAutomation acceptance tests for an existing iPad application. I have a custom shell script that runs instruments from the command line and resets the simulator before running the tests. When it tries to run the UIAutomation tests it fails with the error "Could not start script, target application is not frontmost."
I tried troubleshooting this by attempting to reproduce it in the GUI version of instruments and was able to reproduce it. It only happens the first time the app is launched after installation and it only happens in the iPad 6.0 Simulator. When I run through the same scenario in the iPad 5.1 Simulator it works fine. After launching in instruments on the 6.0 simulator, any UIAutomation script that I try to run on the app returns the "Could not start script, target application is not frontmost." error.
The app itself is not doing anything special in the AppDelege. It initializes the window.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
It creates a view controller and assigns it as the root view controller:
MyViewController *viewController = [[MyViewController alloc] initWithModel:self.myModel];
[self.window setRootViewController:viewController];
[self.window makeKeyAndVisible];
This is done in the didFinishLaunchingWithOptions method.
I am doing something very similar in another app and do not experience this error. I'm curious to see if anyone else has run into this problem and what they did to resolve it.
I'm using Xcode 4.5.2
I have the same error.
1.You can run the app (Not use Instruments)
2.Stop it.
3.Use Instruments run the app.
Then it will be ok!

Resources