Xcode16 iOS18 编译问题适配

embedded/2024/10/22 17:28:15/

问题1:ADClient编译报错问题

报错信息

Undefined symbols for architecture arm64:"_OBJC_CLASS_$_ADClient", referenced from:in ViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
相关代码(demo)

原因

苹果对AdClicent API加了一个标识
ADCLIENT_DEPRECATED_IOS_90_145_OBSOLETED_180
表示:iOS7.1-iOS14.5可用,iOS18彻底废弃,会在iOS18系统上编译失败。

解决办法

使用AdService库的AAAttribution替代,注意iOS14.3才可以使用。

代码
if (@available(ios 14.3, *)) {NSError *error;NSString *token = [AAAttribution attributionTokenWithError:&error];if (token != nil) {...}
}
参考

https://developer.apple.com/forums/thread/759156
https://developer.apple.com/documentation/iad?language=objc

问题2:Xcode16(正式版)运行时,YYCache导致crash

报错信息

原因

在 iOS18 中,需要提前对 sqlite3_stmt 执行 sqlite3_finalize。

解决办法

代码
- (BOOL)_dbClose {if (!_db) return YES;int  result = 0;BOOL retry = NO;BOOL stmtFinalized = NO;if (@available(iOS 18, *)) {if (_dbStmtCache) {CFIndex size = CFDictionaryGetCount(_dbStmtCache);CFTypeRef *valuesRef = (CFTypeRef *)malloc(size * sizeof(CFTypeRef));CFDictionaryGetKeysAndValues(_dbStmtCache, NULL, (const void **)valuesRef);const sqlite3_stmt **stmts = (const sqlite3_stmt **)valuesRef;for (CFIndex i = 0; i < size; i ++) {sqlite3_stmt *stmt = stmts[i];sqlite3_finalize(stmt);}free(valuesRef);CFRelease(_dbStmtCache);}} else {if (_dbStmtCache) CFRelease(_dbStmtCache);_dbStmtCache = NULL;}do {retry = NO;result = sqlite3_close(_db);if (result == SQLITE_BUSY || result == SQLITE_LOCKED) {if (!stmtFinalized) {stmtFinalized = YES;sqlite3_stmt *stmt;while ((stmt = sqlite3_next_stmt(_db, nil)) != 0) {sqlite3_finalize(stmt);retry = YES;}}} else if (result != SQLITE_OK) {if (_errorLogsEnabled) {NSLog(@"%s line:%d sqlite close failed (%d).", __FUNCTION__, __LINE__, result);}}} while (retry);_db = NULL;return YES;
}
参考

https://giters.com/ibireme/YYCache/issues/166

问题3:Xcode16正式版,addSubView crash (maskView)

报错信息

*** Assertion failure in -[TestMaskView _addSubview:positioned:relativeTo:], UIView.m:18496
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Set `maskView` (<UIView: 0x14a21ddd0; frame = (0 0; 0 0); layer = <CALayer: 0x60000314b480>>) to `nil` before adding it as a subview of <TestMaskView: 0x153e08350; frame = (0 0; 393 852); layer = <CALayer: 0x60000314b440>>'
*** First throw call stack:
(0   CoreFoundation                      0x00000001063540ec __exceptionPreprocess + 1721   libobjc.A.dylib                     0x00000001048bede8 objc_exception_throw + 722   Foundation                          0x0000000109d21aa8 _userInfoForFileAndLine + 03   UIKitCore                           0x0000000128c0151c -[UIView(Internal) _addSubview:positioned:relativeTo:] + 11244   ADClientTest                        0x0000000104609660 -[TestMaskView initWithFrame:] + 2765   ADClientTest                        0x0000000104609434 -[ViewController viewDidLoad] + 1646   UIKitCore                           0x0000000127f1e69c -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 807   UIKitCore                           0x0000000127f23238 -[UIViewController loadViewIfRequired] + 9088   UIKitCore                           0x0000000127f234e0 -[UIViewController view] + 209   UIKitCore                           0x00000001286c3a08 -[UIWindow addRootViewControllerViewIfPossible] + 13210  UIKitCore                           0x00000001286c343c -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 16811  UIKitCore                           0x00000001286c4288 -[UIWindow _setHidden:forced:] + 22812  UIKitCore                           0x00000001286d3344 -[UIWindow _mainQueue_makeKeyAndVisible] + 3613  UIKitCore                           0x000000012892dcd8 -[UIWindowScene _performDeferredInitialWindowUpdateForConnection] + 20414  UIKitCore                           0x0000000127af58f0 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 116415  UIKitCore                           0x000000012868f45c -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 80816  UIKitCore                           0x000000012868f70c -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 30417  UIKitCore                           0x000000012815ec08 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 26018  FrontBoardServices                  0x0000000113090ce4 __95-[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:]_block_invoke + 26019  FrontBoardServices                  0x00000001130910a4 -[FBSScene _callOutQueue_coalesceClientSettingsUpdates:] + 6020  FrontBoardServices                  0x0000000113090b64 -[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:] + 40821  FrontBoardServices                  0x00000001130bdd50 __93-[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:]_block_invoke.156 + 21622  FrontBoardServices                  0x000000011309d618 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 16023  FrontBoardServices                  0x00000001130bc220 -[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:] + 38824  libdispatch.dylib                   0x000000010bdea7b8 _dispatch_client_callout + 1625  libdispatch.dylib                   0x000000010bdee3bc _dispatch_block_invoke_direct + 38826  FrontBoardServices                  0x00000001130e0b58 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 4427  FrontBoardServices                  0x00000001130e0a34 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 19628  FrontBoardServices                  0x00000001130e0b8c -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 2429  CoreFoundation                      0x00000001062b8324 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 2430  CoreFoundation                      0x00000001062b826c __CFRunLoopDoSource0 + 17231  CoreFoundation                      0x00000001062b7a2c __CFRunLoopDoSources0 + 32432  CoreFoundation                      0x00000001062b20b0 __CFRunLoopRun + 78833  CoreFoundation                      0x00000001062b1960 CFRunLoopRunSpecific + 53634  GraphicsServices                    0x0000000117edfb10 GSEventRunModal + 16035  UIKitCore                           0x000000012868db40 -[UIApplication _run] + 79636  UIKitCore                           0x0000000128691d38 UIApplicationMain + 12437  ADClientTest                        0x0000000104609064 main + 14038  dyld                                0x00000001047cd410 start_sim + 2039  ???                                 0x000000010490a274 0x0 + 4371554932
)
libc++abi: terminating due to uncaught exception of type NSException
原因

