模拟器运行报错
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| \# 处理 M1 芯片上不支持 模拟器 运行问题:不仅仅编译活跃的架构,反之就是 i386、x86_64、arm64 等架构都编译。 config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64" end end end
YYText YYTextAsyncLayer UIGraphicsBeginImageContext Deprecated #984
https://github.com/ibireme/YYText/issues/984
iOS 18适配问题记录(Xcode16正式版) 问题1:ADClient编译报错问题 报错信息
1 2 3 4 5 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才可以使用。
代码 1 2 3 4 5 6 7 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。
解决办法
代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 - (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) 报错信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 *** 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 + 172 1 libobjc.A.dylib 0x00000001048bede8 objc_exception_throw + 72 2 Foundation 0x0000000109d21aa8 _userInfoForFileAndLine + 0 3 UIKitCore 0x0000000128c0151c -[UIView (Internal) _addSubview:positioned:relativeTo:] + 1124 4 ADClientTest 0x0000000104609660 -[TestMaskView initWithFrame:] + 276 5 ADClientTest 0x0000000104609434 -[ViewController viewDidLoad] + 164 6 UIKitCore 0x0000000127f1e69c -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 80 7 UIKitCore 0x0000000127f23238 -[UIViewController loadViewIfRequired] + 908 8 UIKitCore 0x0000000127f234e0 -[UIViewController view] + 20 9 UIKitCore 0x00000001286c3a08 -[UIWindow addRootViewControllerViewIfPossible] + 132 10 UIKitCore 0x00000001286c343c -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 168 11 UIKitCore 0x00000001286c4288 -[UIWindow _setHidden:forced:] + 228 12 UIKitCore 0x00000001286d3344 -[UIWindow _mainQueue_makeKeyAndVisible] + 36 13 UIKitCore 0x000000012892dcd8 -[UIWindowScene _performDeferredInitialWindowUpdateForConnection] + 204 14 UIKitCore 0x0000000127af58f0 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1164 15 UIKitCore 0x000000012868f45c -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 808 16 UIKitCore 0x000000012868f70c -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 304 17 UIKitCore 0x000000012815ec08 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 260 18 FrontBoardServices 0x0000000113090ce4 __95-[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:]_block_invoke + 260 19 FrontBoardServices 0x00000001130910a4 -[FBSScene _callOutQueue_coalesceClientSettingsUpdates:] + 60 20 FrontBoardServices 0x0000000113090b64 -[FBSScene _callOutQueue_didCreateWithTransitionContext:alternativeCreationCallout:completion:] + 408 21 FrontBoardServices 0x00000001130bdd50 __93-[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:]_block_invoke.156 + 216 22 FrontBoardServices 0x000000011309d618 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 160 23 FrontBoardServices 0x00000001130bc220 -[FBSWorkspaceScenesClient _callOutQueue_sendDidCreateForScene:transitionContext:completion:] + 388 24 libdispatch.dylib 0x000000010bdea7b8 _dispatch_client_callout + 16 25 libdispatch.dylib 0x000000010bdee3bc _dispatch_block_invoke_direct + 388 26 FrontBoardServices 0x00000001130e0b58 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 44 27 FrontBoardServices 0x00000001130e0a34 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 196 28 FrontBoardServices 0x00000001130e0b8c -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 24 29 CoreFoundation 0x00000001062b8324 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 30 CoreFoundation 0x00000001062b826c __CFRunLoopDoSource0 + 172 31 CoreFoundation 0x00000001062b7a2c __CFRunLoopDoSources0 + 324 32 CoreFoundation 0x00000001062b20b0 __CFRunLoopRun + 788 33 CoreFoundation 0x00000001062b1960 CFRunLoopRunSpecific + 536 34 GraphicsServices 0x0000000117edfb10 GSEventRunModal + 160 35 UIKitCore 0x000000012868db40 -[UIApplication _run] + 796 36 UIKitCore 0x0000000128691d38 UIApplicationMain + 124 37 ADClientTest 0x0000000104609064 main + 140 38 dyld 0x00000001047cd410 start_sim + 20 39 ??? 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的视图进行重命名。
参考 https://github.com/Tencent/QMUI_iOS/issues/1557