常见问题及解决方案

使用cocoapods导入第三方库找不到头文件

1.选择target(就是左边你的工程target)—— BuildSettings —— search Paths 下的 User Header Search Paths

网图

Block中造成循环引用警告

1.在Block外边声明弱引用,例如要引用UIViewController类型的self
__block UIViewController *weakSelf = self;
2.Block里面使用
[weakSelf 需要执行的方法];

OC设置状态栏颜色为白色

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

使用第三方键盘IQkeyboard键盘弹出,导航条位置上移导致消失问题解决

1.在当前控制器重写下里面的方法

-(void)loadView
{
    UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.view = scrollview;
}

2.监听键盘出现和消失来更改输入框的位置(这里是bottomView)

rac_addObserverForName方法是封装的方法,可以用系统的

 [[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIKeyboardWillShowNotification object:nil] subscribeNext:^(NSNotification * x) {
        
        NSDictionary* info = [x userInfo];
        CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
        
        [UIView animateWithDuration:0.25 animations:^{
            self.bottomView.frame = CGRectMake(0, kScreenHeigth - kbSize.height - 45, kScreenWidth, 45);
        }];
    }];
    
    [[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIKeyboardDidHideNotification object:nil] subscribeNext:^(NSNotification * x) {
        
        [UIView animateWithDuration:0.3 animations:^{
            self.bottomView.frame = CGRectMake(0, kScreenHeigth - 45, kScreenWidth, 45);
        }];
    }];

上传时报错:Error ITMS-90635 - Invalid Mach-O in bundle - submitting to App store

CocoPods导入的框架bitCode不一致导致的,解决方案是在Podfile后面加上

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

然后 pod install --no-repo-update

如果 pod install 报错,报错如下:
[!] Invalid Podfile file: syntax error, unexpected tCONSTANT, expecting end-of-input

...ig.build_settings['OTHER_CFLAGS'] || ['$(inherited)']

... ^. Updating CocoaPods might fix the issue.

那就需要先删除之前Podfile里面加的post_install do |installer|...... ,然后pod update, 在update之前记得给第三方框架指定一个版本(某些框架最新的可能在你项目无法使用,出现bug),升级后再次执行上面的步骤

podfile示例:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'AutoPartsStore' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

pod 'AFNetworking', '~>2.4.0'
pod 'Alamofire', '~>3.2.1'
pod 'YYModel', '~>1.0.4'
pod 'Kingfisher', '~>2.1.0'
pod 'MJRefresh', '~>3.1.12'
pod 'SnapKit','~>0.22.0'
pod 'Reachability', '~>3.2'
pod 'MBProgressHUD', '~>1.0.0'

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ENABLE_BITCODE'] = 'NO'
        end
    end
end

  # Pods for AutoPartsStore

end

M系列芯片的Mac运行某些命令报错

在命令前添加arch -x86_64

arch -x86_64是一个命令行指令,用于在macOS系统中执行x86_64架构的可执行文件。该指令会启动一个新的shell,使其在x86_64架构下运行,并在该shell中执行后续命令。

在macOS系统中,有两种主要的处理器架构:x86_64和arm64。x86_64是用于Intel和AMD处理器的架构,而arm64是用于Apple设备(如iPhone和iPad)的架构。大多数macOS应用程序都是为x86_64构建的,但随着Apple M1芯片的发布,很多新的应用程序开始为arm64构建。

使用arch -x86_64指令可以在运行arm64的macOS系统上执行x86_64可执行文件,确保这些应用程序不会在新的M1 Mac上出现问题,这对开发者和用户来说都是很方便的。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容