alexrothenberg / motion-addressbook

MIT License
89 stars 30 forks source link

iOS 5 issue: dyld: Symbol not found: _ABAddressBookCreateWithOptions #5

Closed jamonholmgren closed 11 years ago

jamonholmgren commented 11 years ago

When running on an iOS 5.1.1 device, I'm getting this bug:

dyld: Symbol not found: _ABAddressBookCreateWithOptions

I'll attempt to find a solution and do a pull request.

jamonholmgren commented 11 years ago

Submitted a ticket to RubyMotion. It appears to be a compiler bug.

alexrothenberg commented 11 years ago

Hmm I wonder if the if in the code approach is flawed because both branches get compiled into the executable - even when only one api method exists in the ios version. Maybe we need to take another approach where we use a compile-time if to selectively create and compile only the appropriate code.

Let me know what Laurent says to your support ticket.

jamonholmgren commented 11 years ago

No response yet. I'm not sure that a compile-time if will work, since I'm trying to target both iOS 5 and 6 with the same binary. Wouldn't it need to have the code for both at runtime to work?

alexrothenberg commented 11 years ago

A compile-time if would be something analogous to an objective-c #define.

When you compile your app targetting ios5 the gem will be compiled with the ios5 ABAddressBookCreate.
When I compile my app targetting ios6 the gem will be compiled with the ios6 ABAddressBookCreateWithOptions.

I think this decision needs to take place at compile-time so that the app links and loads correctly with the sdk and version of ios on the device.

I haven't seen anything like this in RubyMotion so far though.

jamonholmgren commented 11 years ago

If I target iOS 5, it should include both, though, since iOS 6 can't load iOS 5's ABAddressBookCreate.

Apple really screwed us up on this.

jamonholmgren commented 11 years ago

Okay, I feel a little foolish, although I haven't confirmed this. It appears that removing the iOS 6 specific code and running iOS 6 devices with the ABAddressBookCreate() method instead DOES work fine.

I'll confirm this tomorrow. If so, I'll submit my pull request. You can go look at my repo if you want to see what I did. We would basically be going back to what you already had before. Like I said, I feel kind of foolish. Although this code will be necessary at some point in the future.

jamonholmgren commented 11 years ago

Laurent recommended building a static Objective-C initializer for this until they find a fix for this. That's the route I'm going to take and see how it goes.

alexrothenberg commented 11 years ago

looking forward to seeing what you come up with.

jamonholmgren commented 11 years ago

Just got an email from Laurent:

I just changed the compiler to compile references to C functions as weak linkage. This fixes the problem, on iOS 5.1 or above the program will run but the ABAddressBookCreateWithOptions() function will not be available (and you can use respond_to? to check if it's there).

The change will ship in the upcoming software update planned for this week, we will let you know via this ticket once it's available.

So, once they ship the new version of RubyMotion we should be able to update motion-addressbook to use respond_to?(:ABAddressBookCreateWithOptions) and it should work.

alexrothenberg commented 11 years ago

sweet that will be nice

jjaffeux commented 11 years ago

@ jamonholmgren does the last update allows adress book to be fixed ?

jamonholmgren commented 11 years ago

@jjaffeux I haven't tested it yet. We submitted to Apple so I'm trying not to break anything until we hear back from them. :)

alexrothenberg commented 11 years ago

I believe it does work. I've tested on an IOS 5.1 device. Let me know if you encounter problems.

The latest v0.1.2 should work for both IOS 5 and 6 (I think :)