Why does Xcode compile all my code twice, resulting in linker errors for any global variables?

When I look at the Build Results window, there are duplicate entries for each .m, Precompile.pch, and Link compilation.

Whenever I try to add a global, even as a static constant, I get a linker error.

At the build stage, I see that one launch is for armv6 and the other is for armv7 (when compiling for an iOS device).

However, compilation for the iOS simulator does not duplicate or linker errors.

Is this a problem (besides the obvious problem with linker errors)? If so, will this cause performance issues? How can i fix this?

+3
source share
3 answers

I am sure double messages are caused by the compilation of the Universal App.

+2
source

Short answer: do not use global variables .: D Look externwith objective-c , this can help you create a global one. If you create for arm6 and arm7, you will have duplicate assembly records, since they are different assemblies.

, static const , , . .m extern . , . ( : D)

0

.

- , int add(int a, int b); extern int c;.

- , int add(int a, int b) { return a+b; } int c;.

int c; , , #, "c". : ( 3 4...) , c, . ? ( () .)

extern int c; int c; .

("duplicate" compilations for armv6 and armv7 are absolutely normal. The two architectures are compiled and linked separately and then compiled into a "bold" executable file. Loosely, armv6 works on "old" devices (up to 3GS) and armv7 works on "new" devices (3GS +). New devices can also run armv6, but armv7 is much faster.)

0
source

Source: https://habr.com/ru/post/1776537/


All Articles