常见问题及解决方案

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

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

常见问题及解决方案_第1张图片

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

你可能感兴趣的:(常见问题及解决方案)