Updating to Xcode 7 Beta 5 & Swift 2 produced multiple errors - ios

I updated Xcode to the new Xcode 7 beta 5. In doing so, it converted to Swift 2, but then created even more errors. Right now, I am completely stuck, and don't know what to do, because although all my errors are gone, my app will not work correctly.
My problem is this:
if(self.myOutput3 as? NSObject == true) {
print("IT IS TRUE")
PFUser.logInWithUsernameInBackground(self.myOutput1 as! String, password: "xxx") { (user: PFUser?, error: NSError?) -> Void in
if error == nil {
print("It Worked!")
// self.presentViewController(destViewController, animated: true, completion: nil)
let instillation = PFInstallation.currentInstallation()
instillation["user"] = PFUser.currentUser()
instillation.saveInBackgroundWithBlock(nil)
self.performSegueWithIdentifier("toTimeline", sender: self)
} else {
// self.enterButton.enabled = false
self.errorAlert()
print("Couldn't log in...")
}
}
} else {
print("IT IS FALSE")
self.performSegueWithIdentifier("continueTheSignIn", sender: self)
// self.move()
}
The program will perform the toTimeline segue, but not the continueTheSignIn . I don't see any logical reason that this is not working. Could anyone point me in the right direction?
Also, I am having an error in my messages feature.
cell.textView!.linkTextAttributes = [NSForegroundColorAttributeName:cell.textView!.textColor]
This is giving me the error "Cannot assign a value of type '[String : UIColor?]' to a value of type '[String: AnyObject]!'
I was not previously getting this error in Swift / Xcode 6.4, so I don't know how to fix it.
Additionally, once I bypass this to get into my app to see if my other features are working, most of my UITableViews are not displaying any information. One is, however the rest load the correct amount of rows, but display nothing. What could this be? Also, no Parse pictures are being displayed correctly either. These are even more concerning than the other problems...
Here is the picture after I deleted and re added the segue under a diff. name.

Parse wont support the beta version . it needs a full version . I have contacted them based on a similar issue . They said they will update the parse to work with xcode7 once the full version of xcode7 is released.

Related

migrating project to comply with google sign in requirements for iOS

I'm trying to get a google sign in button to work with my iOS app, but I'm getting this error here:
Cannot find 'presentingViewController' in scope
This is the code segment:
func handleSignInButton() {
GIDSignIn.sharedInstance.signIn(
with: signInConfig,
presenting: presentingViewController // this is the line with the error,
callback: GIDSignInCallback? = nil) { user, error in
guard let signInUser = user else {
// Inspect error
return
}
// If sign in succeeded, display the app's main content View.
}
}
I've been told I need to migrate the way I am signing in and I found this here:
https://developers.google.com/identity/sign-in/ios/quick-migration-guide
but I'm confused about this part here:
Manually connect GIDSignInButton to a method that calls signInWithConfiguration:presentingViewController:callback: using an IBAction or similar.
Can someone show me how to do this properly? I'm a iOS novice :)
Thanks!

RPScreenRecorder stopRecording block not getting called

I have searched enough but failed to get a solution.
I am using ReplayKit to record the screen of my app. I have started recording the screen by calling
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.startRecording() { error in
if let error = error {
self.showScreenRecordingAlert(message: error.localizedDescription)
}
}
When I am pressing the stopRecord button I am calling
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.stopRecording { previewViewController, error in
if let error = error {
self.showScreenRecordingAlert(message : error.localizedDescription)
return
}
}
But the issue that I am facing is, the program control does not enter inside the stopRecording block.
When I am doing po sharedRecorder.isRecording, it always returns false.
I have done everything I know but failed to get a solution.
If you having this above issue with your code i have found the solution for this.
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.stopRecording { previewViewController, error in
if let error = error {
self.showScreenRecordingAlert(message : error.localizedDescription)
return
}}
Above Block will not call if you running your app on simulator so please use real device to test then above method will call definitely.
Thank you.
Just had this issue running XCode 9.4.1 and building onto iOS 11.4.0. Upgrading the phone to iOS 11.4.1 fixed the bug. I'm not sure if the difference in XCode versions is the root cause or if 11.4.0 was just broken.

Build Failed: Value of optional type '[SFUserAccount]?' not unwrapped

