Duplicate Symbols for Architecture arm64

前端 未结 24 2695
礼貌的吻别
礼貌的吻别 2020-12-02 16:21

When I try running my Xcode Project it fails with an error stating that I have duplicate symbols. I looked online where the find these duplicates but have had no luck:

24条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 16:59

    If you are moving to Xcode 7 or 8 and are opening a really old project, I've encountered this problem:

    in SomeConstFile.h

    NSString * const kAConstant;
    

    in SomeConstFile.m

    NSString *const kAConstant = @"a constant";
    

    Earlier versions of the compiler assumed that the definition in the header file was extern and so including SomeConstFile.h all over the place was fine.

    Now you need to explicitly declare these consts as extern:

    in SomeConstFile.h

    extern NSString * const kAConstant;
    

提交回复
热议问题