iOS 18 对 UIView的maskView 增加了断言,导致如果业务代码里有同名属性可能导致触发该断言。

经测试发现:
1.自定义UIView子视图,存在同名属性maskView,会崩溃
2.自定义cell,添加到cell视图上会崩溃,添加到contentView上,则不会崩溃
3.控制器里的maskView视图属性,添加到控制器view,不会崩溃

解决办法

修改自定义视图,将自定义子组件名为maskView的视图进行重命名。

问题4:"__mh_execute_header", referenced from:

Undefined symbols for architecture arm64: "__mh_execute_header", referenced from:

报错信息

解决办法:

dladdr(&_mh_execute_header, &info); 修改为 dladdr(&_MH_EXECUTE_SYM, &info);

 参考链接:https://www.jianshu.com/p/cca4d4d8145d


http://www.ppmy.cn/embedded/118396.html

相关文章

构建现代应用的Python Serverless架构详解

构建现代应用的Python Serverless架构详解 Serverless架构是一种新兴的计算模型&#xff0c;通过消除对底层服务器的显式管理&#xff0c;大大简化了应用的开发与运维流程。在Serverless架构中&#xff0c;开发者仅需关注代码的编写与业务逻辑的实现&#xff0c;无需考虑服务器…

Qt-qmake概述

概述 qmake工具为您提供了一个面向项目的系统&#xff0c;用于管理应用程序、库和其他组件的构建过程。这种方法使您能够控制使用的源文件&#xff0c;并允许简洁地描述过程中的每个步骤&#xff0c;通常在单个文件中。qmake将每个项目文件中的信息扩展为一个Makefile&#xf…

C++之哈希 --- 哈希的应用(位图布隆过滤器)

一、位图 1.1 位图的基本概念 在如今网络交通高度发达的时代&#xff0c;网购已经成为我们日常生活中的一部分。没当双11到来&#xff0c;各大平台都会迎来一次网购的高潮。这就会让服务器短时间内获得高达几十亿上百亿的数据&#xff0c;那我们该如何去处理这海量的数据呢&am…

WPF 依赖属性改变触发响应事件

WPF 依赖属性改变触发响应事件 在书写依赖属性时&#xff0c;如果后台数据发生了变化&#xff0c;我们会发现依赖属性如果不为他设置对应的响应事件&#xff0c;他是不会做任何操作的 解决方案&#xff1a; 当我们使用 DependencyProperty.Register 函数注册依赖属性时&#xf…

【Prometheus】jmx_prometheus_javaagent监控java应用

目录 一、概述 1.1 promethues简介 1.2 JMX Exporter简介 二、监控SparkHistoryServer实现 一、概述 1.1 promethues简介 promethues采集数据的方法很多&#xff0c;常用的是通过各种exporter去主机采集&#xff0c;然后有些程序是没有相关的exporter,所以有些时候会通过脚…

企业网络安全关键:防御措施和应急响应

感谢浪浪云支持发布 浪浪云活动链接 &#xff1a;https://langlangy.cn/?i8afa52 文章目录 什么是网络安全常见的网络安全威胁病毒和恶意软件网络钓鱼拒绝服务攻击中间人攻击社会工程学 基本的网络安全措施强密码策略双因素认证安装和更新防病毒软件定期备份 高级的网络安全方…

C++:笔试题

1.什么是虚函数&#xff1f;什么是纯虚函数&#xff1f; 虚函数是类中的一个成员函数&#xff0c;使用关键字virtual在函数名前声明。 虚函数主要目的是允许子类重写父类中的同名函数&#xff0c;从而实现多态性&#xff0c;并且子函数重写的是虚函数表中的函数。 当通过父类的…

新手友好:这四大剪辑视频工具不容错过!

无论是生活日常的小确幸&#xff0c;还是旅行中的美好时光&#xff0c;亦或是专业级的影视作品创作&#xff0c;视频剪辑都是将这些碎片化的内容串联成动人故事的关键环节。今天就来给大家推荐几款好用的剪辑视频的工具&#xff01; 福昕视频剪辑 直达链接&#xff08;复制到…