GCDAsyncUdpSocket does not compile for iOS - objective-c

I use this library: https://github.com/robbiehanson/CocoaAsyncSocket
There are examples for TCP on the iphone but not UDP. I think that everything should be just the same. Here is my code:
#import <UIKit/UIKit.h>
#class GCDAsyncUdpSocket;
#interface ThirdViewController : UIViewController
{
GCDAsyncUdpSocket *udpSocket;
}
.m:
#import "ThirdViewController.h"
#import "DDLog.h"
#import "DDTTYLogger.h"
#import "GCDAsyncUdpSocket.h"
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
#implementation ThirdViewController
- (void)viewDidLoad
{
[DDLog addLogger:[DDTTYLogger sharedInstance]];
udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
}
But when compiling I get the errors:
Undefined symbols for architecture i386: "_OBJC_CLASS_$_DDLog",
referenced from:
objc-class-ref in ThirdViewController.o "_OBJC_CLASS_$_DDTTYLogger",
referenced from:
objc-class-ref in ThirdViewController.o "_OBJC_CLASS_$_GCDAsyncUdpSocket",
referenced from:
objc-class-ref in ThirdViewController.o ld: symbol(s) not found for architecture i386
What is wrong? Examples from the library compiled without errors.

You have to link CFNetwork.framework or if have it you're propably working on Automatic Reference Counter, turon off ARC for GCDAsyncUdpSocket using -fno-objc-arc

(Build Phases >> Link Binary With Libraries) Add CocoaLumberjack as optional dependency.

Related

Undefined symbols "_OBJC_CLASS_$_" error

My project is written in ApplescriptObjC and Objective-C.
I have an NSTabViewDelegate, which must be written in ObjC:
#import <Cocoa/Cocoa.h>
#import "MSItems.h"
#interface MSTabView : NSTabView<NSTabViewDelegate>
- (void)tabView:(NSTabView *)tabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem;
#end
#implementation MSTabView
- (void)tabView:(NSTabView *)tabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem {
if ([[tabViewItem identifier] intValue] == 1) {
[MSItems myMethod];
}
}
#end
MSItems class is written in ApplescriptObjC, but I created a header file, which contains only the method I need to be called by other classes.
#import <Cocoa/Cocoa.h>
#class MSItems;
#interface MSItems : NSObject
+ (void) myMethod;
#end
In the ASObjC class i have:
script MSItems
property parent : class "NSObject"
on myMethod()
--stuff
end myMethod
end script
But the app doesn't compile and I get the error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MSItems", referenced from:
objc-class-ref in MSTabView.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

iOS using microsoft band build error

