Xcode16 & iOS18 编译问题适配

打印 上一主题 下一主题

主题 1000|帖子 1000|积分 3000

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
问题1:ADClient编译报错问题

报错信息


  1. Undefined symbols for architecture arm64:
  2.   "_OBJC_CLASS_$_ADClient", referenced from:
  3.        in ViewController.o
  4. ld: symbol(s) not found for architecture arm64
  5. 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才可以使用。
代码

  1. if (@available(ios 14.3, *)) {
  2.         NSError *error;
  3.         NSString *token = [AAAttribution attributionTokenWithError:&error];
  4.         if (token != nil) {
  5.             ...
  6.         }
  7. }
复制代码
参考

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

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

报错信息


缘故原由

在 iOS18 中,需要提前对 sqlite3_stmt 实行 sqlite3_finalize。
办理办法


代码

  1. - (BOOL)_dbClose {
  2.     if (!_db) return YES;
  3.    
  4.     int  result = 0;
  5.     BOOL retry = NO;
  6.     BOOL stmtFinalized = NO;
  7.    
  8.     if (@available(iOS 18, *)) {
  9.         if (_dbStmtCache) {
  10.             CFIndex size = CFDictionaryGetCount(_dbStmtCache);
  11.             CFTypeRef *valuesRef = (CFTypeRef *)malloc(size * sizeof(CFTypeRef));
  12.             CFDictionaryGetKeysAndValues(_dbStmtCache, NULL, (const void **)valuesRef);
  13.             const sqlite3_stmt **stmts = (const sqlite3_stmt **)valuesRef;
  14.             for (CFIndex i = 0; i < size; i ++) {
  15.                 sqlite3_stmt *stmt = stmts[i];
  16.                 sqlite3_finalize(stmt);
  17.             }
  18.             free(valuesRef);
  19.             CFRelease(_dbStmtCache);
  20.         }
  21.     } else {
  22.         if (_dbStmtCache) CFRelease(_dbStmtCache);
  23.         _dbStmtCache = NULL;
  24.     }
  25.    
  26.     do {
  27.         retry = NO;
  28.         result = sqlite3_close(_db);
  29.         if (result == SQLITE_BUSY || result == SQLITE_LOCKED) {
  30.             if (!stmtFinalized) {
  31.                 stmtFinalized = YES;
  32.                 sqlite3_stmt *stmt;
  33.                 while ((stmt = sqlite3_next_stmt(_db, nil)) != 0) {
  34.                     sqlite3_finalize(stmt);
  35.                     retry = YES;
  36.                 }
  37.             }
  38.         } else if (result != SQLITE_OK) {
  39.             if (_errorLogsEnabled) {
  40.                 NSLog(@"%s line:%d sqlite close failed (%d).", __FUNCTION__, __LINE__, result);
  41.             }
  42.         }
  43.     } while (retry);
  44.     _db = NULL;
  45.     return YES;
  46. }
复制代码
参考

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


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

报错信息


  1. *** Assertion failure in -[TestMaskView _addSubview:positioned:relativeTo:], UIView.m:18496
  2. *** 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>>'
  3. *** First throw call stack:
  4. (
  5.     0   CoreFoundation                      0x00000001063540ec __exceptionPreprocess + 172
  6.     1   libobjc.A.dylib                     0x00000001048bede8 objc_exception_throw + 72
  7.     2   Foundation                          0x0000000109d21aa8 _userInfoForFileAndLine + 0
  8.     3   UIKitCore                           0x0000000128c0151c -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1124
  9.     4   ADClientTest                        0x0000000104609660 -[TestMaskView initWithFrame:] + 276
  10.     5   ADClientTest                        0x0000000104609434 -[ViewController viewDidLoad] + 164
  11.     6   UIKitCore                           0x0000000127f1e69c -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 80
  12.     7   UIKitCore                           0x0000000127f23238 -[UIViewController loadViewIfRequired] + 908
  13.     8   UIKitCore                           0x0000000127f234e0 -[UIViewController view] + 20
  14.     9   UIKitCore                           0x00000001286c3a08 -[UIWindow addRootViewControllerViewIfPossible] + 132
  15.     10  UIKitCore                           0x00000001286c343c -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 168
  16.     11  UIKitCore                           0x00000001286c4288 -[UIWindow _setHidden:forced:] + 228
  17.     12  UIKitCore                           0x00000001286d3344 -[UIWindow _mainQueue_makeKeyAndVisible] + 36
  18.     13  UIKitCore                           0x000000012892dcd8 -[UIWindowScene _performDeferredInitialWindowUpdateForConnection] + 204
  19.     14  UIKitCore                           0x0000000127af58f0 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1164
  20.     15  UIKitCore                           0x000000012868f45c -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 808
  21.     16  UIKitCore                           0x000000012868f70c -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 304
  22.     17  UIKitCore                           0x000000012815ec08 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 260
  23.     18  FrontBoardServices                  0x0000000113090ce4 __95-[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:]_block_invoke + 260
  24.     19  FrontBoardServices                  0x00000001130910a4 -[FBSScene _callOutQueue_coalesceClientSettingsUpdates:] + 60
  25.     20  FrontBoardServices                  0x0000000113090b64 -[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:] + 408
  26.     21  FrontBoardServices                  0x00000001130bdd50 __93-[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:]_block_invoke.156 + 216
  27.     22  FrontBoardServices                  0x000000011309d618 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 160
  28.     23  FrontBoardServices                  0x00000001130bc220 -[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:] + 388
  29.     24  libdispatch.dylib                   0x000000010bdea7b8 _dispatch_client_callout + 16
  30.     25  libdispatch.dylib                   0x000000010bdee3bc _dispatch_block_invoke_direct + 388
  31.     26  FrontBoardServices                  0x00000001130e0b58 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 44
  32.     27  FrontBoardServices                  0x00000001130e0a34 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 196
  33.     28  FrontBoardServices                  0x00000001130e0b8c -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 24
  34.     29  CoreFoundation                      0x00000001062b8324 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
  35.     30  CoreFoundation                      0x00000001062b826c __CFRunLoopDoSource0 + 172
  36.     31  CoreFoundation                      0x00000001062b7a2c __CFRunLoopDoSources0 + 324
  37.     32  CoreFoundation                      0x00000001062b20b0 __CFRunLoopRun + 788
  38.     33  CoreFoundation                      0x00000001062b1960 CFRunLoopRunSpecific + 536
  39.     34  GraphicsServices                    0x0000000117edfb10 GSEventRunModal + 160
  40.     35  UIKitCore                           0x000000012868db40 -[UIApplication _run] + 796
  41.     36  UIKitCore                           0x0000000128691d38 UIApplicationMain + 124
  42.     37  ADClientTest                        0x0000000104609064 main + 140
  43.     38  dyld                                0x00000001047cd410 start_sim + 20
  44.     39  ???                                 0x000000010490a274 0x0 + 4371554932
  45. )
  46. 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

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

不到断气不罢休

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表