A newbie to native swift development!
Opened the below issue in https://github.com/forcedotcom/SalesforceMobileSDK-iOS/issues/2072
Version of Mobile SDK Used: 5.1.0
Issue found in Native App or Hybrid App: Native App
OS Version: 10.12.5
Device: iPhone 6
Steps to reproduce:
forceios create
Provided application type as native_swift and add other requested details
Open the *.xcworkspace file in Xcode
Build the project
Error: Value id optional type '[SFUserAccount]?' not unwrapped;
func handleSdkManagerLogout()
{
self.log(.debug, msg: "SFAuthenticationManager logged out. Resetting app.")
self.resetViewState { () -> () in
self.initializeAppViewState()
// Multi-user pattern:
// - If there are two or more existing accounts after logout, let the user choose the account
// to switch to.
// - If there is one existing account, automatically switch to that account.
// - If there are no further authenticated accounts, present the login screen.
//
// Alternatively, you could just go straight to re-initializing your app state, if you know
// your app does not support multiple accounts. The logic below will work either way.
var numberOfAccounts : Int;
let allAccounts = SFUserAccountManager.sharedInstance().allUserAccounts()
numberOfAccounts = (allAccounts!.count);
if numberOfAccounts > 1 {
let userSwitchVc = SFDefaultUserManagementViewController(completionBlock: {
action in
self.window!.rootViewController!.dismiss(animated:true, completion: nil)
})
if let actualRootViewController = self.window!.rootViewController {
actualRootViewController.present(userSwitchVc!, animated: true, completion: nil)
}
} else {
if (numberOfAccounts == 1) {
SFUserAccountManager.sharedInstance().currentUser = allAccounts[0]
// ERROR: Value id optional type '[SFUserAccount]?' not unwrapped;
}
SalesforceSDKManager.shared().launch()
}
}
}
The allUserAccounts property of SFUserAccountManager is nullable.
- (nullable NSArray <SFUserAccount *> *) allUserAccounts;
https://github.com/forcedotcom/SalesforceMobileSDK-iOS/blob/master/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Security/SFUserAccountManager.h#L188
If you know for a fact that it will exist at the time you are trying to use it, you can perform a force unwrap by typing allAccounts![0]. If you need to handle the case where it may be nil, you need to check for that by doing something like:
if let accounts = allAccounts
{
currentUser = accounts[0]
}
else
{
// does not exist
}
What I can't tell you is whether it being nil is actually a valid case that you need to handle, as I am not familiar with the library. You'll need to do the research or ask them yourself.
You need to unwrap allAccounts because it's an optional array. And since force unwrapping has been used above to get numberOfAccounts, it's probably safe to use it.
Try this:
SFUserAccountManager.sharedInstance().currentuser = allAccounts![0]

Failed to get images from camera DJI OSMO

I'm working with DJI sdk to get the photographs taken with the camera osmo. The problem I have is that when I show a picture on the screen gives me the following error:
"ERROR: fetchThumbnailWithCompletion: ErrorDomain DJISDKErrorDomainCode = -1004 =" System is busy, Please retry later (Code: -1004). ""
So it is written in the sdk:
#IBAction func onShowThumbnailButtonClicked(sender: AnyObject) {
self.showThumbnailButton.enabled = false
if self.imageMedia?.thumbnail == nil {
// fetch thumbnail is not invoked yet
self.imageMedia?.fetchThumbnailWithCompletion({[weak self](error: NSError?) -> Void in
if error != nil {
self?.showAlertResult("ERROR: fetchThumbnailWithCompletion:\(error!.description)")
}
else {
self?.showPhotoWithImage(self!.imageMedia!.thumbnail!)
}
self?.showThumbnailButton.enabled = true
})
}
}
But I need to show 6 images, therefore I make 6 times (6 times using a do) what is inside the IBAction. Then at that time the error occurs, because if I do it only once that error does not happen.
In addition, selecting ok error that appears like still works for other images but the idea is that no such error appears.
Any idea how to fix it?
Please ensure you have switched the camera to download mode (https://developer.dji.com/iframe/mobile-sdk-doc/ios/Classes/DJICamera.html). If you have already done that, then add delay between photo shooting and download.

Cannot invoke PFFacebookUtils.logInWithPermissions after upgrade to swift 1.2 and xcode 6.3

I updated to XCode 6.3 (and there fore Swift 1.2 with it) and all hell broke loose. So many errors all over the project so Iam going to attempt to understand them one by one. Here's one I fixed myself but just by guessing. Can someone explain what happened here.
Here is the code showing the error (note that this was actually working before the update)
This is how I fixed it, but I don't understand what happened here????
PFFacebookUtils.logInWithPermissions(permissions, block: {
(user: PFUser?, error: NSError?) -> Void in
if user == nil {
println("User cancelled the Facebook Login")
} else if user!.isNew{
println("New User signed up using Facebook")
} else {
println("User logged in through facebook")
self.performSegueWithIdentifier("launchmenu", sender: self)
}
})

Resources