从0-1创建oc项目

2020-07-08  本文已影响0人  青菜白玉堂

一、创建项目

截屏2020-07-08下午5.08.52.png

二、文件名设置

截屏2020-07-08下午5.09.18.png

Product Name:软件名称、产品名称、项目名称
Organization Name:公司名称、组织名称
Organization Identifier:公司的唯一标识
一般是公司域名的反写,比如com.GrandSu
Bundle Identifier:软件的唯一标识
一般是Organization Identifier + Product Name

三、项目名设置

截屏2020-07-08下午5.09.52.png

Version(应用程序发布版本号)
Build(应用程序内部标示)

Xcode编译时候自动增加build号码
https://www.jianshu.com/p/f9c18bd0fda2

四、iocn设置

截屏2020-07-08下午4.59.04.png

五、LaunchImage设置

1.设置LaunchImage图片

截屏2020-07-08下午4.58.51.png

2.设置启动选项,Screen File,置为空

截屏2020-07-08下午4.56.25.png

3.xCode11没有Launch Images Source选项怎样设置LaunchImage?

在工程 targets--Build Settings 搜索
Name,选择all 添加启动页图片文件夹名字即可
截屏2020-07-08下午5.02.40.png

六、创建cocopods

cd 到项目所在目录

touch Podfile 创建文件
vim Podfile 编辑文件

在终端输入vim Podfile,然后输入i,进入编辑模式

低版本的cocoa pods在编写Podfile文件时这样写就可以了

platform :iOS, '8.0'

pod 'AFNetworking'

高版本的cocoa pods在编写Podfile文件必须这样写

platform :ios, '8.0'

target "targetName" do

pod 'AFNetworking'

end

结束之后,按esc,然后再按:,最后输入wq表示已将添加的内容进行修改保存

pod install 安装第三方库

七、Xcode11之后的SceneDelegate

如何删除SceneDelegate?
Xcode11之后新创建的工程会多出两个文件SceneDelegate。那么我们如何让它变回之前的那样的工程呢。

1.将这两个文件删除。会报错

There is no scene delegate set. A scene delegate class must be specified to use a main storyboard file.

2.将Info.plist -> Open As -> Source Code将这部分删除。

<key>UIApplicationSceneManifest</key>
    <dict>
        <key>UIApplicationSupportsMultipleScenes</key>
        <false/>
        <key>UISceneConfigurations</key>
        <dict>
            <key>UIWindowSceneSessionRoleApplication</key>
            <array>
                <dict>
                    <key>UISceneConfigurationName</key>
                    <string>Default Configuration</string>
                    <key>UISceneDelegateClassName</key>
                    <string>SceneDelegate</string>
                    <key>UISceneStoryboardFile</key>
                    <string>Main</string>
                </dict>
            </array>
        </dict>
    </dict>

3.将AppDelegate.m中的UISceneSession lifecycle注释掉或者删掉。

4.在didFinishLaunchingWithOptions中加入UIWindow。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];

    self.window.rootViewController = [[ViewController alloc] init];;
    
    [self.window makeKeyAndVisible];
    return YES;
}

至此,项目已经建立完成,后面在此基础上继续添加。

上一篇 下一篇

猜你喜欢

热点阅读