[ProjectName] was compiled with optimization - stepping may behave oddly; variables may not be available.
何時遇到該問題
打包成xcode項目后,在xcode中真機運行時閃退崩潰,得到該錯誤信息原因
具體原因
未知
版本
Xcode 9 其他版本未測試
Unity2017.2.0 Unity2017.2.1p2 其他版本未測試
解決方案
1. 在xcode 的 Custom Compiler Flags -> Other C Flags 中添加:DRUNTIME_IL2CPP=1
參考: https://stackoverflow.com/questions/45078851/optimization-stepping-may-behave-oddly-ios-unity
2 通過關閉編譯優化。在BuildSetting中分別設置LLVM Code Generation和Swift Code Generation 中的Optimization Level 為None
3. 從頭到尾檢查控制台輸出 排查警告或者錯誤信息。我的項目中發現控制台輸出
“Could not produce class with ID 258.
This could be caused by a class being stripped from the build even though it is needed. Try disabling 'Strip Engine Code' in Player Settings.”
按要求在unity的ios player setting中禁用Strip Engine Code即可
類似:"__ProfileSignOff", referenced from:_GA__ProfileSignOff_m4067977632 in Bulk_Assembly-CSharp-firstpass_14.o
(maybe you meant: _GA__ProfileSignOff_m4067977632)
"__ProfileSignInWithPUIDAndProvider", referenced from:
何時遇到該問題
Unity導入了某些SDK,然后在xcode中構建時錯誤
具體原因
可能Unity導出xcode工程后,相關SDK的庫文件引用出錯誤了,該鏈接庫有__ProfileSignOff等方法定義 ,也可能缺少或丟失SDK庫文件,請檢查文件是否存在.
版本
任何unity和xcode版本
解決方案
在SDK中,找到SDK庫文件,重新導入