3

ld: warning: Some object files have incompatible Objective-C category definitions. Some category metadata may be lost. All files containing Objective-C categories should be built using the same compiler.

This warning above appeared when I installed the Firebase/Core through cocopods. And I believe it cause an error, because my project can't read the FIRApp.configure() at App deleagate in my project. I am sure I download the GoogleService-Infor.plist and put it in the right place in project, because I done it on my another project before (work properly), my another project didn't have the Objective-C categories warning.

Can anyone help me out?

The process that I've done:

  1. Add pod 'Firebase/Core' in the project podfile, close the xcode.
  2. Open terminal, go to the target project folder, execute pod install.

    enter image description here

  3. Appear a warning on terminal (Solution: just put the $(inherited) in the build setting of ALWAYS_..., then problem solve) [!] The xxxxxx-ebooking [Debug] target overrides the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES build setting defined in `Pods/Target Support Files/Pods-xxxxxx-ebooking/Pods-xxxxx-ebooking.debug.xcconfig'. This can lead to problems with the CocoaPods installation:

    • Use the $(inherited) flag, or
    • Remove the build settings from the target.
  4. Appear a warning on xcode (This issues are simple, just commit the new files then warning will gone):

    file:///Users/yyyyyy/Projects/xxxxxx_projects/xxxxxx-ebooking/Pods/Target%20Support%20Files/Pods-xxxxxx-ebooking/Pods-xxxxxx-ebooking.debug.xcconfig: warning: Missing file: /Users/yyyyyy/Projects/xxxxxx_projects/xxxxxx-ebooking/Pods/Target Support Files/Pods-xxxxxx-ebooking/Pods-xxxxxx-ebooking.debug.xcconfig is missing from working copy

  5. Ignore the issues process of 3, 4, because it are easy to solve. Because the most wired warning is :

    ld: warning: Some object files have incompatible Objective-C category definitions. Some category metadata may be lost. All files containing Objective-C categories should be built using the same compiler.

  6. Firebase Analytics has not been created. Please, configure Firebase by calling [FIRApp configure]

    I did put the FIRApp.configure() in my project. But when I call FA event on some view did load, it will show this warning. I believe it is because the Objective-C warning.

AL.
  • 36,815
  • 10
  • 142
  • 281
Wangdu Lin
  • 913
  • 1
  • 9
  • 19
  • May be this will help:[http://stackoverflow.com/questions/39665979/xcode-8-objective-c-category-warning](http://stackoverflow.com/questions/39665979/xcode-8-objective-c-category-warning) – Ronak Chaniyara Jan 23 '17 at 05:22
  • @RonakChaniyara Thank you, but I read this article before. I didn't have this issue on my code. And I also didn't install Google Analytics...So sad. – Wangdu Lin Jan 23 '17 at 05:27
  • This is not even an error..This is just a warning about having incompatible Objective-C category definitions and having it won't cause you any issue...Did you copy the FB configuration file to your project? – Jad Jan 23 '17 at 08:21
  • and then FIRApp.configure() in your ApplicationDidLaunch – Jad Jan 23 '17 at 08:22
  • @Jad Yes, as I said in this question. I did put the FIRApp.configure() in AppDelegate in didFinishLaunchingWithOption. This warning is not an error, but I start a new project and follow the same steps of what I did, then it work fine.... Where should I check in build setting? or anything else? – Wangdu Lin Jan 23 '17 at 08:48
  • I solve FIRApp.cinfigure() issues with my friend. We found out my project has been migrate swift 2.3 to 3.0. xcode suggest me to turn didFinishLaunchingWithOptions into private func to avoid warning of 2.3 syntax. Therefore, no matter what code I put inside of the private fun didFinishLaunchingWithOptions it will not fire. So take away the private mark and change the code into swift 3.0. Problem solved. But the warning of objective-c incompatible still don't know where is the reason. – Wangdu Lin Jan 24 '17 at 03:23

2 Answers2

3

see if using @nonobjc on your static variable resolve the issue

irkinosor
  • 766
  • 12
  • 26
2

Finally I solved all bugs, thanks my friend help me to debug and stack overflow community. Here is the solution:

In the beginning I thought this warning "ld: warning: Some object files have incompatible Objective-C category definitions" caused the fail of executing the FIRApp.configure(). But it end out it are two different errors!

First issue, The FIRApp.configure() issues is because my project has error migration when swift 2.2 to 3.0. The xcode suggested me to change the old 2.2 syntax to be private method in AppDelegate:

private func application(application: UIApplication, willFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
    // This method is your app’s first chance to execute code at launch time.
    FIRApp.configure()         
    return true
 }

The FIRApp.configure() will never execute because it is not AppDelegate's method. So, changed back to correct syntax will solve the issues:

func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
    print("Fire! willFinishLaunchingWithOptions")
    return true
}

Second issue, if using the below demo syntax and your project has objective-C in third party plug-in or your code, it will cause the warning "Some object files have incompatible Objective-C...". Maybe, because syntax is old for swift 3.0 so it appear this warning.

class var applicationBuildNumber: String {
    if let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String {
        return build
    }
    return "Build Number Not Available"
}

If you using class function, then this warning will disappear:

class func appLocalBuild() -> String {
    return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
}
Wangdu Lin
  • 913
  • 1
  • 9
  • 19