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

时间:2015-12-08 21:52:42

标签: ios cocoapods xcode7

在我的项目中,我通过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)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)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 - Cocapods版本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.

工作空间按预期创建,我不会修改任何其他构建设置,也不会修改任何构建阶段。

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

SVProgressHUD和CocoaLumberjack同样没用。

2016年1月4日更新:

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

1 个答案:

答案 0 :(得分:1)

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

的组合
// 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'

相关问题