I'm including the Layar SDK framework into my app (version 8.0) and everything works fine on a device.
However, I can't run the app on a simulator anymore - I don't mind Layar not working (there's no camera after all!) but I do need it to compile for continual integration, automated tests etc (not to mention developing on the train top/from work!)
The linker gives me these errors :
ld: warning: ignoring file /Users/username/Documents/appname/libs/MPOAuth/libMPOAuthMobile.a, missing required architecture i386 in file /Users/username/Documents/appname/libs/MPOAuth/libMPOAuthMobile.a (2 slices)
ld: warning: ignoring file local/LayarSDK/LayarSDK.framework/LayarSDK, missing required architecture i386 in file local/LayarSDK/LayarSDK.framework/LayarSDK (2 slices)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_LayarSDK", referenced from:
objc-class-ref in MYAppDelegate.o
ld: symbol(s) not found for architecture i386
Checking, the LayarSDK doesn't contain i386, it only contains armv7 and armv7s.
My solution is pretty clumsy - if anyone has a better idea, please let me know!
I compile this file (LayarSimulatorStub.m) into my app :
#if TARGET_IPHONE_SIMULATOR
#import <Foundation/Foundation.h>
#interface LayarSDK : NSObject
#end
#implementation LayarSDK
+ (id)layarSDKWithConsumerKey:(id)a andConsumerSecret:(id)b andDelegate:(id)c { return nil; }
- (id)init { return nil; }
- (id)initWithConsumerKey:(id)a andConsumerSecret:(id)b andDelegate:(id)c { return nil; }
#end
#endif
Now, there is an i386 symbol LayarSDK. It just returns nil from all it's constructors. The app now compiles with Layar disabled.
The conditional compilation means that it's not present for the device architectures so there are no linker errors.
Related
The API for dragging and dropping into a UICollectionView changed in iOS 11 Beta 4. In beta 1-3, the code looked like:
let placeholderContext = coordinator.drop(
item.dragItem,
toPlaceholderInsertedAt: indexPath,
withReuseIdentifier: "reuseID",
cellUpdateHandler: { _ in }
)
In beta 4, the introduced UICollectionViewDropPlaceholder. My code is
let placeholder = UICollectionViewDropPlaceholder(
insertionIndexPath: indexPath,
reuseIdentifier: "reuseID"
)
let placeholderContext = coordinator.drop(item.dragItem, to: placeholder)
I am getting this compile error:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_UICollectionViewDropPlaceholder", referenced from:
objc-class-ref in StickerLibraryViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
note: symbol(s) not found for architecture arm64
error: linker command failed with exit code 1 (use -v to see invocation)
Other than not using a placeholder until beta 5, anyone have any ideas of how to get this working in beta 4?
Thanks!
Until this is fixed in Beta 5, I ended up solving this issue by dropping down into the Objective-C runtime.
In the Obj-C header…
NS_ASSUME_NONNULL_BEGIN
#interface RKNFactory : NSObject
- (UICollectionViewDropPlaceholder*)placeholderForIndexPath:(NSIndexPath*)indexPath resuseIdentifier:(NSString*)reuseIdentifier;
#end
NS_ASSUME_NONNULL_END
In the implementation…
#import ObjectiveC.runtime;
#implementation RKNFactory
- (UICollectionViewDropPlaceholder*)placeholderForIndexPath:(NSIndexPath*)indexPath resuseIdentifier:(NSString*)reuseIdentifier {
SEL initSelector = NSSelectorFromString(#"initWithInsertionIndexPath:reuseIdentifier:");
Class placeholderClass = NSClassFromString(#"UICollectionViewDropPlaceholder");
return [[placeholderClass alloc] performSelector:initSelector withObject:indexPath withObject:reuseIdentifier];
}
#end
And then from the Swift code…
return RKNFactory().placeholder(for: indexPath, resuseIdentifier: reuseIdentifier)
I had a similar problem with local authentication not compiling on on the simulator architecture when it was in beta.
Does it compile if you remove arm64 from valid architectures in build settings (or turn off “build all architectures”)?
If they compiled this symbol for simulator, but left it out for arm64, the only solution might be to prevent it from compiling on arm64 and test it only on the simulator for now.
You can also wrap the code temporarily in a “#if block” that prevents the compiler from looking at it when building arm64.
Finally, if you’re building for any versions of iOS under iOS 11, be sure to try turning those off for now, in case they forgot to mark API availability (which might have let the compiler provide a more helpful message).
I have an iOS app and am using XCode Version 6.3.1 (6D1002).
I have a m file in which I define
#interface CustomObject:NSObject {} #end
and I try to use in viewDidLoad as
CustomObject* obj = [[CustomObject alloc]init];
When I run this, I get linkage errors saying
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_CustomObject", referenced from:
objc-class-ref in ChooseAlbumViewController.o
ld: symbol(s) not found for architecture x86_64
I have similar interfaces defined for other objects and those continue to build, link and run fine. Any new interfaces I'm defining are failing with these linkage errors. I could use some help to figure out what's causing this. I'm new to iOS development so if I'm missing information crucial to figure this out please let me know and I'll add it.
Few flags from my Build Settings that might help -
Build Active Architecture Only = YES
Architectures = Standard Architecture armv7 armv64
Valid Architectures = arm64 armv7 armv7s
Here is the code in which I define the interface and try to use it
#interface CustomAlbum : NSObject {
}
#end
#implementation ChooseAlbumViewController
{
}
- (void)viewDidLoad {
[super viewDidLoad];
CustomAlbum* a = [[CustomAlbum alloc] init];
}
Figured it out, the problem was that I had only defined an interface but had not defined an implementation. Adding
#implementation User
#end
to the .m file solved the linkage issues.
Thanks for the help guys
Most of the time, this happens when your class isn't being compiled into the target you want. Select the .m file that CustomObject is in and check the right sidebar. In the first tab, there should be a list of targets. Check ✔️ your current target so that Xcode compiles it.
while compiling the source file ChooseAlbumViewController looks for a corresponding header. The header named CustomAlbum doesn't match. This causes the error message.
In adding 64 bits support to some iOS code I maintain, I found that the nlist function is not available for the x86_64 architecture (64 bits iOS simulator). Code invoking nlist() works fine for all other archs (armv7, armv7s, arm64 and i386) but will not build successfully for x86_64, where the linker fails to find the symbol in the linked libraries.
It can be reproduced on a template project created with Xcode, by simply adding:
#import <mach-o/nlist.h>
int testnlist()
{
struct nlist nl[2];
bzero(&nl, sizeof(struct nlist) * 2);
return nlist("test", nl);
}
Results in:
Undefined symbols for architecture x86_64:
"_nlist", referenced from:
_testnlist in ViewController.o
ld: symbol(s) not found for architecture x86_64
Tested on Xcode 6.1.1 with iOS SDK: 8.1, building for iPhone 6 simulator.
Looks to me like Apple might have forgotten to include some of the simulator's shared libraries built for x86_64, but I might also be overlooking something stupidly obvious...
you might want to try:
#ifndef N_NLIST_DECLARED
struct nlist
{
union
{
char *n_name;
struct nlist *n_next;
long n_strx;
} n_un;
unsigned char n_type;
char n_other;
short n_desc;
unsigned long n_value;
};
#endif
which I extracted from:
<https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/+/android-4.1.2_r2/lib/gcc/x86_64-linux/4.6.x-google/include-fixed/linux/a.out.h>
in that same header file, you will find lots of other things that
will be 'gotcha's when moving to 64bit code
I try to run GHUnit on the device and receive the following compile error.
ld: warning: directory not found for option '-L/Users/gtaskos/Documents/Projects/My/SDKs/My iOS SDK/My-iOS/Pods/build/Debug-iphoneos'
ld: warning: ignoring file /Users/gtaskos/Documents/Projects/My/SDKs/My iOS SDK/My-iOS/Frameworks/GHUnitIOS.framework/GHUnitIOS, missing required architecture arm64 in file /Users/gtaskos/Documents/Projects/My/SDKs/My iOS SDK/My-iOS/Frameworks/GHUnitIOS.framework/GHUnitIOS (4 slices)
Undefined symbols for architecture arm64:
"_OBJC_METACLASS_$_GHAsyncTestCase", referenced from:
_OBJC_METACLASS_$_MyMintTests in MyMintTests.o
"_OBJC_CLASS_$_GHAsyncTestCase", referenced from:
_OBJC_CLASS_$_MyMintTests in MyMintTests.o
"_OBJC_CLASS_$_GHTesting", referenced from:
objc-class-ref in MyMintTests.o
"_GHComposeString", referenced from:
___38-[MyMintTests testGetDetailsAsync]_block_invoke in MyMintTests.o
___38-[MyMintTests testGetDetailsAsync]_block_invoke38 in MyMintTests.o
-[MyMintTests testStrings] in MyMintTests.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Strange is I tried the https://github.com/gh-unit/gh-unit/tree/master/Examples/MyTestable-iOS and it works pretty fine.
Some configuration/setup. I have a workspace with a static library project that uses pods for a dependency, in that project I have a OCUnit tests target, a framework aggregate and added an Empty Application target that configured to use GHUnit, added the framework and used the GHUnitIOSAppDelegate in the main.cs.
Then I added an Objective-C class with a custom name MyMintGHUnitTests.m which has some methods (although only testStrings is available when I run the target, that is another question for StackOverflow).
- (void) testGetDetailsAsync
{
// Call prepare to setup the asynchronous action.
// This helps in cases where the action is synchronous and the
// action occurs before the wait is actually called.
[self prepare];
[self.utility getDetailsNumWithBlock:^(NSNumber *total)
{
GHTestLog(#"Details Number: %#", total);
GHAssertNotNil(totalCrashes, nil);
[self notify:kGHUnitWaitStatusSuccess forSelector:#selector(getDetailsAsyncTest)];
}
failure:^(NSError *error)
{
GHTestLog(#"Failed to get details: %#", error.description);
GHAssertNil(error, nil);
[self notify:kGHUnitWaitStatusSuccess forSelector:#selector(getDetailsAsyncTest)];
}];
// Wait until notify called for timeout (seconds); If notify is not called with kGHUnitWaitStatusSuccess then
// we will throw an error.
[self waitForStatus:kGHUnitWaitStatusSuccess timeout:5.0];
}
Class inherits from GHAsyncTestCase.
Maybe I should say that I also use pods for the GHUnit target.
The target runs on Simulator (without my methods) perfect fails on device.
I'm getting the following error when trying to use C's math.h library:
#import <Foundation/Foundation.h>
#import <math.h>
#interface Filter : NSObject {
float cutoff;
float resonance;
float sampleRate;
float *f;
float freq;
float damp;
}
- (float)filter:(float)input;
#end
Can you tell me how I can solve this error? It seems that the min() function cannot be compiled to armv7 architectures.
Undefined symbols for architecture armv7:
"_min", referenced from:
-[Filter init] in Filter.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You are linking against a static library that is compiled for i386 or x86-64, in your specific case I think that you have referenced a library that contains min function but is not compiled for armv7 architecture, take a look at your referenced static library .
On iOS I had to use fmin() instead of min() as alex purposed. Further, i didn't even need to import math.h as Anoop said.