iOS. Cannot run a project after updating cocos2d library inside this project - ios

It cannot compile sources and writes:
Undefined symbols for architecture i386:
"_CTFontManagerRegisterFontsForURL", referenced from:
-[CCLabelTTF getFontName:] in CCLabelTTF.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with
exit code 1 (use -v to see invocation)
but when I replace all the code in the following function in CCLabelTTF with "return nil":
- (NSString*) getFontName:(NSString*)fontName
{
// Custom .ttf file ?
if ([[fontName lowercaseString] hasSuffix:#".ttf"])
{
// This is a file, register font with font manager
NSString* fontFile = [[CCFileUtils sharedFileUtils] fullPathForFilename:fontName];
NSURL* fontURL = [NSURL fileURLWithPath:fontFile];
CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeProcess, NULL);
return [[fontFile lastPathComponent] stringByDeletingPathExtension];
}
return fontName;
}
then I can compile my code but I cannot use labels.
So how to solve this without creating of a new project and copying all the sources to it?
EDITED
Previous version is 2.x, now I have the last rc2 version.
I have deleted all the files of the old library, copied the files from the new library into the project folder and added them to project via xcode. xcode can create projects with a new library files, so I took them from this new project. Then I made some changes to remove warnings.

Solved by importing CoreText.framework
But I think I will create a new project because I still have some troubles with identifying of iphone5 screen size

Related

Clang Error "duplicate symbols for architecture x86_64"

This error is listed a lot over stack and the common fixes don't seem to work for me. I am getting the error: "duplicate symbols for architecture x86_64" when compiling an Obj-C MacOS Xcode App. Xcode 11.5 and MacOS Catalina 10.15.5. It is saying there are 15 duplicate symbols, with one of the 15 errors looking like:
duplicate symbol '_visual10Window' in:
/Users/tempuser/Library/Developer/Xcode/DerivedData/test-cdicjztmkktfomehwaphnzhbozgh/Build/Intermediates.noindex/test.build/Debug/test.build/Objects-normal/x86_64/Test.o
/Users/tempuser/Library/Developer/Xcode/DerivedData/test-cdicjztmkktfomehwaphnzhbozgh/Build/Intermediates.noindex/test.build/Debug/test.build/Objects-normal/x86_64/MainView.o
My MainView.h and MainView.mm do not contain any definition for visual10Window.
My Test.h has (removing this give a use of undeclared identifier error).
#class Visual10;
Visual10 *visual10Window;
and Test.mm includes
#import "Visual10.h"
and I'm calling a xib from a menu item in Test.mm
- (void)Visual10Menu:(id)sender {
if (!visual10Window) {
visual10Window = [[Visual10 alloc] initWithWindowNibName:#"Visual10"]; }
[visual10Window showWindow:self]; }
I have tried the common suggestions including:
Install and reinstall pods (this project doesn't use pods)
Checked for wrong imports like import ".m" instead of ".h"
Remove -all_load from Other Linker Flags
Build Settings / No Common Blocks set to NO
Checked for duplicate files Build Phases / Compile Sources (None)
Tried adding and removing -ObjC from Other linker flag
Tried Build Settings / Enable Testability set to NO
Tried clearing derived data
None of these work and still get duplicate symbol errors.

Admob Conversion Tracking in Swift

I tried to set conversion tracking in my iOS game, but I didn't be able to do that. The tutorial can be found here: https://developers.google.com/app-conversion-tracking/ios/?hl=it#usage_and_disclosure
I integrate the GoogleConversionTrackingSDK to my project, load AdSupport framework and type -ObjC in Other linker flags.
I tried to convert this snippet from Obj-C:
[ACTConversionReporter reportWithConversionID:#"MY_ID" label:#"MY_LABEL" value:#"MY_VALUE" isRepeatable:NO];
to Swift:
ACTConversionReporter.reportWithConversionID("MY_ID", label: "MY_LABEL", value: "MY_VALUE", isRepeatable: false)
and I put that in didFinishLaunchingWithOptions method of AppDelegate.swift, but I get the error:
Use of unresolved identifier 'ACTConversionReporter'
If I type in Obj-C bridging header in Swift Compiler - Code Generation in Build Settings "ACTReporter.h" (without qm), I put the header file in the folder of my game or if I type the whole path of "ACTReporter.h" ending with its name, I fail the build and I get 2 errors:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ACTConversionReporter", referenced from:
type metadata accessor for __ObjC.ACTConversionReporter in AppDelegate.o
ld: symbol(s) not found for architecture armv7 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
I don't know what to do. I hope there is someone who can fix this.
You need to add to your project "YourProjectName-Bridging-Header.h" file
Here you can see how to add the file
in Bridging Header file add #import "ACTReporter.h"
Then it will work for you!

Linking to J2ObjC from another CocoaPod

We use J2ObjC and are trying to make the switch to Xcode 6's dynamic frameworks in order to incorporate Swift into the project. Simply adding use_frameworks! to our Podfile works great in the case where we're just using J2ObjC, but the problem comes when adding other libraries that reference it.
In this particular example, I have two pods in my Podfile, J2ObjC and any other pod that uses it. Let's call it whatever. The current J2ObjC podspec can be found here. Here's the podspec for whatever:
Pod::Spec.new do |s|
s.ios.deployment_target = '8.0'
s.requires_arc = true
s.source_files = '**/*.{h,m}'
s.dependency 'J2ObjC'
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/J2ObjC/dist/include',
'LIBRARY_SEARCH_PATHS' => '${PODS_ROOT}/J2ObjC/dist/lib' }
end
So far so good. Now, if I want to reference a Java class, say JavaUtilArrayList inside my app, I can do that.
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
JavaUtilArrayList *arrayList = [[JavaUtilArrayList alloc]init];
NSString *whatever = #"o hai";
[arrayList addWithId:[whatever copy]];
NSLog(#"%#", arrayList);
}
Awesome, J2ObjC works inside my main target. But if I try to do the same thing inside whatever, even though the compiler thinks everything is fine (J2ObjC imports work, classes are available, etc.), I get a linker error:
#import "SomeClass.h"
#import "java/util/ArrayList.h"
#implementation SomeClass // Inside 'whatever'
-(JavaUtilArrayList *)arrayList {
NSString *aThing = #"o hai";
JavaUtilArrayList *myList = [[JavaUtilArrayList alloc]init];
[myList addWithId:aThing];
NSLog(#"%#", myList);
return myList;
}
leads to:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_JavaUtilArrayList", referenced from:
objc-class-ref in SomeClass.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've been going crazy reading the CocoaPods guides, man ld, and the J2ObjC guides and am still not getting anywhere. Has anyone built a pod on top of J2ObjC and successfully installed it using use_frameworks!? Any advice would be super appreciated.
Any symbol begging with "_OBJC_CLASS" is from J2ObjC. If it begins "_OBJC_CLASS_$_Java" then it's from the Java Runtime Environment (JRE). If it doesn't have "$_Java" then see this answer.
The linker is missing out the libjre_emul.a library from J2ObjC (JRE emulation library). You need to configure the following:
LIBRARY_SEARCH_PATHS: J2OBJC_HOME/lib
OTHER_LDFLAGS: -l"jre_emul"
I'd suggest trying out the J2ObjC Gradle Plugin as it will automatically configure this for you. Alternatively, see the Xcode Build Rules.

UIColor Category Linker Errors

Earlier today I tried to add Unit tests to my xcode project for a static framework that I am creating. After adding the Unit Tests target to my project, I was able to successfully run the unit tests template and have the tests catch the default assertion. Then, after importing the file that I wanted to test into my new SenTestCase subclass, I tried to run the test but my UIColor category failed building with the test due to linker errors. The text of the linker errors is as follows:
Undefined symbols for 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 for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Next, I found where these two references were in my project. Both live in my category under the 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 I remember correctly, both of these are part of the NSColor class. With a little more inspection, I also noticed that in my Unit Test's framework's folder, both UIKit.framework & Foundation.framework are red. I have tried reimporting them and building but this does not fix that issue either.
Interestingly enough, my static framework will still build and run fine as long as the associated Test is not also run. And when I comment this function out (and every time I use it), the Unit Test builds without issues. Would I be correct in my assumption that the missing UIKit.framework & Foundation.framework could be causing the linker not finding the NSColor properties? Does anyone have any additional suggestions that could explain why these properties are causing these issues or what I could do to fix them?
Any help would be greatly appreciated. Thanks for the assistance.
The linker error indicates that you are using CoreGraphics functions but you are not linking the CoreGraphics framework.
Update your project/target so you link the CoreGraphics.framework and the linker issues will be resolved.

"symbol(s) not found for architecture i386" problem using ShareKit

I want to use the http://getsharekit.com framework for future iOS projects. Hence I started testing out the framework.
But I already get the following error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_SHKItem", referenced from:
objc-class-ref in ShareKitTestAppDelegate.o
"_OBJC_CLASS_$_SHKActionSheet", referenced from:
objc-class-ref in ShareKitTestAppDelegate.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
Often, as far as I know, these problems arise if header files are wrongly imported. But I don't see any error here in the following code where the problem above occurs:
#import "ShareKitTestAppDelegate.h"
#import "SHK.h"
#import "SHKItem.h"
#import "SHKActionSheet.h"
- (IBAction) letshare:(id)sender
{
// Create the item to share (in this example, a url)
NSURL *url = [NSURL URLWithString:#"http://getsharekit.com"];
SHKItem *item = [SHKItem URL:url title:#"ShareKit is Awesome!"];
// Get the ShareKit action sheet
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
// Display the action sheet
[self.window addSubview:actionSheet];
}
I also included the ShareKit Headers Folder into HeaderSearchPath Build-Options, because of searching for all the headers.
But I don't see any error here or anything missed.
Can somebody help me?
With best regards,
Andreas
I had a similar problem with the following linker error:
Undefined symbols for architecture i386: "_OBJC_CLASS_$_SHK"
I resolved it by adding SHK.m to compiled sources under Project settings->Target->Build Phases. Not sure why SHK.m was not in the compiled sources list, and it was working previous to duplicating the Target. After the duplication I couldn't link any of the targets.
Adding SHKItem.m or SHK.m to compiled sources might help you if they aren't there already.
Read this http://getsharekit.com/install/.
Have you added the frameworks?

Resources