当前位置: 首页 > news >正文

Xcode16 iOS18 编译问题适配

问题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

相关文章:

  • Vue3+Element-UI Plus登录静态页
  • Vue极简入门
  • 【达梦数据库】存储过程统计模式下表信息-SQL改写
  • 微服务架构拆分策略与实践
  • 前后端分离集成CAS单点登录
  • Redis配置文件详解(上)
  • 【C++】——vector深度剖析模拟实现
  • 命名导出和默认导出的用法区别
  • RabbitMQ08_保证消息可靠性
  • 2、在LVGL模拟器中了解部件的基础属性
  • 智慧城市主要运营模式分析
  • 【后端开发】JavaEE初阶——计算机是如何工作的???
  • 常见的TTL,RS232,RS485,IIC,SPI,UART之间的联系和区别
  • YOLOv8 Flask整合问题
  • 什么是Agent智能体?
  • 自己简单写的 事件订阅机制
  • 【许晓笛】 EOS 智能合约案例解析(3)
  • Angular 2 DI - IoC DI - 1
  • JS笔记四:作用域、变量(函数)提升
  • JS实现简单的MVC模式开发小游戏
  • js数组之filter
  • magento 货币换算
  • nodejs实现webservice问题总结
  • Rancher-k8s加速安装文档
  • Redis 中的布隆过滤器
  • Terraform入门 - 1. 安装Terraform
  • underscore源码剖析之整体架构
  • 阿里云购买磁盘后挂载
  • 闭包--闭包之tab栏切换(四)
  • 基于webpack 的 vue 多页架构
  • 技术胖1-4季视频复习— (看视频笔记)
  • 目录与文件属性:编写ls
  • 什么软件可以剪辑音乐?
  • 实战|智能家居行业移动应用性能分析
  • 学习笔记DL002:AI、机器学习、表示学习、深度学习,第一次大衰退
  • No resource identifier found for attribute,RxJava之zip操作符
  • ​LeetCode解法汇总1410. HTML 实体解析器
  • ​MPV,汽车产品里一个特殊品类的进化过程
  • #、%和$符号在OGNL表达式中经常出现
  • #FPGA(基础知识)
  • #stm32驱动外设模块总结w5500模块
  • (13)[Xamarin.Android] 不同分辨率下的图片使用概论
  • (Spark3.2.0)Spark SQL 初探: 使用大数据分析2000万KF数据
  • (非本人原创)史记·柴静列传(r4笔记第65天)
  • (附源码)springboot教学评价 毕业设计 641310
  • (经验分享)作为一名普通本科计算机专业学生,我大学四年到底走了多少弯路
  • (原创)攻击方式学习之(4) - 拒绝服务(DOS/DDOS/DRDOS)
  • *2 echo、printf、mkdir命令的应用
  • .mat 文件的加载与创建 矩阵变图像? ∈ Matlab 使用笔记
  • .NET C# 配置 Options
  • .net core webapi 大文件上传到wwwroot文件夹
  • .net core 调用c dll_用C++生成一个简单的DLL文件VS2008
  • .NET 解决重复提交问题
  • .Net各种迷惑命名解释
  • .NET中的Event与Delegates,从Publisher到Subscriber的衔接!