Xcode15适配

一、制作图片溃散

在将色彩制作成图片时,出现了溃散,原因为传入的size为0。

+ (UIImage *)imageWithColor:(UIColor *)color withSize:(CGSize)size {
   CGRect rect = CGRectMake(0, 0, size.width, size.height);
   UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
   [color setFill];
   UIRectFill(rect);  // Fill it with your color
   UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
   UIGraphicsEndImageContext();
   return image;
}

发现UIGraphicsBeginImageContextWithOptionsiOS17被标记为过期。运用新方法批改为:

+ (UIImage *)imageWithColor:(UIColor *)color withSize:(CGSize)size {
   UIGraphicsImageRendererFormat *format = [[UIGraphicsImageRendererFormat alloc] init];
   format.opaque = NO;
   format.scale = 0.0;
   UIGraphicsImageRenderer *render = [[UIGraphicsImageRenderer alloc] initWithSize:size format:format];
   UIImage *image = [render imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
     CGRect rect = CGRectMake(0, 0, size.width, size.height);
     [color setFill];
     UIRectFill(rect);
   }];
  
   return image;
}

测验一切正常。

二、报错DT_TOOLCHAIN_DIR

编译的时候报错DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead,这需求全局(包含第三方库)都要替换哈。

解决方法,直接在Podfile中批改,如下:

post_install do |installer|
  flutter_post_install(installer) if defined?(flutter_post_install)
​
  installer.aggregate_targets.each do |target|
   target.xcconfigs.each do |variant, xcconfig|
    xcconfig_path = target.client_root + target.xcconfig_relative_path(variant)
    IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
   end
  end
​
  installer.pod_target_subprojects.flat_map { |p| p.targets }.each do |target|
​
   target.build_configurations.each do |config|
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"if config.base_configuration_reference.is_a? Xcodeproj::Project::Object::PBXFileReference
     xcconfig_path = config.base_configuration_reference.real_path
     IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
    end
   end
  end
end

批改之前是

post_install do |installer|
  flutter_post_install(installer) if defined?(flutter_post_install)
 
  installer.pod_target_subprojects.flat_map { |p| p.targets }.each do |target|
   target.build_configurations.each do |c|
    c.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    c.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
   end
  end
end

添加了其间的DT_TOOLCHAIN_DIR相关内容。批改后记住删去Pods文件夹,从头pod install.

三、报错compact unwind compressed function offset doesn't fit in 24 bits

编译时出现Assertion failed: (false && "compact unwind compressed function offset doesn't fit in 24 bits"), function operator(), file Layout.cpp, line 5758.的报错。

解决方法:在Other Linker Flags中添加**-ld_classic**.

Xcode15适配

四、个推溃散

升级到Xcode15后运转在iOS17系统没有问题,但是在iOS17以下的系统,那么就会溃散啊。溃散日志如下

* thread #12, name = 'GTSDKThread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
   frame #0: 0x0000000000000000
   frame #1: 0x00000001028a60a4 qiji`merged type metadata accessor for Swift.Array<Dispatch.DispatchWorkItemFlags> + 48
   frame #2: 0x00000001028a5930 qiji`type metadata completion function for GTSDK.NetworkChannel + 132
   frame #3: 0x00000001a68858c8 libswiftCore.dylib`swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::MetadataWaitQueue::Worker&, swift::MetadataRequest) + 468
   frame #4: 0x00000001a68742d8 libswiftCore.dylib`swift_getSingletonMetadata + 880
   frame #5: 0x000000010289d82c qiji`type metadata accessor for GTSDK.NetworkChannel + 48
   frame #6: 0x00000001a59902b4 libobjc.A.dylib`realizeClassMaybeSwiftMaybeRelock(objc_class*, locker_mixin<lockdebug::lock_mixin<objc_lock_base_t>>&, bool) + 184
   frame #7: 0x00000001a599013c libobjc.A.dylib`initializeAndMaybeRelock(objc_class*, objc_object*, locker_mixin<lockdebug::lock_mixin<objc_lock_base_t>>&, bool) + 136
   frame #8: 0x00000001a5973cbc libobjc.A.dylib`lookUpImpOrForward + 932
   frame #9: 0x00000001a596e0c4 libobjc.A.dylib`_objc_msgSend_uncached + 68
   frame #10: 0x000000010288c51c qiji`-[GXPushService initWithDelegate:] + 124
   frame #11: 0x000000010288b2a8 qiji`-[GXPushManager service] + 92
   frame #12: 0x00000001028685c4 qiji`__57-[GtSdkManager startWithAppId:appKey:appSecret:delegate:]_block_invoke_2 + 348
   frame #13: 0x00000001a6a68850 Foundation`__NSThreadPerformPerform + 264
   frame #14: 0x00000001ac779f34 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
   frame #15: 0x00000001ac78630c CoreFoundation`__CFRunLoopDoSource0 + 176
   frame #16: 0x00000001ac70a1d0 CoreFoundation`__CFRunLoopDoSources0 + 244
   frame #17: 0x00000001ac71fb8c CoreFoundation`__CFRunLoopRun + 836
   frame #18: 0x00000001ac724ec0 CoreFoundation`CFRunLoopRunSpecific + 612
   frame #19: 0x00000001a6a6f0d4 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
   frame #20: 0x000000010284a280 qiji`-[GTCThread main] + 228
   frame #21: 0x00000001a6a885a8 Foundation`__NSThread__start__ + 716
  * frame #22: 0x00000001fa7366cc libsystem_pthread.dylib`_pthread_start + 148

此现象必现,所以可以判别必定个推的问题了,直接联系了个推官方,10分钟后得到答复,是最低支持版其他问题。

解决方法:

Xcode15适配

五。Done

编译成功,运转成功,运用Xcode15提交App Store,审阅成功。

声明: 解决方法来之网络,谢谢大神的无私奉献。