Static library with ARC support linked to non-ARC project causing linker errors

前端 未结 2 1613
青春惊慌失措
青春惊慌失措 2020-12-05 05:09

I have a non-ARC project that uses an ARC-enabled static library. This is a supported scenario, so that everything works fine. That is, until I run the code on a 4.x device,

2条回答
  •  清歌不尽
    2020-12-05 05:43

    I assumed that the toolchain may have added the necessary libraries to link to, in order for ARC to work properly. So the linker transcript may contain this piece of information. If the project of the app itself is not ARC-enabled, you may not get these by default, but you could still link to them by defining them explicitly.

    Looking at the build transcript you can indeed find the appropriate linker flag there: it’s called -fobjc-arc (just as the related compiler flag). When you add this setting to Other Linker Flags, the linker will include the ARC library with the main build product and the code should run fine.

提交回复
热议问题