我可以构建一个ARC框架并在非ARC项目中使用它吗?

时间:2023-01-17 12:57:00

I think the title explains my question pretty well, I'm currently working on a small framework for my personal needs, and thought about building it with ARC (if thats possible at all?), and use it in old projects that were built before ARC?

我认为这个标题很好地解释了我的问题,我目前正在研究一个小框架以满足我的个人需求,并考虑用ARC构建它(如果可能的话?),并在以前构建的旧项目中使用它弧?

3 个解决方案

#1


7  

Yes, with one caveat: if you have iOS 4.x as a deployment target, a supplemental library is necessary to deal with ARC-compiled code on the older runtime. For an application built using ARC, this is packaged in with the application. This is not included if you are using an ARC-compiled library in a non-ARC application.

是的,有一点需要注意:如果您将iOS 4.x作为部署目标,则需要一个补充库来处理旧运行时的ARC编译代码。对于使用ARC构建的应用程序,它与应用程序一起打包。如果您在非ARC应用程序中使用ARC编译的库,则不包括此项。

You can manually link this library into your non-ARC application to avoid runtime problems on the older OS versions by adding -fobjc-arc to your Other Linker Flags for the application.

您可以手动将此库链接到非ARC应用程序,以通过将-fobjc-arc添加到应用程序的其他链接器标志来避免旧版操作系统上的运行时问题。

See this Apple Developer Forums thread for some more discussion on this.

有关此问题的更多讨论,请参阅此Apple Developer Forums主题。

#2


2  

You can link against the glue library provided by Apple (as Brad has said in his answer above). However, the __weak variable qualifier is not compatible with operating systems below 4.3 (As mentioned here: iOS 5 Best Practice (Release/retain?) in a comment by sudo).

您可以链接Apple提供的胶水库(正如Brad在上面的回答中所说)。但是,__ weak变量限定符与4.3以下的操作系统不兼容(如下所述:iOS 5最佳实践(发布/保留?)在sudo的评论中)。

#3


1  

Should be fine. The library is already compiled, so ARC/NonARC shouldn't matter anymore.

应该没事。该库已经编译,因此ARC / NonARC不再重要。

#1


7  

Yes, with one caveat: if you have iOS 4.x as a deployment target, a supplemental library is necessary to deal with ARC-compiled code on the older runtime. For an application built using ARC, this is packaged in with the application. This is not included if you are using an ARC-compiled library in a non-ARC application.

是的,有一点需要注意:如果您将iOS 4.x作为部署目标,则需要一个补充库来处理旧运行时的ARC编译代码。对于使用ARC构建的应用程序,它与应用程序一起打包。如果您在非ARC应用程序中使用ARC编译的库,则不包括此项。

You can manually link this library into your non-ARC application to avoid runtime problems on the older OS versions by adding -fobjc-arc to your Other Linker Flags for the application.

您可以手动将此库链接到非ARC应用程序,以通过将-fobjc-arc添加到应用程序的其他链接器标志来避免旧版操作系统上的运行时问题。

See this Apple Developer Forums thread for some more discussion on this.

有关此问题的更多讨论,请参阅此Apple Developer Forums主题。

#2


2  

You can link against the glue library provided by Apple (as Brad has said in his answer above). However, the __weak variable qualifier is not compatible with operating systems below 4.3 (As mentioned here: iOS 5 Best Practice (Release/retain?) in a comment by sudo).

您可以链接Apple提供的胶水库(正如Brad在上面的回答中所说)。但是,__ weak变量限定符与4.3以下的操作系统不兼容(如下所述:iOS 5最佳实践(发布/保留?)在sudo的评论中)。

#3


1  

Should be fine. The library is already compiled, so ARC/NonARC shouldn't matter anymore.

应该没事。该库已经编译,因此ARC / NonARC不再重要。