• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 在 Release Build 中无法使用通过 Cocoapods 添加的框架

[复制链接]
菜鸟教程小白 发表于 2022-12-13 12:26:36 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

在我的项目中,我通过 Cocoapods 添加了我的依赖项。对于这个问题,我以 CocoaAsyncSocket 为例,但我使用的其他两个依赖项也有同样的问题。我的 Podfile 看起来像:

platform :ios, '8.0'
use_frameworks!

link_with 'MainTarget'

pod 'CocoaLumberjack'
pod 'CocoaAsyncSocket'
pod 'SVProgressHUD'

target 'MainTargetTests' do
    pod 'OCMock', '~> 3.0'
end

当我在调试中(在设备上)构建和运行应用程序时,一切都按预期工作。当我存档应用程序(使用企业许可证)时,我无法创建 GCDAsyncSocket 的新实例。没有编译器或链接器错误,当我查看 .ipa 的内容时,所有框架都按预期打包。

行为示例:

@implementation OPTAppDelegate
- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions {
    [self configSocketManager];

    // perform the rest of the usual set up.
    return YES;
}

- (void) configSocketManager {
    GCDAsyncSocket *socket = [[GCDAsyncSocket alloc] init];
    if ( ! socket ) {
        // we only enter this block in when the app is built for release
        [[NSException exceptionWithName"Socket Not Created" reason"No idea" userInfo:nil] raise];
    }

    // if we get here, all is good
}

一些环境信息: - Xcode 版本 7.1.1 - Cocopods 版本 0.39.0

Pod 安装输出:

Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing CocoaAsyncSocket (7.4.2)
Installing CocoaLumberjack (2.2.0)
Installing OCMock (3.2)
Installing SVProgressHUD (1.1.3)
Generating Pods project
Integrating client project
Sending stats
Sending stats
Pod installation complete! There are 4 dependencies from the Podfile and 4 total pods installed.

工作区按预期创建,我没有修改任何其他build设置,也没有修改任何构建阶段。

什么可能会阻止在发布版本中使用上述框架?

SVProgressHUD 和 CocoaLumberjack 变得同样无用。

2016 年 1 月 4 日更新:

使用 answer below 提供的提示,它修复了崩溃,但似乎每当我尝试实例化一个对象(即 GCDAsyncSocket)时,它都会返回 nil



Best Answer-推荐答案


根据我在过去几周读到的类似问题,你不能做一个组合

// Method 1
pod '1'
pod '2'

// Method 2
target 'MainTargetTests' do
    pod '3', '~> 3.0'
end

尝试坚持一种方法,或者另一种。如果您需要通用 pod,因为它基本上是一个 ruby​​ 文件,您可以声明如下内容:

def common_pods
  pod '1'
  pod '2'
end

target 'Debug' do
  common_pods
end

target 'Release' do
  common_pods
  pod '3'
end

希望对您有所帮助!这样你也可以删除你的“linked_with”

关于ios - 在 Release Build 中无法使用通过 Cocoapods 添加的框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34166720/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap