iosxcodeframeworksnsnetservice

dyld: Symbol not found: _OBJC_CLASS_$_NSNetService Error


So I have the following problem:

launching my application on iOS 8 on my iPhone 5s, I get no error, but launching my app on iOS 6.1.3 on my iPhone 3GS, I get this error:

dyld: Symbol not found: _OBJC_CLASS_$_NSNetService
Referenced from: /var/mobile/Applications/567E221A-FC5C-4011-90AD-E47E5FF033B1/BellyClient.app/BellyClient
Expected in: /System/Library/Frameworks/CFNetwork.framework/CFNetwork
in /var/mobile/Applications/567E221A-FC5C-4011-90AD-E47E5FF033B1/BellyClient.app/BellyClient

I imported a class named Server. The class uses the CFNetwork.framework, which contains the class NSNetService, which is avaiable since iOS 2.0.

Using NSClassFromString(@"NSNetService") is not really a solution I like. I also don't know, why this error occurs, because the class NSNetService should be avaiable in iOS 6. Could it be the device?

I searched and found, that setting the framework to Optional, will solve this issue. But the problem is, that I cannot use the framework, when I run the application on iOS 6. When I do

if ([NSNetService class] == nil) {
    NSLog(@"NSNetService is nil");
}

I get printed NSNetService is nil.

Is it possible to launch the app without crashing and without setting the framework as Optional

Thanks iComputerfreak


Solution

  • Try re-adding Foundation.framework:

    1. Go to your project's target
    2. Choose "General" tab
    3. Under "Linked Frameworks an Libraries" look for Foundation.framework, select it and press the minus ('-') sign at the buttom to remove this framework.
    4. Now press the plus sign ('+') and search for Foundation.framework - re-add it, and it's supposed to fix your crash.

    Hope it works - it did for me.