url(forUbiquityContainerIdentifier) returns nil - ios

I'm trying to get the url for my contrainer ID but the method keeps returning nil.
I've done the following:
Enabled iCloud Key-value storage in Xcode capabilities.
testing on a physical device.
iCloud, and iCloud Drive turned on in the physical device.
Made sure that iCloud Key-Value Store is added to the entitlements file.
My code is:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Override point for customization after application launch.
let cloudURL = FileManager.default.url(forUbiquityContainerIdentifier: nil)
print(cloudURL as Any)
return false
}
I have looked for almost all of the questions that are related to this issue and tried the answers but it's not working.

For Xcode 9.2, checking this option worked:

iOS10.3
I had same problem, fix it by following steps:
1.go to physical device's setting -> iCloud. turn off iCloud Drive and turn it on again, find your app in iCloud Drive, turn off and turn on.
2.shut down your device, and restart it.
Then it worked, I'm not sure which part make it worked, hope for help.

Try this :
Inside the Settings app, under the 'iCloud' menu. I noticed that 'Documents & Data' was set to Off.
Solution was to change ('Documents & Data' to 'On'.

Related

Crashes not showing up in Firebase console

I'm trying to transition my iOS app from Crashlytics to Firebase, since Crashlytics is going to be shut down in a month. I went through the steps described here:
https://firebase.google.com/docs/crashlytics/get-started-new-sdk
It all looked great until I tried my first test distribution. I added a piece of code that would crash the app on a button tap to test that I get the crashes from distributed apps. However, it didn't work. The app crashes, but I see no crash reports. I do see that Crash-free users percentage is going down though. So something is getting registered, but the actual crashes are not there.
My fists couple of test distributions were missing DSYMs. And under DSYMs tab I could even see the crash count. However, when I did upload the DSYMs the crashes still didn't appear.
Now I'm using a script that does the DSYM upload on archive, but crashes are not showing up still.
When I do a build using Xcode and force crash everything works as expected. It's only the distributed AdHoc builds don't show any crashes in the portal.
Any kind of help is highly appreciated.
If your forced crash didn't crash, crashed before you wanted it to, or you're experiencing some other issue with Crashlytics, you can enable Crashlytics debug logging to track down the problem.
To enable debug logging on your development device, specify the following command line argument in Xcode:
Crashlytics 3.11.1+
-FIRDebugEnabled
Previous versions
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Initialize Firebase service.
FirebaseApp.configure()
Fabric.sharedSDK().debug = true
return true
}
Boom, after hours of trying and searching.
https://github.com/firebase/firebase-ios-sdk/issues/2901
Disabling bitcode for AdHoc builds fixed it for me.

IOS - second launch of my app going auto in background

when I start my application from Xcode, the application works properly, but if I close and then open the app again, it goes into the background automatically without control. How can I fix this bug ?
There are some crash types those will not be happening when running the app via Xcode.
For example:
If the app launch takes too long, that app will be crashed. Basically it’s not a crash, but app needs to be launched quickly without delay which is expected by operating system.
So You need to make sure that you are not doing any heavy operations on Main Thread during app launch especially on below methods in AppDelegate
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Avoid heavy loads on main thread here
return true
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Avoid heavy loads on main thread here
return true
}
Also I received a crash a few years back when I tried to add an objective c struct to my NSObject class without allocating memory of struct variable. But this crash was unable to reproduce when I was running my app via Xcode and only happened when I launch the app without Xcode. So I made that struct variable as a pointer and did memory allocation as like (BoothStructure*)malloc(sizeof(BoothStructure) * count), after that there was no crash.
So please analyze your crash using crash logs as well and check if it meets any one of above scenario.
To check crash log of development build:
Open Xcode -> Connect your iOS device which has/had the crashed app -> Window -> Devices and Simulators -> View Device Logs
To check crash log of production build(you should add your developer account in Xcode that is used to publish your app):
Open Xcode -> Window -> Organizer -> Select your app from the list of apps -> Select crashes tab in segmented controller at top -> Select your build version.

NSException when using Firebase

I followed all the steps correctly to install Firebase to my iOS App and it still doesn't work. In the application method, I added FIRApp.configure() like so:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
And I keep receiving NSException errors. Firebase seems to work on my Android Project, what's the deal with iOS?
I believe this is some sort of Swift 3 issue, because I encountered a similar problem. After looking over the internet, I believe that Firebase 3 hasn't updated to recent Swift Syntax located in Swift 3. Many other developers are having trouble with it as well. As an alternative, you could switch back from Xcode 8 and into 7, which would allow you to create your application which will work with current IOS, and when Firebase updates, it will be easy for you to migrate to Swift 3.
Hope this helps,
Morgan Gallant

Settings Blank On First Launch With registerDefaults

I have an issue with registerDefaults of NSUserDefaults with a settings bundle. Perhaps others have dealt with this issue and simply ignored but it's hit a point where I'm convinced this is either a bug or we're approaching the issue incorrectly.
Create a new dictionary and register it.
Launch the app.
Go to iOS Settings App
Go to your app settings and see the only things visible are location and camera.
Previous solution: Swipe up on the settings app to close and relaunch it then all of the settings appear.
Obviously this isn't ideal and although we have been dealing with the issue ever since iOS 7 I believe I am ready for a real solution since it's become more problematic for support lately. Has anyone had this work on first launch and if so, can you please share your technique?
Things we've tried.
Moving the register function to init() = same result
Calling register after didFinishLaunching = same result
Only add one option to narrow down issue = same result
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var appDefaults = Dictionary<String, AnyObject>()
appDefaults["some_setting"] = true
appDefaults["some_setting2"] = false
NSUserDefaults.standardUserDefaults().registerDefaults(appDefaults)
NSUserDefaults.standardUserDefaults().synchronize()
return true
}
This was FINALLY fixed in iOS 10 with no changes necessary to the code above. THANK YOU APPLE!

App Crashes on AppDelegate Class Declaration with EXC_BAD_ACCESS CODE 1 on iOS 9.1/9.2

I installed XCode 7.1 and 7.2 to update my app for iOS 9.1 and 9.2 respectively, but each time I run the app on simulators or devices the app crashes on the AppDelegate's class declaration as shown below. However, I have also XCode 7.0 and when I run my app on iOS 9.0 it works fine without any issue !.
The problem even if I compile the app for iOS 9.0 it would crashes on any device running iOS 9.1 or 9.2, I tried to change the initial view controller to be a simple plain one but it seems that it never reaches the point of loading view controllers and never reaches the beginning of func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool.
It seems that Apple did something with iOS 9.1 & 9.2. The app is written in swift, I enabled NSZombie and breakpoints to catch exceptions but I get no clue from the logs.
Debug Navigator:-
AppDelegate Class Declaration
That happens to me almost every time in new versions of Xcode/Swift/iOS. When I have had this problem I have erased that line and written it again.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
This happens when you have not set you variable types correctly. Check how you declare them. In my case i was trying to access a Bool as UIColor.
I've generally had this happen when there is a storyboard problem. For example, an error in:
storyboard.instantiateController(withIdentifier: "FooView")
Try putting breakpoints around controllers that are being loaded around where you are crashing to see if that's the problem.

Resources