Xcode16 iOS18 编译问题适配

news/2024/9/29 0:04:55/

问题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/news/1531037.html

相关文章

Dash稳定版更新

大家好&#xff0c;今天要和大家聊聊一个开发Python网页应用的超级神器——Dash 2.18.1稳定版本正式发布啦&#xff01;此次更新&#xff0c;针对2.18.0版本的问题进行了修复和优化&#xff0c;为我们带来了更为稳定、强大的开发体验。 Dash是什么&#xff1f; Dash是一款基于P…

【2024】前端学习笔记9-内部样式表-外部导入样式表-类选择器

学习笔记 内部样式表外部导入样式表类选择器&#xff1a;class 内部样式表 内部样式表是将 CSS 样式规则写在 HTML 文档内部。通过<style>标签在 HTML 文件的<head>部分定义样式。 简单示例&#xff1a; <!DOCTYPE html><html><head><style…

react hooks--useCallback

概述 useCallback缓存的是一个函数&#xff0c;主要用于性能优化!!! 基本用法 如何进行性能的优化呢&#xff1f; useCallback会返回一个函数的 memoized&#xff08;记忆的&#xff09; 值&#xff1b;在依赖不变的情况下&#xff0c;多次定义的时候&#xff0c;返回的值是…

暴雨讲堂:算力高速互联催化超节点开启AI新篇章

在2024中国国际北京通信展期间&#xff0c;暴雨副总裁孙辉介绍了暴雨信息在超节点方案的最新突破&#xff0c;彰显了暴雨信息在算力和网络技术上的强大创新能力。 随着人工智能技术的飞速发展&#xff0c;AI大模型的参数规模正以超越摩尔定律的速度急剧扩张。在此背景下&#…

嵌入式开发中学习C++的用处?

这个问题一直有同学在问&#xff0c;其实从我的角度是一定是需要学的&#xff0c;最直接的就是你面试大厂的嵌入式岗位或者相关岗位&#xff0c;最后一定会问c&#xff0c;而很多人是不会的&#xff0c;这就是最大的用处&#xff0c;至于从技术角度考量倒是其次&#xff0c;因为…

828华为云征文|使用Flexus X实例安装宝塔面板教学

目录 一、Flexus X实例简介 1.1 概述 1.2 产品规格 二、切换操作系统 2.1 Huawei Cloud EulerOS 2.0 标准版 2.2 切换镜像 三、部署宝塔面板 3.1 安装宝塔面板 3.2 放通安全组规则 3.3 登录宝塔面板 四、使用感受 4.1 柔性算力随心配 4.2 一直加速一直快 4.3 越用…

Unity 设计模式 之 结构型模式 -【装饰者模式】【外观模式】【享元模式】【代理模式】

Unity 设计模式 之 结构型模式 -【装饰者模式】【外观模式】【享元模式】【代理模式】 目录 Unity 设计模式 之 结构型模式 -【装饰者模式】【外观模式】【享元模式】【代理模式】 一、简单介绍 二、装饰者模式&#xff08;Decorator Pattern&#xff09; 1、什么时候使用装…

Java 编码系列:线程基础与最佳实践

引言 在多任务处理和并发编程中&#xff0c;线程是不可或缺的一部分。Java 提供了丰富的线程管理和并发控制机制&#xff0c;使得开发者可以轻松地实现多线程应用。本文将深入探讨 Java 线程的基础知识&#xff0c;包括 Thread 类、Runnable 接口、Callable 接口以及线程的生命…