Reputation: 4946
In my project, I have added my dependencies via Cocoapods. For this question, I am using CocoaAsyncSocket as an example, but I have the same issue the two other dependencies that I am using. My Podfile looks like:
platform :ios, '8.0'
use_frameworks!
link_with 'MainTarget'
pod 'CocoaLumberjack'
pod 'CocoaAsyncSocket'
pod 'SVProgressHUD'
target 'MainTargetTests' do
pod 'OCMock', '~> 3.0'
end
Everything works as expected when I build and run the application in debug (on a device). When I archive the app (with an enterprise license), I can not create a new instance of GCDAsyncSocket. There no compiler or linker errors, and I when look into the contents of the .ipa, and all frameworks are packaged as expected.
An example of the behaviour:
@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
}
Some Environment Info: - Xcode Version 7.1.1 - Cocapods Version 0.39.0
Pod install Output:
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.
The workspace is created as expected, and I am not modifying any other build settings,not any of the build phases.
Using the hints provided by the answer below, it has fixed a crash, but it seems whenever I try to instantiate an object (i.e. GCDAsyncSocket), it returns nil
.
Upvotes: 2
Views: 425
Reputation: 193
From what I read in the past few weeks with similar issues, you cannot do a combination of
// Method 1
pod '1'
pod '2'
// Method 2
target 'MainTargetTests' do
pod '3', '~> 3.0'
end
Try to stick with one method, or the other. If you need common pods, since it's basically a ruby file you can declare something like :
def common_pods
pod '1'
pod '2'
end
target 'Debug' do
common_pods
end
target 'Release' do
common_pods
pod '3'
end
Hope that helps! That way you can also remove your 'linked_with'
Upvotes: 1