近期bug记录201911

ios 插件

Unity与Native调用

Unity - Manual: Building Plugins for iOS

  • extern "C"
    函数声明得用C like
  • String to char *
    const char *Cstr = myObjCStr.UTF8String;
    放在extern “C” 的func中return 会内存泄露,最后采用了jpush中一段代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    static char *MakeHeapString(const char *string) {
    if (!string){
    return NULL;
    }
    char *mem = static_cast<char*>(malloc(strlen(string) + 1));
    if (mem) {
    strcpy(mem, string);
    }
    return mem;
    }
  • .m与.mm
    用到c++func得用.mm

其他

Unity3D Native 插件开发(3)— 理解 IL2CPP 机制-腾讯游戏学院
十分钟让你明白Objective-C的语法(和Java、C++的对比) | 皮卡丘♪~(´ε` )

info.plist编辑

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
string plistPath = path + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));

// Get root
PlistElementDict rootDict = plist.root;

var buildKey = "key";
rootDict.CreateDict(buildKey);
rootDict.SetString(buildKey, "value");

string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";
if (rootDict.values.ContainsKey(exitsOnSuspendKey)) {
rootDict.values.Remove(exitsOnSuspendKey);
}

//Write to file
File.WriteAllText(plistPath, plist.WriteToString());

push角标问题

IOS 极光推送角标问题 - 简书
解决方案:
UnityAppController.mm脚本中的 applicationDidBecomeActive函数内增加:

1
2
[UIApplication sharedApplication].applicationIconBadgeNumber=0;
[JPUSHService setBadge:0];

Jenkins打包

errSecInternalComponent
详细: Xcode Command /usr/bin/codesign failed with exit code 1 : errSecInternalComponent
ios - Xcode Command /usr/bin/codesign failed with exit code 1 : errSecInternalComponent - Stack Overflow

Jenkins Xcode命令行上传

xcode11 构建上传问题 - 崇祟 - 博客园
https://github.com/bitrise-steplib/steps-deploy-to-itunesconnect-application-loader/issues/9

git rebase a b c

将另一分支的几个提交cherry-pick过来
git - How to cherry-pick multiple commits - Stack Overflow