sessionWithConfiguration freezing iOS 8 iPhone 4S on new Xcode 6.0.1 - xcode

I am experiencing a disturbing issue when trying to execute one of my apps on an iPhone 4S with iOS8 and Xcode 6.0.1. What happens is that the control seems to freeze in the last instruction of the block:
dispatch_once(&onceToken, ^{
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:#"myBackgroundSessionIdentifier"];
NSLog(#"configuration=%#", configuration);
configuration.allowsCellularAccess = YES;
configuration.timeoutIntervalForRequest = 30.0;
configuration.timeoutIntervalForResource = 60.0;
configuration.HTTPMaximumConnectionsPerHost = 1;
session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:[NSOperationQueue
mainQueue]];
});
Please note that neither the iPad I tested nor the simulator have any issues about it.
Also the same app on the store, compiled with the past Xcode, seems to have no issue on any device, both according to my tests and on the lack of users feedbacks.
I could not test it on my iPhone 4 as I seem unable to install the app on it from the new Xcode: it complaints the iPhone is busy when I try to install it.
Has anyone had a similar problem and knows how to fix it?

Wipe the device and restore from backup.

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.

App not showing same result as Xcode simulator

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.

SIGABRT on Startup in Simulator

I was just running my code on the simulator which has been working in the past. The only thing I've really done for the startup code is setting user defaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
#"Automatic", #"userType",
#"NO", #"autoRefresh",
#"60", #"refreshInt", nil
];
[defaults registerDefaults:appDefaults];
[defaults synchronize];
I ran the app 10 times on my iPhone/iPad and experienced no crashing on startup. However, if I run it on the iPhone/iPad Simulator, the iPhone simulator crashes with SIGABRT basically every other time. I am not sure what's causing this as I've already restarted my computer and did a "Reset all Contents and settings" on the simulator.
Thanks!
Alan
If you are running Xcode 4.6.2 on OSX 10.8.4, try upgrading to Xcode 4.6.3 which was just released a few days ago. The 4.6.3 version has fixes for the random crashes and hangs that sometimes happens when debugging on the ios simulator.
This seems to be a bug in the lldb in chord with the newest version of Moutain Lion. If you want to avoid this switch to using GDB

Why debugger lldb says object is nil in iOS 5.1 simulator?

My write some code like:
_myDataArray = [[NSMutableArray alloc] initWithCapacity : kNum];
for (int i=0; i<kNum; i++) {
MyData *myData = [[[MyData alloc] init] autorelease];
pageData.title = [NSString stringWithFormat:#"No.%d line", i];
[_myDataArray addObject:myData];
}
There is no problem in iOS 4.3 simulator, but lldb debugger says _myDataArray is nil
(lldb) po _myDataArray
(NSMutableArray *) $2 = 0x00000000 <nil>
in iOS 5.0/5.1 simulator, Xcode 4.3.1 but result of in view is correct.
Xcode 4.3.2 looks fix this problem.
I can confirm that we have the same problem with the 5.0 and 5.1 simulator using the 4.3.1 Xcode. Same code with Xcode 4.2.1 and 5.0 simulator doesn't have the problem. Noticed that mutable arrays getting allocated in the order they are in the .h file - stepping through the .m code in debug mode is hilarious because arrays are getting allocated out of order. Solution? Wait for Apple to fix the problem, report the bug, etc.
I can confirm the exact same problem with iOS 4.3, 5.0 and 5.1 both on iDevice and in the Simulator. An Update from Xcode 4.3.1 to 4.3.2 does not solve the problem here...
Switching back to the GDB debugger in the scheme settings solves the problem.
I have the same issue with all of my projects in the 5.0 and 5.1 simulators. XCode 4.3.3 fixed this for me.

iOS App Crashing on iOS 4.2 but not 4.0, simulator not showing logs

Using XCode 3.2.5 I can run my application on iOS Simulator using the 4.2 SDK. However, it crashes on the following function, more specifically, the presentModalViewController call:
- (void)login {
//check to see if they logged in correctly here
/*UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:#"Login Failed!"
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];*/
[self presentModalViewController:self.accountsViewController animated:YES];
}
However, on XCode 4 Dev Preview, I can't even access 4.2 SDK in the Simulator, so I'm forced to use 4.0 SDK. In 4.0, that function works find and as expected. I have two issues:
Why is the 4.2 SDK in the Simulator not reporting the reason it crashed in XCode 3.2.5? It used to be that when my app would crash in debugging mode in the Simulator, XCode would pop up the reason. However, it's not anymore.
Why would that simple line crash in 4.2 but not 4.0. Could it be the different XCode versions?
It was some sort of weird issue between XCode version. I recreated the whole add using solely XCode 3.2.5 and the same exact code now works.

Resources