iOS 开发 Xcode 8.1创建新项目的配置–详解
1.创建项目内容
2.TARGETS–>General设置
// 图标,启动图片,拖入图片资源
//名称,版本,支持的方向,系统的版本
info.plist
Bundle display name;
Bundle versions string , short;
Supported interface orientations;(三个方向)
项目-TARGETS-General - 8.0以上
3…pch文件设置
//pch文件
创建:iOS-Other-PCH.file //直接拖入已写好的
配置:项目-TARGETS-Build Setting - All - Prefix - Prefix Header - 双击添加相对路径 ./项目名称/pch文件名.pch;
//
// PrefixHeader.pch
//
// Created by Apple on 14/6/13.
// Copyright © 2014年 zhouyu. All rights reserved.
//
#ifndef PrefixHeader_pch
#define PrefixHeader_pch
// 如果当前是OC的代码就用下面的这些东西
// 主要是屏蔽c文件
# ifdef __OBJC__
#define JDGUITextFieldHeight 40.0
#define KUIScreenSize [UIScreen mainScreen].bounds.size
#define KUIScreenWidth [UIScreen mainScreen].bounds.size.width
#define KUIScreenHeight [UIScreen mainScreen].bounds.size.height
#define BackGroundColor(R,G,B) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1.0]
// 自定义输入日志 Log
#ifdef DEBUG // 如果当前是开发 调试阶段可以用ZYLog输入
#define ZYLog(...) NSLog(__VA_ARGS__)
#else // 发布后就不能输入了
#define ZYLog(...)
#endif
#endif
#endif /* PrefixHeader_pch */
4.设置图片资源
删除LaunchScreen.storyboard
设置启动图标和APP图片
5.隐私设置
包括访问 相册/相机/麦克风/通讯录 iOS 10不设置,使用相关功能APP会发生崩溃
cameraDescription //相机
photoLibraryDescription //相册
microphoneDescription //麦克风
contactsDescription //通讯录
locationWhenInUseDescription //定位
mediaLibraryDescription //媒体库
siriDescription //siri语音
calendarsDescription //日历
还有蓝牙,日历,健康,地图定位等等
6.纯代码搭建界面
删除不必要文件
AppDelegate
#import "AppDelegate.h"
#import "TabBarController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
// 2.设置为窗口的跟控制器
// if ([self isNewVersion]) {
//
// self.window.rootViewController = [[GuideController alloc] init];
// } else {
self.window.rootViewController = [[TabBarController alloc] init];
// }
[self.window makeKeyAndVisible];
return YES;
}
根据功能搭建架构
7.cocoapods集成第三方库
打开终端cd 切换到当前项目路径
pod init
打开Podfile文件修改内容
platform :ios, ‘8.0’
#项目名称(英文名称),替换成项目名称
target '项目名称(英文名称)' do
pod 'Masonry'
pod 'AFNetworking'
pod 'SDWebImage'
pod 'SVProgressHUD'
pod 'Bugly'
end
//安装第三方库
pod install
初次安装比较费时
安装成功
8.项目.xcworkspace文件生成不出来的情况
解决方案:运行 gem install cocoapods 更新cocoapods工具,然后再执行pod install
xxxxx$ gem install cocoapods
Fetching: nap-1.0.0.gem (100%)
Successfully installed nap-1.0.0
Fetching: molinillo-0.4.0.gem (100%)
Successfully installed molinillo-0.4.0
Fetching: cocoapods-trunk-0.6.4.gem (100%)
Successfully installed cocoapods-trunk-0.6.4
Fetching: cocoapods-try-0.5.1.gem (100%)
Successfully installed cocoapods-try-0.5.1
Fetching: cocoapods-stats-0.6.2.gem (100%)
Successfully installed cocoapods-stats-0.6.2
Fetching: cocoapods-search-0.1.0.gem (100%)
Successfully installed cocoapods-search-0.1.0
Fetching: cocoapods-downloader-0.9.3.gem (100%)
Successfully installed cocoapods-downloader-0.9.3
Fetching: cocoapods-core-0.39.0.gem (100%)
Successfully installed cocoapods-core-0.39.0
Fetching: cocoapods-0.39.0.gem (100%)
Successfully installed cocoapods-0.39.0
Parsing documentation for nap-1.0.0
Installing ri documentation for nap-1.0.0
Parsing documentation for molinillo-0.4.0
Installing ri documentation for molinillo-0.4.0
Parsing documentation for cocoapods-trunk-0.6.4
Installing ri documentation for cocoapods-trunk-0.6.4
Parsing documentation for cocoapods-try-0.5.1
Installing ri documentation for cocoapods-try-0.5.1
Parsing documentation for cocoapods-stats-0.6.2
Installing ri documentation for cocoapods-stats-0.6.2
Parsing documentation for cocoapods-search-0.1.0
Installing ri documentation for cocoapods-search-0.1.0
Parsing documentation for cocoapods-downloader-0.9.3
Installing ri documentation for cocoapods-downloader-0.9.3
Parsing documentation for cocoapods-core-0.39.0
Installing ri documentation for cocoapods-core-0.39.0
Parsing documentation for cocoapods-0.39.0
Installing ri documentation for cocoapods-0.39.0
9 gems installed
xxxxx$ pod install
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.5.4)
Installing DACircularProgress (2.3.1)
Installing FMDB (2.5)
Installing GCJSONKit (1.5.0)
Installing IQKeyboardManager (3.2.0.3)
Installing MBProgressHUD (0.9.1)
Installing MWPhotoBrowser (1.4.1)
Installing MarqueeLabel (2.0.10)
Installing NJKScrollFullScreen (0.2.6)
Installing PSTCollectionView (1.2.3)
Installing SDWebImage (3.7.3)
Installing SSKeychain (1.2.3)
Installing TOWebViewController (2.0.19)
Installing TTTAttributedLabel (1.10.1)
Installing UICountingLabel (1.1.0)
Installing UMeng (2.2.1)
Installing UMengSocial (4.3)
Installing XYPieChart (0.2)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `xxx.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 14 dependencies from the Podfile and 18
total pods installed.
xxxxx$