iOS开发之使用CocoaPods更新第三方出现“target overrides the `OTHER_LDFLAGS`……”问题解决方案...

本文记录了在项目中使用CocoaPods引入SDWebImage时遇到的问题及解决过程。出现警告未引起重视,直接使用导致运行时错误。通过删除项目文件中的某些配置解决了该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  今天在自己的项目中用CocoaPods引入第三方SDWebImage的时候,出现了问题。当更新完毕后,在终端没太注意这个问题的提示,就直接使用SDWebImage了,在使用的时候一些方法的提示和头文件都能引入和使用(看上去SDWebImage可以正常使用),可是一运行就报错(错误是下面给出的错误)。貌似是程序写的有问题,然后就检查程序代码,可是检查不出任何错误,折腾了半天,然后就猛然想起pod update时报的错误。下面就写篇博客来纪念一下这个bug~

  1.引入第三方库的时候,在终端上会显示下面的警告,是警告(黄叹号吗),当时我就没太在意!感觉出现警告应该能正常运行的~警告如下(主要是下面的俩个):

 

  2.如果不解决的直接用第三方的话,程序中会出现下面的错误:

 

  3.然后就在程序中调啊~调啊~还是没调好,于是就解决黄叹号,解决步骤如下:

    (1)打开工程所在文件夹,找到.xcodeproj的文件,然后显示包内容,找到project.pbxproj文件,如下:

    (2)用文本编辑器打开,然后查找`OTHER_LDFLAGS`这个东西,把有关这个东西的地方都删掉(应该有四处),如下图:

    (3)删除完以后,在终端重新update一下,如下(就没有下面两个黄叹号了,解决完毕)

    (4)在编译运行我们的工程,编译通过~

