如何在非ARC兼容项目中使用ARC兼容文件

时间:2023-01-17 12:52:19

My project has dependent libraries that don't compile under the LLVM compiler, so my project is not compatible with ARC.

我的项目有独立的库,它们不会在LLVM编译器下编译,所以我的项目与ARC不兼容。

How can I include other third party libraries and source files that are ARC compatible in to my non-ARC project.

如何包含与我的非ARC项目兼容的其他第三方库和源文件。

Thanks in advance.

提前谢谢。

2 个解决方案

#1


2  

If you're not using LLVM your main project won't be able to use ARC at as it's a LLVM 3.0 feature.

如果您不使用LLVM,您的主项目将无法使用ARC at,因为它是一个LLVM 3.0特性。

If I was you I'd make your main project/target/app compile under LLVM and include your older external dependencies as static library dependencies. Once the static libraries are compiled the fact that they're ARC or non-ARC doesn't make a difference.

如果我是你,我会让你的主项目/目标/应用程序在LLVM下编译,并将你以前的外部依赖项包含为静态库依赖项。一旦编译了静态库,那么它们是ARC还是non-ARC都没有什么区别。

You'll need to move to Xcode workspaces that contain multiple Xcode projects, one for each of your third party libraries and have static library targets for each project. This setup allows independent build settings and greater flexibility. You'll find a lot of people create static libraries for third party things these days.

您需要移动到包含多个Xcode项目的Xcode工作区,每个第三方库一个,每个项目都有静态库目标。这个设置允许独立的构建设置和更大的灵活性。你会发现现在有很多人为第三方创建静态库。

Checkout a blog post or two on setting up static libraries within an Xcode workspace, it's quite common these days.

查看一两个关于在Xcode工作区中设置静态库的博客文章,这在现在很常见。

#2


8  

You could add a complier flag to each compile source in the Build Phases. The flag you should add is -fobjc-arc

在构建阶段,您可以向每个编译源添加一个编译器标志。您应该添加的标志是-fobjc-arc

#1


2  

If you're not using LLVM your main project won't be able to use ARC at as it's a LLVM 3.0 feature.

如果您不使用LLVM,您的主项目将无法使用ARC at,因为它是一个LLVM 3.0特性。

If I was you I'd make your main project/target/app compile under LLVM and include your older external dependencies as static library dependencies. Once the static libraries are compiled the fact that they're ARC or non-ARC doesn't make a difference.

如果我是你,我会让你的主项目/目标/应用程序在LLVM下编译,并将你以前的外部依赖项包含为静态库依赖项。一旦编译了静态库,那么它们是ARC还是non-ARC都没有什么区别。

You'll need to move to Xcode workspaces that contain multiple Xcode projects, one for each of your third party libraries and have static library targets for each project. This setup allows independent build settings and greater flexibility. You'll find a lot of people create static libraries for third party things these days.

您需要移动到包含多个Xcode项目的Xcode工作区,每个第三方库一个,每个项目都有静态库目标。这个设置允许独立的构建设置和更大的灵活性。你会发现现在有很多人为第三方创建静态库。

Checkout a blog post or two on setting up static libraries within an Xcode workspace, it's quite common these days.

查看一两个关于在Xcode工作区中设置静态库的博客文章,这在现在很常见。

#2


8  

You could add a complier flag to each compile source in the Build Phases. The flag you should add is -fobjc-arc

在构建阶段,您可以向每个编译源添加一个编译器标志。您应该添加的标志是-fobjc-arc