Unity Admob Xcode 自動 Build

iOSでAdmobを利用するために必要な物

gpg-cpp-sdk
https://developers.google.com/games/services/downloads/
Admobのプラグイン
https://github.com/googleads/googleads-mobile-plugins/releases
GoogleMobileAdsSdkiOS-7.1.0
https://developers.google.com/+/mobile/ios/upgrading-sdk
Xcodeフレームワークを自動で入れるプラグイン
https://bitbucket.org/Unity-Technologies/xcodeapi


Frameworksフォルダに以下のものを入れる
google-plus-ios-sdk-1.7.1
GoogleMobileAdsSdkiOS-7.1.0
gpg-cpp-sdk
f:id:suakijob:20150423174904p:plain

Admobのプラグイン
GoogleMobileAds.unitypackage

Admobのサンプル
gist.github.com



Xcodeに自動でフレームワークを入れるファイルをEditorに置く
Unity-Technologies-xcodeapi-f62fa74f23a7
f:id:suakijob:20150423174710p:plain
PostBuildProcess.cs
gist.github.com

フレームワーク(注意:いらないのが入っているかも)

AddressBook.framework
AssetsLibrary.framework
CoreData.framework
CoreTelephony.framework
CoreText.framework
Security.framework
WebKit.framework
ImageIO.framework
EventKit.framework
EventKitUI.framework
AdSupport.framework
AudioToolbox.framework
AVFoundation.framework
CoreGraphics.framework
EventKit.framework
EventKitUI.framework
MessageUI.framework
StoreKit.framework
SystemConfiguration.framework

XcodeのOther lincker flageに追加するもの

-ObjC

プラグインのインポートを変更

Assets/Plugins/iOS/GADUBanner.m
@import CoreGraphics;
@import Foundation;
@import GoogleMobileAds;
@import UIKit;
変更
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UIKit/UIKit.h>

Assets/Plugins/iOS/GADUInterstitial.m
@import CoreGraphics;
@import Foundation;
@import GoogleMobileAds;
@import UIKit;
変更
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UIKit/UIKit.h>

Assets/Plugins/iOS/GADUObjectCache.m
@import Foundation;
変更
#import <Foundation/Foundation.h>

Assets/Plugins/iOS/GADURequest.h
@import Foundation;
@import GoogleMobileAds;
変更
#import <Foundation/Foundation.h>
#import <GoogleMobileAds/GoogleMobileAds.h>


Assets/Plugins/iOS/GADURequest.m
@import Foundation;
@import GoogleMobileAds;
変更
#import <Foundation/Foundation.h>
#import <GoogleMobileAds/GoogleMobileAds.h>


rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache/*

Xcode7.0からENABLE_BITCODEをNoにしないとこのプロダクトではBuildが失敗するので対応した。
-U and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together の対応方法 - Qiita
proj.AddBuildProperty(target, "ENABLE_BITCODE", "no");