iOS Revisited: Errors

Hot

Post Top Ad

Showing posts with label Errors. Show all posts
Showing posts with label Errors. Show all posts

28 Oct 2017

Argument of '#selector' refers to instance method that is not exposed to Objective-C | Add '@objc' to expose this instance method to Objective-C

10/28/2017 08:29:00 am 1
After installing Xcode 9 and migrating to Swift 4 from Swift 3 , @objc inference warning comes like below:

The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the “Swift 3 @objc Inference” build setting to “Default” for the “AppName” target.


If you introduce new methods or variables to a Swift class, marking them as @objc exposes them to the Objective-C run time. This is necessary when you have Objective-C code that uses your Swift class, or, if you are using Objective-C-type features like Selectors.

Fix compiler Errors:

We can fix this @objc inference warning by using two ways.

Solution 1:

One is to use @objc on each function or variable that needs to be exposed to the Objective-C run time as follow:

@objc func getSomeData() {

}

This is the best way for converting your code so that compiler doesn't complain.

Solution 2:

Second one is to add @objcMembers by a Class declaration as follow:

@objcMembers
class Photo {

}

This will automatically add @objc to ALL the functions and variables in the class.

This is a easy way but it increases the application size by exposing functions that did not need to be exposed.

Official Documentation

Read More

25 Sept 2017

could not find a valid GoogleService-Info.plist in your project - iOS, Swift, Objective-C

9/25/2017 11:38:00 pm 0

*** Terminating app due to uncaught exception 'com.firebase.core', reason: '`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/.'
***

Solution 1:

Check the downloaded plist file name. The correct name should be 'GoogleService-Info.plist'.

Some names like GoogleService-Info(3).plist, GoogleService-Info(5).plist are invalid.

Firebase App configuration looks for the 'GoogleService-Info.plist' file. If the name is invalid and the app will crash with the above error.

So change name and Run, it should works without any error.

Solution 2:

Even though changing the name app still crashing then check the selected target for 'GoogleService-Info.plist'

For that first select 'GoogleService-Info.plist' file.

GoogleService-Info.plist'

Next in the right side panel of Xcode, select 'file inspector'. There we can see 'Target Membership' check our target.



Now try Build and Run,it should works without any error.
Read More

Post Top Ad