Duplicate Symbol Error in Objective-C build?
It seems that you are compiling the same BlogTableItemCell class two times in different places of your code. This may happen in the following cases.
You have put the same class
implementation into two different
files;You actually have just one
implementation of this class, however
you are also linking in your project a framework
or library containing a class whose
name is exactly the same of yours.
Try finding in the whole project your class and make sure only one copy is available within your project.
xCode: Objective C: duplicate symbol error
Now I want to read the data from the array in multiple files so I simply use
#import "CarArray"
This is an incorrect way of accessing array data from multiple places, because it creates multiple definitions in situations when you use the file more than once.
One way of sharing an array would be providing a header with a declaration, and a .m file with an implementation:
CarArray.h:
extern NSString *cars[5][3];
CarArray.m:
#import "CarArray.h"
NSString *cars[5][3] = {
{@"1A", @"1B", @"1C"},
{@"2A", @"2B", @"2C"},
{@"3A", @"3B", @"3C"},
{@"4A", @"4B", @"4C"},
{@"5A", @"5B", @"5C"}
}
Use #import "CarArray.h"
in files from which you wish to use cars
.
Another alternative would be making a class to wrap your global variable, and providing a class method for accessing the array.
Apple Mach-O Linker Error: 1 duplicate symbol for architechture
You are declaring your three int values in the header file as globals. Everywhere you include this header in your code, you'll be defining/redefining them.
You could declare them as extern in your header file:
/* in ViewController.h */
extern int coinsTotal;
extern int pointsLeft;
extern int dailyTwenty;
And then declare them once at the top of your AppDelegate.m outside of the @implementation code.
/* in AppDelegate.m */
int coinsTotal = 0;
int pointsLeft = 0;
int dailyTwenty = 0;
...
@implementation AppDelegate
...
@end
But I would prefer to create them as members of a singleton class and then include the interface header file where ever you need to set or read the values.
Xcode Objective-C: 2 duplicate symbols error
You seem to be importing "Weights.m". This is almost certainly a mistake. You usually only want to import header files (files that end in ".h")
ios objective-c duplicate symbols for architecture arm64
You actually spotted the cause of your problem:
There is no .m file for PersistentContainer - everything is in the header file.
You need to put the @implementation
part in an .m
file, otherwise all other source files that import PersistentContainer.h
will re-implement the class, leading to the duplicate symbol definition. This because each import is equivalent to writing the same contents in the files that do the imports.
Unlike C++, where you are allowed to define parts of the class implementation in the header files, in Objective-C you must write all the implementation in implementation files.
Duplicate symbols for architecture x86_64 under Xcode
75 duplicate symbols for architecture x86_64
Means that you have loaded same functions twice.
As the issue disappear after removing -ObjC
from Other Linker Flags,
this means that this option result that functions loads twice:
from Technical Q&A
This flag causes the linker to load every object file in the library
that defines an Objective-C class or category. While this option will
typically result in a larger executable (due to additional object code
loaded into the application), it will allow the successful creation of
effective Objective-C static libraries that contain categories on
existing classes.
https://developer.apple.com/library/content/qa/qa1490/_index.html
Related Topics
Finish All Asynchronous Requests Before Loading Data
Shift Elements in Array by Index
What's the Best Way to Handle Multiple Skscenes
Swift Editor Placeholder in Source File
Insert CSS into Loaded HTML in Uiwebview/Wkwebview
Xcodebuild Different Provisioning Profile for Target Dependency
Changing Navigation Bar Color in Swift
How to Dismiss Viewcontroller in Swift
Ios: What's the Fastest, Most Performant Way to Make a Screenshot Programmatically
Drop-Down List in Uitableview in iOS
Sorting Nsarray of Dictionaries by Value of a Key in the Dictionaries
How to Calculate Uilabel Width Based on Text Length
How to Implement a Pop-Up Dialog Box in iOS
Working With Unicode Code Points in Swift
Uitableview: How to Disable Selection for Some Rows But Not Others