Objective C框架不能导出一些类

问题描述 投票:1回答:1

我开发了一个名为EzoRed(ezored.com)的工具。它使用本机代码(c ++)为ios或aar生成一个框架。

当我获得生成的xcode项目并拖放到我的示例项目中时,我使用框架没有问题。当我只拖动生成的框架时(使用Debug版本的框架一切正常,但是发布不起作用。),我的应用程序编译,安装在设备或模拟器上但是当我运行时我得到错误:

enter image description here

我使用nm工具检查导出的符号,并看到只导出了* Impl类。看到:

nm -gU build / ios / Release-universal / EzoRed.framework / EzoRed

0000000000010a88 S _OBJC_CLASS_$_EZRAudioStreamerPlatformServiceImpl
0000000000010b28 S _OBJC_CLASS_$_EZRGreetingMessagePlatformServiceImpl
00000000000109e8 S _OBJC_CLASS_$_EZRHttpClientPlatformServiceImpl
0000000000010ab0 S _OBJC_METACLASS_$_EZRAudioStreamerPlatformServiceImpl
0000000000010b50 S _OBJC_METACLASS_$_EZRGreetingMessagePlatformServiceImpl
0000000000010a10 S _OBJC_METACLASS_$_EZRHttpClientPlatformServiceImpl
0000000000010d30 D __ZTIPU39objcproto28EZRHttpClientPlatformService11objc_object
0000000000010fa0 D __ZTIPU42objcproto31EZRAudioStreamerPlatformService11objc_object
0000000000011200 D __ZTIPU44objcproto33EZRGreetingMessagePlatformService11objc_object
0000000000010d18 D __ZTIU39objcproto28EZRHttpClientPlatformService11objc_object
0000000000010f88 D __ZTIU42objcproto31EZRAudioStreamerPlatformService11objc_object
00000000000111e8 D __ZTIU44objcproto33EZRGreetingMessagePlatformService11objc_object
000000000000c700 S __ZTSPU39objcproto28EZRHttpClientPlatformService11objc_object
000000000000c9c0 S __ZTSPU42objcproto31EZRAudioStreamerPlatformService11objc_object
000000000000cca0 S __ZTSPU44objcproto33EZRGreetingMessagePlatformService11objc_object
000000000000c740 S __ZTSU39objcproto28EZRHttpClientPlatformService11objc_object
000000000000ca00 S __ZTSU42objcproto31EZRAudioStreamerPlatformService11objc_object
000000000000cce0 S __ZTSU44objcproto33EZRGreetingMessagePlatformService11objc_object

这很奇怪,因为一切都编译没有问题。

使用Debug版本的框架一切正常。但是发布不起作用。

一些检查:

它被包含在桥文件中:https://github.com/ezored/sample-app/blob/master/source/ios/SampleApp/SampleApp/SampleApp-Bridging-Header.h

它在CMakeLists.txt上: https://github.com/ezored/sample-app/blob/master/vendor/target-ios-master/CMakeLists.txt#L132

它编译和安装没有问题,但没有运行。它显示了上传信息。

所有项目文件都在这里,任何人都可以下载和运行: https://github.com/ezored/sample-app

使用的命令是:

cmake --build . --config Debug  (is exported all files correct)
cmake --build . --config Release  (is exported only *Impl files)

xcode direct命令具有相同的效果:

xcodebuild build -configuration "Debug"  (is exported all files correct)
xcodebuild build -configuration "Release"  (is exported only *Impl files)

我做错了什么?谢谢你的帮助。

c++ ios objective-c xcode frameworks
1个回答
0
投票

我找到的解决方案放在我的CMakeLists.txt上:

CXX_VISIBILITY_PRESET默认值

因为在文件ios.cmake我有行:

set(CMAKE_CXX_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} -fvisibility=hidden -fvisibility-inlines-hidden -fobjc-abi-version=2 -fobjc-arc ${CXX_FLAGS}")

https://github.com/ezored/target-ios/blob/master/build/files/ios.cmake#L284

我不知道这是不是最好的做法,我会尝试用App批准App Store上的应用程序。

© www.soinside.com 2019 - 2024. All rights reserved.