I created the project, imported the microsoft band sdk
http://developer.microsoftband.com/download/Microsoft%20Band%20SDK%20for%20iOS.zip
And I tried intimate the sdk sensor sample
http://developer.microsoftband.com/download/Microsoft%20Band%20SDK%20and%20Samples%20for%20iOS.zip
my viewcontroller.h:
#import <UIKit/UIKit.h>
#import <MicrosoftBandKit_iOS/MicrosoftBandKit_iOS.h>
#interface ViewController : UIViewController<MSBClientManagerDelegate>
#property (strong, nonatomic) IBOutlet UIActivityIndicatorView *ConnectionIndicator;
.
.
.
other UI components
.
.
.
#end
my viewcontroller.m:
#import "ViewController.h"
#interface ViewController ()
#property (weak,nonatomic)MSBClient *client;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[MSBClientManager sharedManager].delegate = self;
_client = [[[MSBClientManager sharedManager] attachedClients]firstObject];
if ( _client == nil ) {
NSLog(#"Band connected failed: No Band paired");
return;
}else{
[[MSBClientManager sharedManager] connectClient:_client];
NSLog(#"Trying to connect to Band...");
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)clientManager:(MSBClientManager *)clientManager clientDidConnect:(MSBClient *)client{
}
-(void)clientManager:(MSBClientManager *)clientManager clientDidDisconnect:(MSBClient *)client{
}
-(void)clientManager:(MSBClientManager *)clientManager client:(MSBClient *)client didFailToConnectWithError:(NSError *)error{
}
#end
Warning:
Ld DerivedData/SenseWatch/Build/Products/Debug-iphoneos/SenseWatch.app/SenseWatch normal arm64
cd /Users/Jieyi/Documents/Repo/SenseWatch
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -L/Users/Jieyi/Documents/Repo/SenseWatch/DerivedData/SenseWatch/Build/Products/Debug-iphoneos -F/Users/Jieyi/Documents/Repo/SenseWatch/DerivedData/SenseWatch/Build/Products/Debug-iphoneos -F/Users/Jieyi/Downloads/MicrosoftBandKit_iOS_SAMPLES_1.3.10427.1 -filelist /Users/Jieyi/Documents/Repo/SenseWatch/DerivedData/SenseWatch/Build/Intermediates/SenseWatch.build/Debug-iphoneos/SenseWatch.build/Objects-normal/arm64/SenseWatch.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -miphoneos-version-min=8.0 -dead_strip -fembed-bitcode-marker -fobjc-arc -fobjc-link-runtime -framework MicrosoftBandKit_iOS -Xlinker -dependency_info -Xlinker /Users/Jieyi/Documents/Repo/SenseWatch/DerivedData/SenseWatch/Build/Intermediates/SenseWatch.build/Debug-iphoneos/SenseWatch.build/Objects-normal/arm64/SenseWatch_dependency_info.dat -o /Users/Jieyi/Documents/Repo/SenseWatch/DerivedData/SenseWatch/Build/Products/Debug-iphoneos/SenseWatch.app/SenseWatch
ld: warning: URGENT: all bitcode will be dropped because '/Users/Jieyi/Downloads/MicrosoftBandKit_iOS_SAMPLES_1.3.10427.1/MicrosoftBandKit_iOS.framework/MicrosoftBandKit_iOS(MSBClientManager.o)' was built without bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. Note: This will be an error in the future.
ld: warning: URGENT: all bitcode will be dropped because '/Users/Jieyi/Downloads/MicrosoftBandKit_iOS_SAMPLES_1.3.10427.1/MicrosoftBandKit_iOS.framework/MicrosoftBandKit_iOS(MSBBLEProvider.o)' was built without bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. Note: This will be an error in the future.
ld: warning: URGENT: all bitcode will be dropped because '/Users/Jieyi/Downloads/MicrosoftBandKit_iOS_SAMPLES_1.3.10427.1/MicrosoftBandKit_iOS.framework/MicrosoftBandKit_iOS(MSBClient.o)' was built without bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. Note: This will be an error in the future.
ld: warning: URGENT: all bitcode will be dropped because '/Users/Jieyi/Downloads/MicrosoftBandKit_iOS_SAMPLES_1.3.10427.1/MicrosoftBandKit_iOS.framework/MicrosoftBandKit_iOS(MSBDeviceManager.o)' was built without bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. Note: This will be an error in the future.
...
Error:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_CBUUID", referenced from:
objc-class-ref in MicrosoftBandKit_iOS(MSBBLEProvider.o)
objc-class-ref in MicrosoftBandKit_iOS(MSBSpple.o)
objc-class-ref in MicrosoftBandKit_iOS(MSBPeripheral.o)
objc-class-ref in MicrosoftBandKit_iOS(MSBSensorManagerUtility.o)
objc-class-ref in MicrosoftBandKit_iOS(MSBZippyPushV2.o)
objc-class-ref in MicrosoftBandKit_iOS(MSBZippyCargo.o)
objc-class-ref in MicrosoftBandKit_iOS(MSBZippyCargoV2.o)
...
"_CBCentralManagerOptionShowPowerAlertKey", referenced from:
+[MSBBLEProvider buildCBCentralManagerOptions] in MicrosoftBandKit_iOS(MSBBLEProvider.o)
"_OBJC_CLASS_$_CBCentralManager", referenced from:
objc-class-ref in MicrosoftBandKit_iOS(MSBBLEProvider.o)
"_CBCentralManagerOptionRestoreIdentifierKey", referenced from:
+[MSBBLEProvider buildCBCentralManagerOptions] in MicrosoftBandKit_iOS(MSBBLEProvider.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
and I am pretty new to Xcode and objective-c
I have no idea what is this.
You are missing the CoreBuetooth framework. Include The framework under the link with libraries section.

Cocoa touch Framework with Unit tests

In Xcode 6 with Objective-C:
When I create a Cocoa Touch Framework the project has already a unit test target.
Assuming I have the following class and unit test case in my framework:
//Framework
#interface MyClass : NSObject
- (NSString*)greetings;
#end
#implementation MyClass
- (NSString*)greetings {
return #"Hello";
}
#end
// Test class
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "MyClass.h"
#interface MyClassTests : XCTestCase
#end
#implementation MyClassTests
- (void)testGreetings {
MyClass *myClass = [[MyClass alloc] init];
XCTAssertTrue([[myClass greetings] isEqualToString:#"Hello"]);
}
#end
When I try to run the test I get:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MyClass", referenced from:
objc-class-ref in MyClassTests.o
Why is the test target not finding my classes? I can't figure out what is wrong. I assume that the Xcode template would set up everything correctly.
you add this x86_64 architecture in Build setting -> Valid Architecture x86_64 and try it. It can be work.
Refer the architecture:
armv7: Used in the oldest iOS 7-supporting devices
armv7s: As used in iPhone 5 and 5C
arm64: For the 64-bit ARM processor in iPhone 5S
i386: For the 32-bit simulator
x86_64: Used in 64-bit simulator

Objective-c subclassing gives linking error

I'm trying to port a game to iOS but I'm having a problem. I have a class called CKSprite with the following method:
- (id)initWithFile:(NSString *)fileName effect:(GLKBaseEffect *)effect
{
if ((self = [super init]))
{
//some stuff
}
return self;
}
I then have a subclass called CKPLayer (it has no other methods or properties at the moment other than what it inherits:
#property (strong) CKPlayer *player1;
But when I try to initialise it using the parent method:
self.player1 = [[CKPlayer alloc] initWithFile:#"Images/parrot.png" effect:self.effect];
I get this error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CKPlayer", referenced from:
objc-class-ref in CKViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is my first time trying to do anything like this so I've probably done something stupid.
Any help will be greatly appreciated.
#import "CKSprite.h"
#interface CKPlayer : CKSprite
#end
The linker is missing the implementation for the class CKPlayer. Maybe you just forgot to implement it since it has "no other methods or properties at the moment", in that case just add a file which should look like:
#import "CKPlayer.h"
#implementation CKPlayer
#end
and ld should be happy

Getting Strange Error Running Objective C Code

My project have no visible error but when i try to run it gives following error
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ConcreteScreen", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am using my ContactScreen class in ViewController.m
i tried by #class ContactScree and #import "ContactScreen.h"
and in my ViewController i am using it as [ContactScreen myMethod];
when i comment out this line it work fine but now it is giving compile time error :(
yesterday it was wroking fine
here is my code
#import "ViewController.h"
#import "ConcreteScreen.h"
#interface ViewController ()
#end
#implementation ViewController
-(IBAction)btnContactPress:(id)sender{
NSLog(#"Contact Screen");
ConcreteScreen *coontact = [[ConcreteScreen alloc]init];
}
You confused ConcreteScreen and ContactScreen and compiler told you that it isn't aware about ConcreteScreen
Be sure your .m file is included in the project. It's possible to create it, use the header and all but it doesn't go into the build. Also it needs to be in the target.