chrisjp / CJPAdController

A singleton class providing a simple way to add iAd and AdMob ads to a view controller. Choose one as the default, fall back to the other.
http://chrisphillips.co.uk
MIT License
202 stars 58 forks source link

Compilation error #22

Closed foffux closed 9 years ago

foffux commented 9 years ago

I am trying to use CJPAdController under Xcode 5.1.1 but I got the following compilation error. I am wondering if it is due to Xcode 5 or not. If not, please help me solving this issue. Thank you. schermata 2015-02-09 alle 16 57 05

chrisjp commented 9 years ago

Not a problem with Xcode 5, but you probably created the project in Xcode 4 and so the project didn't have modules enabled by default.

It's an easy fix. Simply go to your project's build settings, search for "modules", you should see a setting "Enable Modules (C and Objective-C)" - change this to Yes. You should be able to compile then.

EDIT: Just noticed your screenshot this is only appearing on the GoogleMobileAdsSdk line, so this setting maybe already set to Yes. Might want to check your project's Framework Search Paths are set correctly, it might not be finding the AdMob SDK.

foffux commented 9 years ago

Hello Thanks for the answer but I guess this is not the issue. I created the project with Xcode 5 and so I have already this setting enabled, as you can see from the screen shot below. Other suggestion? schermata 2015-02-09 alle 17 11 40

chrisjp commented 9 years ago

Sorry I edited my comment above after looking at your first screenshot more closely. Seems like it's not finding the Google AdMob SDK. I see you're using Pods, so it's strange you get this error as it should handle this all automatically.

Check your project's Framework Search Paths? Should have an entry like $(PODS_ROOT)/Google-Mobile-Ads-SDK set to recursive

foffux commented 9 years ago

Are you meaning this? If you did, I guess I have. But also changing to recursive does not help, as you can see. Sorry I have to leave my job place now, I will check your answer as soon as possible, hoping you can help me. Thank you. schermata 2015-02-09 alle 17 26 47 schermata 2015-02-09 alle 17 27 35 schermata 2015-02-09 alle 17 26 47 schermata 2015-02-09 alle 17 27 35 schermata 2015-02-09 alle 17 30 44 schermata 2015-02-09 alle 17 30 53

chrisjp commented 9 years ago

Yes I see something similar in mine. But mine also has $(PODS_ROOT)/Google-Mobile-Ads-SDK so try adding that and make sure it's set to recursive. pod install should have added it automatically though.

image

foffux commented 9 years ago

Hi Chris. Sorry for annoying you but I am not able to let my project run with it. I tried what you tad me, but nothing, I tried to perform a cleaning reinstall, but nothing. Here you are what I can see. I cannot understand why it does not work... schermata 2015-02-10 alle 09 36 37 schermata 2015-02-10 alle 09 36 46 schermata 2015-02-10 alle 09 36 53 schermata 2015-02-10 alle 09 36 59

foffux commented 9 years ago

I tried to import just google ads framework but nothing I got the following issue. I cannot understand: schermata 2015-02-10 alle 11 09 49

chrisjp commented 9 years ago

This is very strange. I honestly don't know why this is happening, especially with CocoaPods. I created a new test project just now and it can build fine with CJPAdController and the AdMob SDK.

My only other thought is maybe you have an old version of cocoapods which isn't handling it correctly? You could try running sudo gem install cocoapods to update, and then try installing your pods again in a new project?

Or maybe it is a problem with Xcode 5... I'm not sure, I can't test that as I only have Xcode 6 available now.

foffux commented 9 years ago

Hi Exactly same issue with a new test project and only this pod added. I also updated my cocoapods, but my version was already: pod --version 0.35.0 so the latest one. The last chance is to update to Xcode 6...I had to do it but I would have been able to understand why this issue happened. Anyway, I try with Xcode 6 and I hope...

foffux commented 9 years ago

Hi. I did it! I had to update to Xcode 6 and also add -Objc instead of -ObjC in OTHER LINKER FLAGS I do not actually the reason but it works for me now. Thank you.

chrisjp commented 9 years ago

Glad to hear you fixed it!

The new AdMob framework (v7.0.0) shouldn't require that -ObjC flag though, so I'm thinking you have an old version, probably 6.12? Well, I guess if it all works then it doesn't matter now :)

foffux commented 9 years ago

I do not think so because in xcconfig I can see:

PODS_GOOGLE_MOBILE_ADS_SDK_FRAMEWORK_SEARCH_PATHS = "$(PODS_ROOT)/Google-Mobile-Ads-SDK/GoogleMobileAdsSdkiOS-7.0.0" PODS_GOOGLE_MOBILE_ADS_SDK_OTHER_LDFLAGS = -framework "AVFoundation" -framework "AudioToolbox" -framework "CoreGraphics" -framework "CoreTelephony" -framework "EventKit" -framework "EventKitUI" -framework "GoogleMobileAds" -framework "MessageUI" -framework "StoreKit" -framework "SystemConfiguration" -weak_framework "AdSupport"

So I think my version is the latest one. Do you know how I can check for sure? Thank you.

chrisjp commented 9 years ago

Oh, yes that's definitely the latest version, it wouldn't have created that directory otherwise. It's possible you require -ObjC for some other pods you have though. Google said in the v7.0.0 release notes - "Removed dependency on the -ObjC linker flag."

As for explicitly checking the version I believe there is a constant GoogleMobileAdsVersionString and also [GADRequest sdkVersion] method that should return version strings.

So it's a little weird you had problems getting this to work, but if everything is working fine now then hopefully you should be good to go. Good luck with your project.

foffux commented 9 years ago

I finally guess to have understood how to run your pod correctly. I followed this:

http://stackoverflow.com/questions/26445784/target-overrides-the-framework-search-paths-build-settings

Now, I am using your controller. And I have a question you sure can answer. Running also your sample project I cannot see mediation at work. That is: if [CJPAdController sharedInstance].adNetworks = @[@(CJPAdNetworkiAd), @(CJPAdNetworkAdMob)]; then only iAd can be seen instead if [CJPAdController sharedInstance].adNetworks = @[@(CJPAdNetworkAdMob), @(CJPAdNetworkiAd)]; then only AdMob can be seen

This happens both in iOS 7 and iOS 8. I sure with an older version of your controller, I was able to see both, mediated.

Are you trying to check, please? Thank you very much.

foffux commented 9 years ago

Sorry. I was wrong. Everything works well, just I had to wait for enough time...sorry.

foffux commented 9 years ago

It is a very long long time, anyway...When all of two are setup, in fact almost only one is shown. Are you aware of this?

chrisjp commented 9 years ago

Yes. That is actually the way this is supposed to work. It's not technically 'mediation'.

Basically, you choose which ad network you prefer and it will show this all the time. But, if it doesn't get an ad, it will try the other network instead, and it will keep using that until it can get an ad from the network you prefer.

foffux commented 9 years ago

Ahhh...sorry. I did not get this. I have not read carefully. Ok, I now get this. Then it works well :-)

foffux commented 9 years ago

This issue can be close for me, but please take a look also at Status bar and Banner on top #23 Thank you.