问题:
iOS12.2以下的系统会崩溃,运行报错:
dyld: Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib
解决:
Xcode14.0会报错,14.1以上版本已修复,如果使用的是Xcode14.0则进行以下设置:
如果是工程报错,
在build phase -> Link Binary With Libraries中添加libswiftCoreGraphics.dylib
或者
在Build Settings -> OtherLinkFlags 添加: -Wl,-weak-lswiftCoreGraphics
如果是pod引入的库报错,
在pod中找到对应的target -> General -> Link Binary With Libraries中添加:libswiftCoreGraphics.tbd
或者
Build Settings -> OtherLinkFlags 添加: -Wl,-weak-lswiftCoreGraphics
或者
将库改成手动引入。
来源(https://www.jianshu.com/p/2911d5ead17a)
问题:
部分SDK pod下来后需要指定证书签名,默认为none,会导致编译失败
解决:
在Podfile文件中添加以下方法,二选一,然后终端执行pod install
#解决方案1
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO'
end
end
end
end
#解决方案2
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["DEVELOPMENT_TEAM"] = "Your Team ID"
end
end
end
end
问题:
项目无法运行到iOS16设备上,无法选中设备,提示developer mode disable.
解决:
手机升级到iOS16后,设置中多了开发者管理开关,默认是关闭的,前往设置->隐私与安全性->开发者模式,点击开启即可,如还不行,则重启手机。
问题:
横竖屏切换失败
解决:
if (@available(iOS 16.0, *)) {
[vc setNeedsUpdateOfSupportedInterfaceOrientations];
UIWindowScene *windowScene = (UIWindowScene *)[[[UIApplication sharedApplication] connectedScenes] allObjects].firstObject;
UIWindowSceneGeometryPreferencesIOS *perference = [[UIWindowSceneGeometryPreferencesIOS alloc] init];
perference.interfaceOrientations = UIInterfaceOrientationMaskLandscapeRight;
[windowScene requestGeometryUpdateWithPreferences:perference errorHandler:^(NSError * _Nonnull error) {
RjLog(@"强制%@错误:%@", isLaunchScreen ? @"横屏" : @"竖屏", error);
[AnalyticsHelper logEventWithName:@"ChangeOrientationFailed"];
}];
}
以下是使用Xcode14以下版本的写法:
if (@available(iOS 16.0, *)) {
void (^errorHandler)(NSError *error) = ^(NSError *error) {
RjLog(@"强制%@错误:%@", isLaunchScreen ? @"横屏" : @"竖屏", error);
[AnalyticsHelper logEventWithName:@"ChangeOrientationFailed"];
};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
SEL supportedInterfaceSelector = NSSelectorFromString(@"setNeedsUpdateOfSupportedInterfaceOrientations");
[vc performSelector:supportedInterfaceSelector];
NSArray *array = [[UIApplication sharedApplication].connectedScenes allObjects];
UIWindowScene *scene = (UIWindowScene *)[array firstObject];
Class UIWindowSceneGeometryPreferencesIOS = NSClassFromString(@"UIWindowSceneGeometryPreferencesIOS");
if (UIWindowSceneGeometryPreferencesIOS) {
SEL initWithInterfaceOrientationsSelector = NSSelectorFromString(@"initWithInterfaceOrientations:");
UIInterfaceOrientationMask orientation = UIInterfaceOrientationMaskLandscapeRight;
//
id geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] performSelector:initWithInterfaceOrientationsSelector withObject:@(orientation)];
if (geometryPreferences) {
SEL requestGeometryUpdateWithPreferencesSelector = NSSelectorFromString(@"requestGeometryUpdateWithPreferences:errorHandler:");
if ([scene respondsToSelector:requestGeometryUpdateWithPreferencesSelector]) {
[scene performSelector:requestGeometryUpdateWithPreferencesSelector withObject:geometryPreferences withObject:errorHandler];
}
}
}
#pragma clang diagnostic pop
}
网友评论