In the iOSUndefined symbols for architecture x86_64
In native iOS development, this error message should be more or less encountered:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_XXX", referenced from:
__XXX in TestClass.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Copy the code
This error message means that there are some unrecognized symbols in TestClass. It means that some methods or classes used in TestClass cannot be recognized.
General solution: Add the corresponding static library, or framework. Today, I’m not trying to solve the problem of iOS native development, but the problem of native components in ReactNative. If you want to solve the problem of native components, please go to here.
The author has done RN component development for the SDK pushed by UmENG, and embedded the native SDK in the component, so that when used in RN, there is no need to care about UMeng’S SDK, and it truly achieves ReactNative plug-in development.
After a few lines of command, the whole environment is set up, the compilation is OK before the SDK is imported, and the compilation is OK after the SDK is imported. The actual performance is similar to what I expected, and the component should be ready soon.
Ideas are good, reality is cruel.
After I write a good call to the SDK method, began to compile, WTF what ghost, this error what situation, scared me quickly to check the code, the annotation of the annotation, the restoration of the restoration. Compile -> No problem!
Finally, a solution was found by comparing other projects. This compilation problem was caused by the use of the Umeng (third-party) framework in my component, so the final solution is: Xcode -> Build Settings -> Other Linker Flags to add -framework “XXX”, such as your testDemo. framework, So this is — framework “TestDemo”
PS: Reference third-party components in package.json in an RN project using “xxx-Component “: “.. / XXX /”, all files in the package.json directory are copied to the RN project node_moudle/xxx-component directory, and RN displays some duplicate XXX error messages. Unneeded files need to be removed in the node_moudle/xxx-component directory.
If you happen to encounter this question and come across this article, congratulations, you’ve come to the right place! If you don’t have these annoying problems, you’re lucky!
The above hope to help you have fun 🤘