Conditional link static library in XCode with environment variable

后端 未结 1 1886
逝去的感伤
逝去的感伤 2021-01-19 07:26

I want to link a static library (.a file) into my code with some restrictions

  • The condition should be an environment variable instead of build typ
1条回答
  •  既然无缘
    2021-01-19 07:55

    In the end I ended up solving this problem by adding more parameters to the xcodebuild command line.

    Basically what you need to do is to adjust:

    • Where the header .h files are located
    • Where the library .a is located
    • Tell the linker that you want to use the library -lCrittercism_v4_0_7
    /usr/bin/xcodebuild -configuration Release clean
    "LIBRARY_SEARCH_PATHS=\${LIBRARY_SEARCH_PATHS} \${PROJECT_DIR}/Libraries/CrittercismSDK"
    "HEADER_SEARCH_PATHS=\${HEADER_SEARCH_PATHS} \${PROJECT_DIR}/Libraries/CrittercismSDK" 
    "OTHER_LDFLAGS=-lCrittercism_v4_0_7"
    

    With this approach you don't need to add the library to the target or to Xcode at all. If the last three parameters aren't added to the command line, the library won't belong to the final executable at all.

    0 讨论(0)
提交回复
热议问题