本篇文章针对原生iOS工程中集成 Unity3d
模块,unity
工程的导出这里就不讲了。
环境
- Xcode 10.3
- Unity 2018.3.14f1 Personal
集成
导入文件
需要导入的就是这五个文件

直接拖入Xcode工程,注意这里的Data文件夹在工程里是蓝色的,在导入的时候要选择Create folder references
,其余的选择Create Group

拖入完成后注意
Classes
中这四个文件需要删除,选择Remove References


删除原本项目main.m
文件
将Classes中的Prefix.pch配置到 TARGETS
->Build Settings
->Prefix Header

TARGETS
->Build Settings
->Enable Bitcode
设置为NO
添加头文件以及依赖
配置头文件到TARGETS
->Build Settings
->Header Search Paths
,注意这里路径要跟你工程中文件的位置配置

在Build Settings
中添加User-Defined Setting

GCC_THUMB_SUPPORT
设置为 NO
GCC_USE_INDIRECT_FUNCTION_CALLS
设置为 NO
UNITY_RUNTIME_VERSION
设置为 你unity的版本UNITY_SCRIPTING_BACKEND
设置为 il2cpp

Other Linker Flags
设置为 $(inherited) -weak_framework CoreMotion -weak-lSystem
Other C Flags
设置为 $(inherited) -DINIT_SCRIPTING_BACKEND=1 -fno-strict-overflow -DNET_4_0 -DRUNTIME_IL2CPP=1
Mismatched Return Type
设置为 NO
ENABLE_STRICT_OBJC_MSGSEND
设置为 NO

在TARGETS
中的Build Phases
中添加New Run Script Phaes

导入全部依赖库

完成
网友评论