浏览代码

Merge pull request #121 from Unity-Technologies/zxw/ios_prelink_solution

Zxw/ios prelink solution
/siyaoH-1.17-PlatformMessage
GitHub 3 年前
当前提交
940f891a
共有 3 个文件被更改,包括 40 次插入2 次删除
  1. 37
      engine/README.md
  2. 3
      engine/src/shell/common/switches.cc
  3. 2
      engine/src/shell/common/switches.h

37
engine/README.md


./flutter/tools/gn --unoptimized --ios --bitcode //enable bitcode
```
add this line to the end of out/ios_debug_unopt/args.gn:
add this line to the end of out/ios_debug_unopt/args.gn, also
ensure that "bitcode_marker=false" if bitcode is enabled
```
icu_use_data_file=false
```

```
cd <uiwidigets_dir>\engine
mono bee.exe ios
```
```
### Prelink Library (TODO: make it simpler)
Different from other platforms, the engine is built as a static library on iOS. One drawback of this is that, there are potential library conflicts between our library and the Unity build-in library (libiPhone-lib.a). To address this issue, an additional prelink step is required. Since prelink is not supported by Bee yet (https://unity.slack.com/archives/C1RM0NBLY/p1617696912101700), currently we have to do it manually as follows:
Generate the symbols that need to be stripped from libtxt_lib.a:
```
nm -j $FLUTTER_ROOT/out/ios_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a > third.symbol
```
Prelink our library with libtxt_lib.a and produce one single target file, namely libUIWidgets_d.o, inside engine folder:
```
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -r -arch arm64 -syslibroot $IOS_SDK_PATH -unexported_symbols_list third.symbol $TARGET_FILES $FLUTTER_ROOT/out/ios_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a -o "libUIWidgets_d.o" //disable bitcode
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -r -arch arm64 -bitcode_bundle -bitcode_verify -syslibroot $IOS_SDK_PATH -unexported_symbols_list third.symbol $TARGET_FILES $FLUTTER_ROOT/out/ios_debug_unopt/obj/flutter/third_party/txt/libtxt_lib.a -o "libUIWidgets_d.o" //enable bitcode
```
where **$IOS_SDK_PATH** is the ios sdk path on your computer, which is usually inside "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/" and named like iPhoneOS*XX*.*YY*.sdk. **$TARGET_FILES** is a list of target files (i.e., .o files) in our library. You can find all the target files in the file "artifacts/tundra.dag.json" by collecting all the file names with suffix ".o" from the **Inputs** section under this **Annotation** "Lib_iOS_arm64 artifacts/libUIWidgets/debug_iOS_arm64/libUIWidgets_d.a".
Archive the generated target file into a static library:
```
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool" -arch_only arm64 -static "libUIWidgets_d.o" -o "libUIWidgets_d.a"
```
Strip all the internal symbols from libtxt_lib.a:
```
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip" -x "libUIWidgets_d.a"
```
Copy the generated libUIWidgets_d.a from the engine folder to the plugin folder of your target project (e.g., Samples/UIWidgetsSamples_2019_4/Assets/Plugins/iOS/) to replace the original libraries there (i.e., libtxt_lib.a and libUIWidgets_d.a)

3
engine/src/shell/common/switches.cc


#include <cstdint>
namespace uiwidgets {
#if OS_ANDROID || OS_WIN
extern "C" uint8_t _binary_icudtl_dat_start[];
extern "C" uint8_t _binary_icudtl_dat_end[];

_binary_icudtl_dat_end - _binary_icudtl_dat_start);
}
#endif
std::unique_ptr<fml::Mapping> GetSymbolMapping(std::string symbol_prefix,
std::string native_lib_path) {

2
engine/src/shell/common/switches.h


#include "flutter/fml/mapping.h"
namespace uiwidgets {
#if OS_ANDROID || OS_WIN
#endif
std::unique_ptr<fml::Mapping> GetSymbolMapping(std::string symbol_prefix,
std::string native_lib_path);
} // namespace uiwidgets
正在加载...
取消
保存