ios - UIColor Category Linker Errors -
earlier today tried add unit tests xcode project static framework creating. after adding unit tests target project, able run unit tests template , have tests catch default assertion. then, after importing file wanted test new sentestcase subclass, tried run test uicolor category failed building test due linker errors. text of linker errors follows:
undefined symbols architecture i386: "_cgcolorgetcomponents", referenced from: -[uicolor(colorextension) hexvalue] in staticframework(staticframework) "_cgcolorgetnumberofcomponents", referenced from: -[uicolor(colorextension) hexvalue] in staticframework(staticframework) ld: symbol(s) not found architecture i386 clang: error: linker command failed exit code 1 (use -v see invocation)
next, found these 2 references in project. both live in category under following function:
- (nsstring *)hexvalue { uicolor *color = self; const size_t totalcomponents = cgcolorgetnumberofcomponents(color.cgcolor); const cgfloat * components = cgcolorgetcomponents(color.cgcolor); return [nsstring stringwithformat:@"#%02x%02x%02x", (int)(255 * components[min(0,totalcomponents-2)]), (int)(255 * components[min(1,totalcomponents-2)]), (int)(255 * components[min(2,totalcomponents-2)])]; }
if remember correctly, both of these part of nscolor class. little more inspection, noticed in unit test's framework's folder, both uikit.framework & foundation.framework red. have tried reimporting them , building not fix issue either.
interestingly enough, static framework still build , run fine long associated test not run. , when comment function out (and every time use it), unit test builds without issues. correct in assumption missing uikit.framework & foundation.framework causing linker not finding nscolor properties? have additional suggestions explain why these properties causing these issues or fix them?
any appreciated. assistance.
the linker error indicates using coregraphics functions not linking coregraphics framework.
update project/target link coregraphics.framework , linker issues resolved.
Comments
Post a Comment