Search code examples
iosxcodeamazon-web-servicescocoapodsaws-mobilehub

awsmobilehub and cocoapods integration


I have started using AWSMobileHub and I am just going through the integration steps but it does not appear to play nicely with cocoapods which I intend on using in the project.

I have followed the integration steps and add the frameworks which I downloaded from aws + the helper code.

AWS-Frameworks

I have added them as embedded frameworks like so

enter image description here

enter image description here

This compiles and runs fine

Then I add cocoapods to the project with pod init, editing podfile with the following and creating workspace.

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.0'

use_frameworks!

target 'ProjectName' do
project 'ProjectName'

pod 'Fabric'
pod 'Crashlytics'

end

followed by pod install which adds what ever frameworks I have added to podfile.

But now when I compile I get the following errors.

Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_AWSS3PreSignedURLBuilder", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSContentManager.o)
"_OBJC_CLASS_$_AWSS3ListObjectsOutput", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSContentManager.o)
"_OBJC_CLASS_$_AWSS3GetPreSignedURLRequest", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSContentManager.o)
"_OBJC_CLASS_$_AWSS3", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSContentManager.o)
 (maybe you meant: _OBJC_CLASS_$_AWSS3ContentProvider)
"_OBJC_CLASS_$_FBSDKLoginManager", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSFacebookSignInProvider.o)
"_OBJC_CLASS_$_AWSLambdaInvoker", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSCloudLogic.o)
"_OBJC_CLASS_$_AWSSNSGetEndpointAttributesInput", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSPushManager.o)
"_OBJC_CLASS_$_FBSDKApplicationDelegate", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSFacebookSignInProvider.o)
"_OBJC_CLASS_$_AWSSNSSubscribeInput", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSPushManager.o)
"_OBJC_CLASS_$_GIDSignIn", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSGoogleSignInProvider.o)
"_OBJC_CLASS_$_AWSSNSSetEndpointAttributesInput", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSPushManager.o)
"_OBJC_CLASS_$_FBSDKAccessToken", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSFacebookSignInProvider.o)
"_OBJC_CLASS_$_AWSSNS", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSPushManager.o)
"_OBJC_CLASS_$_FBSDKGraphRequest", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSFacebookSignInProvider.o)
"_OBJC_CLASS_$_AWSS3ListObjectsRequest", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSContentManager.o)
"_OBJC_CLASS_$_AWSSNSCreatePlatformEndpointInput", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSPushManager.o)
"_OBJC_CLASS_$_AWSSNSUnsubscribeInput", referenced from:
  objc-class-ref in AWSMobileHubHelper(AWSPushManager.o)
"_AWSSNSErrorDomain", referenced from:
  ___88-[AWSPushManager interceptApplication:didRegisterForRemoteNotificationsWithDeviceToken:]_block_invoke.237 in AWSMobileHubHelper(AWSPushManager.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If I remove the embedded frameworks and add them to the podfile instead

pod 'AWSCognitoIdentityProvider'
pod 'AWSCore'

I get the same errors.

This is my other linker flags for debug build

//:configuration = Debug
OTHER_LDFLAGS = $(inherited) -l"c++" 
-l"sqlite3" 
-l"stdc++" 
-l"z" 
-framework "AVFoundation" 
-framework "AWSCognitoIdentityProvider" 
-framework "AWSCore" 
-framework "AddressBook" 
-framework "AssetsLibrary" 
-framework "CFNetwork" 
-framework "CoreFoundation" 
-framework "CoreGraphics" 
-framework "CoreLocation" 
-framework "CoreMedia" 
-framework "CoreMotion" 
-framework "CoreText" 
-framework "CoreVideo" 
-framework "MessageUI" 
-framework "QuartzCore" 
-framework "SafariServices" 
-framework "Security" 
-framework "StoreKit" 
-framework "SystemConfiguration" 
-framework "UIKit"

//:completeSettings = none

edit: It would appear that it allows some frameworks be added with cocoapods fine

the problem seems to arise when a framework requires -ObjC to be added to other linker flags

OTHER_LDFLAGS = $(inherited) -ObjC -l"z" -framework "AFNetworking" -framework "AWSCognitoIdentityProvider" -framework "AWSCore" -framework "Bolts" -framework "CFNetwork" -framework "CoreGraphics" -framework "FBSDKCoreKit" -framework "FBSDKLoginKit" -framework "PureLayout" -framework "QuartzCore" -framework "Reveal"

Above is in the pod.debug.xcconfig file

When I add the following the compile fine with aws

pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'PureLayout'
pod 'AFNetworking', '3.1.0'

as examples

But then if I add the following it adds in -ObjC and causes all the errors

pod 'Reveal-iOS-SDK', :configurations => ['Debug']

Any ideas what I should be doing here to get these frameworks playing together?

The same happens if I try adding reveal as a pod file into the sample app that comes with AWSMobileHub "MySampleApp"

edit 2: When I remove the AMazonAws folder that contains the AWSMobileHubHelper.framework and compile with just the aws files added from cocoapods it works fine. The issue seems to happen when the AmazonAws folder is added.


Solution

  • I solved above by going to the Pod file pod-projectname.debug.xcconfig and removing -ObjC from the OTHER_LDFLAGS.

    I have no idea what this flag does and I am still looking into it but at least for now it is letting me compile and run my project. If anyone has more info on this I am all ears.

    EDIT - Ok folks please dont do this. It leads to other bugs down the road. For instance I was adding a pod called Intercom that requires the -ObjC flag. It compiles fine without but will crash later while running.

    I have logged this bug to Amazon and I have a support engineer looking at this issue. In the mean time I have removed the Helper framework completely and I am using the other aws frameworks directly and adding them using pods.

    If I hear back anything useful from amazon support I will update this here.