pet

文档

项目参数

https://ehu9lcwtyd.feishu.cn/sheets/TZjfs9a0jhTJpStjWyNc76benHb

}a.[230S

ios工程编译

获得p12和pp file

其中dev的pp file需要增加对应的测试设备。

00008101-00084C320208001E

用对应的包名新建一个空工程,把proj.ios_mac文件夹拷贝过去

可能还需要拷贝cocos2d目录下其他文件,如build文件夹,external文件夹。

修改webview相关

https://www.jianshu.com/p/a83848e500b8

修改Minmum Deployments到12.0

修改Requires full screen、iPhone Orientation和iPad Orientation

重新添加Classes和Resources

添加代码后,可以按名称排序一下

添加代码搜索路径

如果报错找不到pub/PF.h,Build Settings->Search Paths->Header Search Paths

添加$(SRCROOT)/../Classes

pod

  1. 在proj.ios_mac文件夹下打开终端,输入pod init

  2. 编辑Podfile中的内容,如:

    platform :ios, '12.0'
    
    use_frameworks!
    target 'PET_CANDY_PUZZLE-mobile' do
    
        pod 'AppLovinSDK'
        pod 'AppLovinMediationAdColonyAdapter'
        pod 'AppLovinMediationChartboostAdapter'
        pod 'AppLovinMediationGoogleAdManagerAdapter'
        pod 'AppLovinMediationGoogleAdapter'
        pod 'AppLovinMediationInMobiAdapter'
        pod 'AppLovinMediationIronSourceAdapter'
        pod 'AppLovinMediationVungleAdapter'
        pod 'AppLovinMediationFacebookAdapter'
        pod 'AppLovinMediationMintegralAdapter'
        pod 'AppLovinMediationByteDanceAdapter'
        pod 'AppLovinMediationTapjoyAdapter'
        pod 'AppLovinMediationUnityAdsAdapter'
    
        pod 'Adjust'
    
        #Facebook自动记录事件(安装,启动,内购),如有使用Fb的登录、分享等组件,也需要升级9.0.1及以上
        # pod 'FBSDKCoreKit', '~> 9.0.1'
    
        pod 'YF_IAP'
    
        pod 'YF_DataAcqu', '5.0.5'
    
        pod 'FBAEMKit', '16.1.3'
        pod 'FBSDKCoreKit', '16.1.3'
        pod 'FBSDKLoginKit', '16.1.3'
        pod 'FBSDKShareKit', '16.1.3'
        pod 'FBSDKGamingServicesKit', '16.1.3'
    
        post_install do |installer|
            xcode_base_version = `xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -d . -f 1`
            installer.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                # For xcode 15+ only
                if config.base_configuration_reference && Integer(xcode_base_version) >= 15
                xcconfig_path = config.base_configuration_reference.real_path
                xcconfig = File.read(xcconfig_path)
                xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
                File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
                end
            end
            end
        end
    
    end
  3. 输入export all_proxy=socks5://127.0.0.1:1081

  4. 输入pod install --repo-update

Info.plist修改

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

商店评分

Google UMP

代码修改->iOS平台相关函数

代码修改->ATT

  1. 添加依赖AppTrackingTransparency.framework

  2. 在AppController.mm里包含头文件

    #import <AppTrackingTransparency/AppTrackingTransparency.h>

  3. 在applicationDidBecomeActive函数里增加如下代码

    //att
    if (@available(iOS 14, *)) {
        NSUInteger status = ATTrackingManager.trackingAuthorizationStatus;
        if (status == ATTrackingManagerAuthorizationStatusNotDetermined) {
            NSLog(@"[ios att log] 未决定");
            [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
                if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
                    NSLog(@"[ios att log] 用户同意");
                } else {
                    NSLog(@"[ios att log] 用户不同意");
                }
            }];
        } else if (status == ATTrackingManagerAuthorizationStatusRestricted) {
            NSLog(@"[ios att log] 限制");
        } else if (status == ATTrackingManagerAuthorizationStatusDenied) {
            NSLog(@"[ios att log] 拒绝");
        } else if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
            NSLog(@"[ios att log] 同意");
        }
    }
  4. 在Info.plist里增加如下代码:

    <key>NSUserTrackingUsageDescription</key>
    <string>Your data will be used to avoid random ads and get better game experiences!</string>

代码修改->广告

  1. 根据需要集成的广告平台,在官网勾选后拷贝到Podfile里并pod。

  2. 在Info.plist里增加如下代码:

    <key>AppLovinSdkKey</key>
    <string>SpT1TmLovSn4vQJxPipKB1xbGpB-4pEXciZASvyMMkQF8lBTR-td0pEHcPFhDUDrBo_egy_2fQHp9TLaSDCS0Q</string>
    <key>SKAdNetworkItems</key>
    <array>
        //balabala
    </array>
  3. 初始化:#import <AppLovinSDK/AppLovinSDK.h>

    //1. ad
    [ALSdk shared].mediationProvider = @"max";
    [[ALSdk shared] initializeSdkWithCompletionHandler:^(ALSdkConfiguration *configuration) {
        NSLog(@"[ios gdpr log] country code=%@", configuration);
        PFIOS::of_maxad_inter_init();
        PFIOS::of_maxad_reward_init();
    }];
    [[ALSdk shared] showMediationDebugger];
  4. 拷贝视频和插屏的两个类文件

代码修改->adjust

  1. #import <Adjust.h>

    NSString* adjustToken = @"rw5l7ub4y48w";
    NSString *adjustEnvironment = ADJEnvironmentProduction;
    ADJConfig* adjustConfig = [ADJConfig configWithAppToken:adjustToken environment:adjustEnvironment];
    [Adjust appDidLaunch:adjustConfig];
  2. 添加依赖AdSupport.framework、AdServices.framework、StoreKit.framework、AppTrackingTransparency.framework、WebKit.framework

    https://help.adjust.com/zh/article/get-started-ios-sdk

代码修改->EAS

  1. 在Info.plist里增加如下代码:

    <key>EAS_APP_ID</key>
    <string>8429kznyiqu0mpg9twsoclgy</string>
  2. #import <YFData/YFData.h>

    YFDataCommon.common.app_reg = YFREGION_CHINA;
    [YFDataHelper start:^(NSError * _Nullable error) {
      if (error) {
        //初始化错误不影响数据的打点及上传
        YFDataLogInfo(@"初始化错误:%@", error.localizedDescription);
      } else {
        YFDataLogInfo(@"初始化成功");
      }
    }];

代码修改->内购

  1. 共享密钥

代码修改->

解决报错->Undefined symbol: _ADJEnvironmentProduction

  1. 添加一个swift文件,并添加桥接文件。

  2. 在Build Settings->Linking->Other Linker Flags添加$(inherited)-ObjC

  3. 在Build Settings->Search Paths->Library Search Paths添加$(inherited)

解决报错->Undefined symbol: OBJC_CLASS$_GCController

  1. 添加框架GameController.frameworkMediaPlayer.framework

解决报错->运行崩溃:The Google Mobile Ads SDK was initialized without an application ID

  1. 在Info.plist里增加如下代码:

    <key>GADApplicationIdentifier</key>
    <string>ca-app-pub-xxx</string>