Note that there are some explanatory texts on larger screens.

plurals
  1. POIPhone: Adding Category to CoreLocation threw link error. Why?
    primarykey
    data
    text
    <p>I added a category to CLLocation in CoreLocation but kept getting a link error.<br> I search around and through process of TRY IT AND BE DAMNED I fixed the problem by adding -framework CoreLocation to Other Linker Flags<br> But dont know why?<br> I'm guessing its something to do with CoreLocation being and external framework. </p> <p>The Code: <strong>CLLocation+DistanceComparison.h</strong></p> <pre><code>#import &lt; Foundation/Foundation.h &gt; #import &lt; CoreLocation/CoreLocation.h &gt; static CLLocation * referenceLocation; @interface CLLocation (DistanceComparison) - (NSComparisonResult) compareToLocation:(CLLocation *)other; @end </code></pre> <p><strong>CLLocation+DistanceComparison.m</strong></p> <pre><code>#import "CLLocation+DistanceComparison.h" #import &lt;CoreLocation/CoreLocation.h&gt; @implementation CLLocation (DistanceComparison) - (NSComparisonResult) compareToLocation:(CLLocation *)other { CLLocationDistance thisDistance = [self getDistanceFrom:referenceLocation]; CLLocationDistance thatDistance = [other getDistanceFrom:referenceLocation]; if (thisDistance &lt; thatDistance) { return NSOrderedAscending; } if (thisDistance &gt; thatDistance) { return NSOrderedDescending; } return NSOrderedSame; } @end </code></pre> <p><strong>Build Error:</strong></p> <pre> Ld build/Debug-iphonesimulator/SortedLocations.app/SortedLocations normal i386 cd /Users/clearbrian/Documents/Development/IPhoneDevelopment/034.SortedLocations/SortedLocations setenv MACOSX_DEPLOYMENT_TARGET 10.5 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk -L/Users/clearbrian/Documents/Development/IPhoneDevelopment/034.SortedLocations/SortedLocations/build/Debug-iphonesimulator -F/Users/clearbrian/Documents/Development/IPhoneDevelopment/034.SortedLocations/SortedLocations/build/Debug-iphonesimulator -filelist /Users/clearbrian/Documents/Development/IPhoneDevelopment/034.SortedLocations/SortedLocations/build/SortedLocations.build/Debug-iphonesimulator/SortedLocations.build/Objects-normal/i386/SortedLocations.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/clearbrian/Documents/Development/IPhoneDevelopment/034.SortedLocations/SortedLocations/build/Debug-iphonesimulator/SortedLocations.app/SortedLocations Undefined symbols: ".objc_class_name_CLLocation", referenced from: literal-pointer@__OBJC@__cls_refs@CLLocation in RootViewController.o ld: symbol(s) not found collect2: ld returned 1 exit status </pre> <p>Getting link error when we added category<br> maybe because its external framework </p> <p>got help from<br> hg clone <a href="https://traillocation.googlecode.com/hg/" rel="nofollow noreferrer">https://traillocation.googlecode.com/hg/</a> traillocation<br> They added Foundation in Other Linker Flags for one of their targets<br> so I tried adding CoreLocation see attempt 2 </p> <p>ATTEMPT 1 : didnt work - see attempt 2 </p> <p>NOTE: to use this category on the 3.0 device, the -all_load linker flag<br> must be set in users of this library due to a toolkit bug.<br> See <a href="https://stackoverflow.com/questions/1147676/">Categories in static library for iPhone device 3.0</a> </p> <p>Right Click on project name in Groups and Files pane<br> Get Info<br> Build tab<br> type Other Linker Flags in search<br> when found<br> Double click in right column<br> add -all_load </p> <p>ATTEMPT 2 -<br> Right Click on project name in Groups and Files pane<br> Get Info<br> Build tab<br> type Other Linker Flags in search<br> when found<br> Double click in right column<br> add -framework CoreLocation<br> close<br> if you reopen the params are on two lines, this is ok<br> -framework<br> CoreLocation<br> Clean all targets<br> Build<br> seemed to work </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload