last day (14 days later) » 

2:07 PM
0
A: On device only - Unrecognized selector sent to class

PartiallyFiniteIf your StarIOFunctions class implemented in a static library that you're linking with the iOS app, you need to add the -ObjC linker flag to your project settings. It looks like the method isn't present in the app binary after compiling. This article describes how to add the linker flag.

 
Adding that then stops me from building, with Error: clang: error: linker command failed with exit code 1 (use -v to see invocation)
 
Click on the error in the left pane. It should show you the full error text.
 
I've managed to resolve that issue - it was to do with another library and is now fixed. The app still crashes with the exact same error with -ObjC set.
 
@Joseph try add -all_load as well. Sometimes I find myself having to do that for some reason.
 
Still crashes :(
 
2:07 PM
Make sure you're setting both these flags on the iOS app target, not the library itself.
 
Yes - I've been doing it on the target app.
I've just created a brand new app, to remove the issue being anywhere else.
Dropped the library into the app
Added a button, and then those two lines of code.
 
of all the other stackoverflow questions I've found, doing this has resolved this issue
so I'm not sure why this isn't working
 
Added the flags you mentioned and then it still crashes it
It'll be something basic, I'm sure of it. I'm brand new to Objective-C, so I guess I've missed something obvious.
Could the problem be in the library?
Is there a way to debug the code in the library?
 
you should be able to set breakpoints in the library code
but if it crashes before you can even call a single library function, that doesn't really help
try adding a global C function to the library, and calling that
just as a test
something like static void TestFunction () { NSLog("Hello"); }
 
Ok, good idea. 1 sec.
 
2:13 PM
oops
making it static won't work
you'll need to add an actual declaration in the header file
and put the function body in an implementation file
otherwise this won't actually work as a test
so void TestFunction () { NSLog("Hello"); } in a .m file in the library somewhere
and void TestFunction (); in a header
 
So I have this in my header:
+ (void) TestFunction;
And this in my .m:
+ (void) TestFunction {
NSLog(@"Hello");
}
 
does that work?
if that crashes
try adding void TestFunction (); to your header
outside the @interface
and void TestFunction () { NSLog("Hello"); }
also outside the @implementation
then call it as TestFunction(); from inside the app
 
Right that works.
Also, my function is now working on the device.
So, I am using the library file that I have built just for the device
Whereas before I was using the file where I had LIPO the simulator and device versions of the .a together
 
maybe that made the linker magically lose the symbols
 
So the issue must be in the way I have done that then I guess
 
2:21 PM
if you leave everything within the Xcode build process
without using your own build scripts externally
things seem to work most of the time
You can add the library as a target dependency in the build phases for your app
basically you drag the Xcode project for the library into the left pane of your app project
then choose to not copy any files
after that you can go to build phases and add it as a target dependency
 
But in order to use my library on both the simulator and device - am I correct in thinking I build the library for both and then have to LIPO the two .a files together? Then it's that resulting .a file that I drag in?
 
you can avoid that completely
 
Because now I can currently build for device, but not simulator.
 
that's correct
but Xcode seems to be breaking it
so it might be easier to drag in the Xcode project for your library
and then go to build phases for your app
under target dependencies, click + and add your library
 
Ahhh, I see what I mean.
 
2:23 PM
then further down in link binary with libraries
add your library there too
 
I need a single .a file, so will need to get to the bottom of the issue
 
then it will automatically build for you
 
I use Xamarin, and in order to bind this Objective-C library I need a single .a file.
 
look at the library build settings then
those are the settings for a static library I compile into my projects
if you add the right architectures there
and set build active architectures only to no
Xcode should be able to build a universal library binary for you without you having to manually LIPO the files together
 
Ah, thats interesting to know. Let me give that a quick go.
 
2:31 PM
Hi
did you solved your problem?
 
Hey - kind of. PartiallyFinite is kindly helping me - it's looking like its an issue with the way I am building the library
 
Glad to hear that
 
I'm still getting "Undefined symbols for architecture i386:" when trying to build for the simulator
I have copied your valid architectures
(although the order is slightly different - would that matter?)
 
the order doesn't matter
and that's very strange
 
In the Architectures box I only have armv7 and arm64
let me send a snap
 
2:36 PM
190
Q: Build fat static library (device + simulator) using Xcode and SDK 4+

AdamIt appears that we can - theoretically - build a single static library that includes both simulator and iPhone and iPad. However, Apple has no documentation on this that I can find, and Xcode's default templates are NOT configured to do this. I'm looking for a simple, portable, re-usable techni...

this answer seems to have a working method to do this
 
try adding all the architectures from valid architectures into architectures as well
 
Same issues. Odd.
I'll have a play around
You've found my problem though - thank you so much!
 
2:55 PM
no problem
sorry there's nothing else I can do to fix it
 

last day (14 days later) »