当前位置: 首页 > 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

http://www.lryc.cn/news/446903.html

相关文章:

  • 加密解密的艺术:探索Java中的DES算法
  • jQuery——层次选择器
  • MySQL常见面试总结
  • 记录一次学习--委派攻击学习
  • 前端列表数据太多导致页面卡顿就这么处理
  • 机器学习_神经网络_深度学习
  • MT6765/MT6762(R/D/M)/MT6761(MT8766)安卓核心板参数比较_MTK联发科4G智能模块
  • TikTok五分钟开户快速步骤流程!
  • BFS 解决拓扑排序 , 课程表 , 课程表 II , 火星词典
  • web安全攻防渗透测试实战指南_web安全攻防渗透测试实战指南,零基础入门到精通,收藏这一篇就够了
  • 大模型如何赋能智慧城市新发展?
  • 随记——机器学习
  • 【在Linux世界中追寻伟大的One Piece】进程间通信
  • 多路复用IO
  • C++ prime plus-7-編程練習
  • 计算1 / 1 - 1 / 2 + 1 / 3 - 1 / 4 + 1 / 5 …… + 1 / 99 - 1 / 100 的值,打印出结果
  • Linux本地服务器搭建开源监控服务Uptime Kuma与远程监控实战教程
  • JS 历史简介
  • 爬虫逆向学习(七):补环境动态生成某数四代后缀MmEwMD
  • 光伏电站并网验收需要注意什么细节
  • 页面禁用鼠标右键属于反爬虫措施吗 ?
  • 视频理解大模型最新进展
  • cocos creator 使用 protobuf 的步骤与注意事项
  • mac访达查找文件目录
  • 【数据结构】点分治 点分树
  • K8s Calico替换为Cilium,以及安装Cilium过程(鲁莽版)
  • 背景图鼠标放上去切换图片过渡效果
  • 【Linux】当前进展
  • 阿里云云效多个ssh密钥对配置
  • 前后端跨域问题及其在ThinkPHP中的解决方案