Posts

Showing posts with the label Swift

Can't Change Custom Class Of UIButton To GIDSignInButton

Image
Answer : You should try assign GIDSignInButton not to the Button Object from the Object library but to the the View Object instead It's work for me. It will look like this using UIView instead of UIButton. That's because GIDSignInButton is a subclass of UIView, not UIButton. Add to the storyboard / nib a regular UIView and change it's class to GIDSignInButton instead. From google doc: Add a GIDSignInButton to your storyboard, XIB file, or instantiate it programmatically. To add the button to your storyboard or XIB file, add a View and set its custom class to GIDSignInButton. You can create UIButton and then on its action method you can write this code for signing via google: GIDSignIn.sharedInstance().signIn() It works for me, in this way you can customize UIButton according to your requirement and also perform signin by using google

Adding A Watch App To A Flutter IOS Application

Answer : Flutter doesn't support Apple Watch apps due to the fact that it lacks Bitcode support for iOS as discussed in this GitHub issue. You can track the state of Adding Bitcode support for iOS - Flutter GitHub issue, but currently it seems to have a low priority for the Flutter development team. looks like apple watch development is supported in flutter now. here is an example: https://github.com/magnatronus/flutter-watchtips

Convert String To Date In Swift

Answer : Convert the ISO8601 string to date let isoDate = "2016-04-14T10:44:00+0000" let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: "en_US_POSIX") // set locale to reliable US_POSIX dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" let date = dateFormatter.date(from:isoDate)! Get the date components for year, month, day and hour from the date let calendar = Calendar.current let components = calendar.dateComponents([.year, .month, .day, .hour], from: date) Finally create a new Date object and strip minutes and seconds let finalDate = calendar.date(from:components) Consider also the convenience formatter ISO8601DateFormatter introduced in iOS 10 / macOS 12: let isoDate = "2016-04-14T10:44:00+0000" let dateFormatter = ISO8601DateFormatter() let date = dateFormatter.date(from:isoDate)! Try the following date Format. let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = "yyyy'-'MM...

Crashlytics Does Not Show Crashes

Image
Answer : Checked the following terms, Make sure Crashlytics SDK line is after all other 3rd-party SDK lines. (it needs to be last one called in your appDidFinishLaunching method.) Force a crash and then relaunch the app. Xcode must be disconnected to stop it from intercepting the crash report. To disconnect Xcode, follow the instructions here. If you're using [Crashlytics sharedInstance] crash]; to test crashing, make sure it's not in the appDidFinishLaunching method. These are already mentioned in support section, Here is additional ones - Check in organization -> Your App -> Missing dSYM, Is it showing any missing dSYM file if yes, Then do the following step Right Click on your archive -> Show in Finder -> Right click on file and click on Show package contents Right click on dSYM file - > Show package contents -> Contents -> Resources -> DWARF (Open in terminal) Run command dwarfdump --uuid "file name you saw there in dwarf folder" This w...

Converting String To Int With Swift

Answer : Updated answer for Swift 2.0+ : toInt() method gives an error, as it was removed from String in Swift 2.x. Instead, the Int type now has an initializer that accepts a String : let a: Int? = Int(firstTextField.text) let b: Int? = Int(secondTextField.text) Basic Idea, note that this only works in Swift 1.x (check out ParaSara's answer to see how it works in Swift 2.x): // toInt returns optional that's why we used a:Int? let a:Int? = firstText.text.toInt() // firstText is UITextField let b:Int? = secondText.text.toInt() // secondText is UITextField // check a and b before unwrapping using ! if a && b { var ans = a! + b! answerLabel.text = "Answer is \(ans)" // answerLabel ie UILabel } else { answerLabel.text = "Input values are not numeric" } Update for Swift 4 ... let a:Int? = Int(firstText.text) // firstText is UITextField let b:Int? = Int(secondText.text) // secondText is UITextField...

AlamoFire Download In Background Session

Image
Answer : Update Based on this amazing tutorial, I have put together an example project available on GitHub. It has an example for background session management. According to Apple's URL Loading System Programming Guide: In both iOS and OS X, when the user relaunches your app, your app should immediately create background configuration objects with the same identifiers as any sessions that had outstanding tasks when your app was last running, then create a session for each of those configuration objects. These new sessions are similarly automatically reassociated with ongoing background activity. So apparently by using the appropriate background session configuration instances, your downloads will never be "in flux". I have also found this answer really helpful. Original answer From Alamofire's GitHub page: Applications can create managers for background and ephemeral sessions, as well as new managers that customize the default ses...

Could Not Get GOOGLE_APP_ID In Google Services File From Build Environment

Image
Answer : This worked for me: When install Crashlytic with Firebase, for multiple scheme, you can have error Could not get GOOGLE_APP_ID in Google Services file from build environment . You can fix it by: In Build Settings , add a user define for file name in User Defined : In Build Phases , tap plus button, New Run Script Phase above your Crashlytic build phase, and type this code to the text field. Remember to rename %YOUR_CUSTOM_PATH_TO_FOLDER% to your path to Plist files: GOOGLE_SERVICE_INFO_PLIST_FROM="${PROJECT_DIR}/%YOUR_CUSTOM_PATH_TO_FOLDER%/${FIREBASE_CONFIG_FILE}.plist" BUILD_APP_DIR="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" GOOGLE_SERVICE_INFO_PLIST_TO="${BUILD_APP_DIR}/GoogleService-Info.plist" cp "${GOOGLE_SERVICE_INFO_PLIST_FROM}" "${GOOGLE_SERVICE_INFO_PLIST_TO}" I had this in my "Build Phases" and it's works "${PODS_ROOT}/FirebaseCrashlytics/run" "${PODS_ROOT}/FirebaseCrashlytics/uploa...

Cannot Install Cocoapods - No Podfile Found In The Project Directory

Answer : Steps to add CocoaPods to manage dependencies in your project: sudo gem install cocoapods -> This installs CocoaPods as a piece of software on your machine. Go to the root of your project directory and execute pod init -> This will add a base Podfile to your project. Add the external dependencies that you have to this Podfile by editing it. Run pod install which will fetch all the external dependencies mentioned by you, and associate it with a .xcworkspace file of your project. This .xcworkspace file will be generated for you if you already do not have one. From here on, you should use .xcworkspace file instead of .xcproject / .xcodeproj . Example Podfile Syntax: target 'MyApp' do pod 'AFNetworking', '~> 3.0' end Where AFNetworking is the pod and 3.0 is the specific version that I want to install. Documentation: Using CocoaPods If you want to add a library from GitHub to your own project, after installing gems, ...