[!] Unable to read the license file `LICENSE` for the spec `FirebaseAppCheckInterop (11.15.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAuth (11.8.1)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAuthInterop (11.15.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCore (11.8.1)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCoreExtension (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCoreInternal (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseInstallations (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `Fyber_Marketplace_SDK (8.3.8)` [!] Unable to read the license file `LICENSE` for the spec `GoogleUtilities (8.1.0)` [!] Unable to read the license file `LICENSE` for the spec `RecaptchaInterop (100.0.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAppCheckInterop (11.15.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAuth (11.8.1)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAuthInterop (11.15.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCore (11.8.1)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCoreExtension (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCoreInternal (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseInstallations (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `Fyber_Marketplace_SDK (8.3.8)` [!] Unable to read the license file `LICENSE` for the spec `GoogleUtilities (8.1.0)` [!] Unable to read the license file `LICENSE` for the spec `RecaptchaInterop (100.0.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAppCheckInterop (11.15.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAuth (11.8.1)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAuthInterop (11.15.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCore (11.8.1)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCoreExtension (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCoreInternal (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseInstallations (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `Fyber_Marketplace_SDK (8.3.8)` [!] Unable to read the license file `LICENSE` for the spec `GoogleUtilities (8.1.0)` [!] Unable to read the license file `LICENSE` for the spec `RecaptchaInterop (100.0.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAppCheckInterop (11.15.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAuth (11.8.1)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseAuthInterop (11.15.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCore (11.8.1)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCoreExtension (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseCoreInternal (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `FirebaseInstallations (11.8.0)` [!] Unable to read the license file `LICENSE` for the spec `Fyber_Marketplace_SDK (8.3.8)` [!] Unable to read the license file `LICENSE` for the spec `GoogleUtilities (8.1.0)` [!] Unable to read the license file `LICENSE` for the spec `RecaptchaInterop (100.0.0)` [!] The `Unity-iPhone [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Unity-iPhone/Pods-Unity-iPhone.release.xcconfig'. This can lead to problems with the CocoaPods installation
08-07
<think>我们正在解决的是在CentOS容器中部署DVWA时,需要启用PHP配置中的`allow_url_include`选项的问题。根据引用[1],我们知道在DVWA的部署中,需要修改php.ini文件中的`allow_url_include`为On,并重启Apache服务。 步骤: 1. 找到php.ini文件的位置。 2. 修改php.ini中的`allow_url_include = Off``allow_url_include = On`。 3. 重启Apache服务(在CentOS 7及以上,通常使用systemctl restart httpd)。 但是,在容器环境中,我们需要注意: - 容器可能没有安装文本编辑器(如vim),所以我们可以使用sed命令进行修改,或者将文件挂载出来修改。 - 容器重启后配置会丢失,所以最好在Dockerfile中修改配置,以便持久化。 以下提供两种方法:临时修改(适用于运行中的容器)和通过Dockerfile构建镜像(推荐)。 方法一:临时修改运行中的容器(以交互方式进入容器) 1. 进入容器: ```bash docker exec -it <容器名或ID> /bin/bash ``` 2. 查找php.ini的位置。通常位于/etc/php.ini或/etc/php.d/目录下,或者使用以下命令查找: ```bash php --ini ``` 输出示例: ``` Configuration File (php.ini) Path: /etc Loaded Configuration File: /etc/php.ini ... ``` 3. 使用sed命令修改(假设路径为/etc/php.ini): ```bash sed -i 's/allow_url_include = Off/allow_url_include = On/g' /etc/php.ini ``` 或者,如果配置行是注释状态,可以取消注释并设置为On: ```bash sed -i 's/;allow_url_include = Off/allow_url_include = On/g' /etc/php.ini ``` 如果原配置中没有显式设置为Off,则可能需要手动添加一行: ```bash echo "allow_url_include = On" >> /etc/php.ini ``` 4. 重启Apache服务: ```bash systemctl restart httpd ``` 注意:容器中可能没有systemd,可以使用以下命令重启Apache: ```bash apachectl restart ``` 方法二:通过Dockerfile构建镜像(推荐) 在构建镜像时修改配置,这样每次启动容器都会包含正确的配置。 假设基础镜像是CentOS,并且已经安装了Apache和PHP,以下是Dockerfile示例: ```Dockerfile FROM centos:7 # 安装必要的软件:Apache, PHP, 以及其他依赖 RUN yum install -y httpd php php-mysqli php-gd # 修改php.ini配置 RUN sed -i 's/allow_url_include = Off/allow_url_include = On/g' /etc/php.ini # 或者如果原配置中没有,则添加 # RUN echo "allow_url_include = On" >> /etc/php.ini # 复制DVWA代码到容器中(假设当前目录有DVWA的代码) COPY DVWA /var/www/html/DVWA # 修改DVWA的配置文件(根据引用[2]需要修改数据库连接信息) # 这里以修改config.inc.php为例,将db_server改为localhost RUN sed -i "s/'db_server' => '127.0.0.1'/'db_server' => 'localhost'/" /var/www/html/DVWA/config/config.inc.php # 设置权限(DVWA需要写权限到某些目录) RUN chown -R apache:apache /var/www/html/DVWA # 暴露80端口 EXPOSE 80 # 启动Apache CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"] ``` 构建镜像: ```bash docker build -t dvwa-image . ``` 运行容器: ```bash docker run -d -p 80:80 --name dvwa-container dvwa-image ``` 验证: 访问http://localhost,应该可以看到DVWA的登录页面。 注意:如果遇到数据库连接问题,确保容器内运行了MySQL/MariaDB服务,或者连接外部数据库。这里为了简化,没有包含数据库服务,需要单独运行数据库容器并链接,或者修改DVWA配置连接外部数据库。 另外,根据引用[2],还需要修改DVWA的配置文件config.inc.php,将db_server从127.0.0.1改为localhost(或者实际的数据库地址)。上面的Dockerfile中已经包含这一步。 如果修改后仍然有问题,可以检查以下几点: 1. 确保php.ini修改成功:进入容器查看/etc/php.ini文件。 2. 确保Apache重启成功:查看Apache错误日志(/var/log/httpd/error_log)。 3. 确保数据库服务可用,并且DVWA的配置文件中的数据库用户名和密码正确。 相关问题: 1. 如何在Docker容器中安装并配置MariaDB? 2. 如何将DVWA容器连接到独立的数据库容器? 3. 如何解决DVWA安装页面的“无法连接数据库”错误? 4. 如何修改Apache的配置以允许.htaccess覆盖? 5. 如何为DVWA配置虚拟主机? 6. 如何解决PHP函数allow_url_fopen未启用的问题?</think>### 在 CentOS 容器中为 DVWA 部署启用 `allow_url_include` 的完整指南 #### 🔍 问题分析 DVWA 部署需要启用 PHP 的 `allow_url_include` 选项(引用[1]),该选项默认在 CentOS 的 PHP 配置中为禁用状态。以下是分步解决方案: #### ✅ 解决方案步骤 ##### 1. 进入容器并定位 PHP 配置文件 ```bash docker exec -it your_container_name /bin/bash php -i | grep "Loaded Configuration File" # 查找 php.ini 路径 # 通常路径为:/etc/php.ini 或 /etc/php.d/xxx.ini ``` ##### 2. 修改 PHP 配置(两种方法) **方法一:直接编辑 php.ini** ```bash vi /etc/php.ini # 若没有 vi,使用 sed 修改 ``` 找到并修改: ```ini ; 原始配置 allow_url_include = Off ; 修改为 allow_url_include = On ``` **方法二:使用 sed 命令(推荐)** ```bash sed -i 's/allow_url_include = Off/allow_url_include = On/g' /etc/php.ini sed -i 's/;allow_url_include/allow_url_include/g' /etc/php.ini # 若被注释 ``` ##### 3. 同时启用相关选项(引用[1]) ```bash sed -i 's/magic_quotes_gpc = On/magic_quotes_gpc = Off/g' /etc/php.ini sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /etc/php.ini ``` ##### 4. 重启 Apache 服务 ```bash systemctl restart httpd # CentOS 7+ # 或 apachectl restart # 无 systemd 的容器 ``` ##### 5. 验证配置生效 ```bash php -i | grep allow_url_include # 应输出:allow_url_include => On => On ``` #### 🐳 Dockerfile 持久化方案 ```Dockerfile FROM centos:7 # 安装 Apache 和 PHP RUN yum install -y httpd php php-mysqli # 修改 PHP 配置 RUN sed -i 's/allow_url_include = Off/allow_url_include = On/g' /etc/php.ini && \ sed -i 's/magic_quotes_gpc = On/magic_quotes_gpc = Off/g' /etc/php.ini && \ sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /etc/php.ini # 配置 DVWA(引用[2]) COPY DVWA /var/www/html/DVWA RUN sed -i "s/'db_server' => '127.0.0.1'/'db_server' => 'localhost'/" /var/www/html/DVWA/config/config.inc.php # 设置权限 RUN chown -R apache:apache /var/www/html/DVWA EXPOSE 80 CMD ["httpd", "-DFOREGROUND"] ``` #### ⚠️ 常见问题排查 1. **配置未生效**: - 检查是否正确重启 Apache:`ps aux | grep httpd` - 查看错误日志:`tail -f /var/log/httpd/error_log` 2. **DVWA 数据库连接问题**(引用[2]): ```bash # 修改 DVWA 配置 vi /var/www/html/DVWA/config/config.inc.php ``` 确保配置正确: ```php $_DVWA[ 'db_server' ] = 'localhost'; # 而非 127.0.0.1 ``` 3. **容器 DNS 解析失败**(引用[3]): ```bash docker run --dns 8.8.8.8 --dns 8.8.4.4 -d your_image ``` #### 📌 验证 DVWA 运行 访问 `http://容器IP/setup.php` 应显示绿色配置检查通过状态: ``` PHP allow_url_include: On [绿色对勾] ``` #### 💡 最佳实践 1. 使用官方 PHP 镜像:`FROM php:7.4-apache` 2. 分离配置层: ```Dockerfile COPY php-overrides.ini /usr/local/etc/php/conf.d/ ``` 3. 最小权限原则:运行 Apache 时使用非 root 用户 --- ### 🔄 相关问题 1. 如何在 Docker 容器中正确配置 MariaDB 以配合 DVWA 使用? 2. 如何解决 DVWA 安装页面的 "Could not connect to the database" 错误? 3. 如何为 PHP 容器启用必要的扩展(如 mysqli、gd)? 4. 如何优化包含 DVWA 的 Docker 镜像体积? 5. 如何解决 CentOS 容器中的 SELinux 权限问题? 6. 如何配置 Apache 的 .htaccess 文件以支持 DVWA 重写规则? > 提示:DVWA 的 `config.inc.php` 数据库配置需与容器内数据库服务一致(引用[2]),若使用独立数据库容器,需将 `localhost` 替换为数据库容器名称。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值