豪翔天下

Change My World by Program

0%

Xcode / iOS开发手册

Xcode常用操作

模拟器打开keyboard键盘

  • 默认是不会弹出键盘的,直接用电脑的键盘进行输入,但是有时候想要调试一下键盘弹出的效果,可以点击顶部菜单I/O -> Keyboard -> Toggle Software Keyboard

Apple设计资源

图标

  • App Icon Generator: iOS或者android各种尺寸图标一键生成,生成后直接拖到xcode即可

App需要提供图标的规格为40/588/60/80/87/120/160/180/1024,另外,如果最好是将png图片转换为jpg,因为默认会把png不存在的地方背景设置为黑色。准备好图标素材以后,直接在xcode里面的Images.xcassets将图标拖入即可。

App 上架流程

  1. 注册开发者账号
  2. App Store Connect新建一个APP
  3. 从Xcode上传APP至App Store Connect
    1. 下载P12文件(申请发布(Distribution)证书)
    2. 导入P12文件(我操作的时候是别人直接发给我的,所以这里就没记录步骤了,应该可以参考这里),有一点需要注意的时候,双击P12文件安装成功后,还需要在keychain里点击其private key,修改Access Control,需要修改配置Allow all applications to access this item,否则下面在上传的时候会提示missing private key或者让你无限输入电脑用户名密码的问题
    3. 点击Product->Archive,完成后会自动弹出一个对话框(当然,这个对话框也可以通过Window->Organizer打开,要选择对应的APP)
    4. 选择Distribute App,然后选择App Store Connect,再Upload,一直下一步应该就可以了。(如果打包能成功,但是上传却说认证失败,可能是网络问题)
    5. 上传完成后可以在App Store Connect后台的TestFlight看到刚才的build了,这时候可以去添加测试用户,点击左侧菜单App Store Connect User进行添加,添加方式见页面提示即可,很简单,添加完成后会发送邮件给用户,里面有个兑换码,在ios的testflightapp上点击redeem输入兑换码即可下载,如果下载时提示the app couldn't be installed because testflight isn't available,那就等大概五分钟试试

App 迁移transfer

删除APP

  • 如果删除为提交过的app,那么它仍然会出现在列表中,非常烦,只能等半年后她自己清理了

Cocoapods/pod

  • 升级pod

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    pod --version	# 查看pod版本
    sudo gem install cocoapods # 升级版本

    # 清理并重新安装以来
    rm -rf ~/Library/Caches/CocoaPods;
    rm -rf Pods;
    rm -rf ~/Library/Developer/Xcode/DerivedData/*;
    pod deintegrate;
    pod setup;
    pod install;

TroubleShooting

  • **Signing for “xxx” requires a development team. Select a development team in the project editor.**解决方法: 点击项目名->targets->General->Signing,选择自己的Team,选择后重新构建,如果仍然出现该错误,那么可以重启一下xcode或者更新一下xcode多次尝试。

  • **打包archive的时候签名报错XXX is automatically signed for development, but a conflicting code signing identity iPhone Distribution has been manually specified. Set the code signing identity value to “Apple Development” in the build settings editor, or switch to manual signing in the Signing & Capabilities editor.**:需要去PROJECT -> BUILD SETTINGS -> COMBINED中的Signing->Code Signing Identity的值从iOS Developer修改为Apple Development,还有TARGETS -> Build Settings -> Combined中的Signing->Code Signing Identity->Release的值从iOS Developer修改为Apple Development

  • 上传archive最后提示Missing private key

  • Run on device突然报错Errors were encountered while preparing your device for development. Please check the Devices and Simulators Window.: 重启手机试试吧

  • “XXXX” has 2 Apple Distribution certificates but their private keys are not installed. Contact the creator of one of these certificates to get a copy of the private key: 可能是key过期了,去apple developer重新生成一个证书吧,下载下来安装上,但是得重启一下xcode

  • push app 到appstore一直在processing: 这个时候确实可以再push一个新版本,可能会更快

  • ios模拟弱网环境: 设置->开发者选项-> Network LINK CONDITIONER

  • set the code signing identity value to apple development in the build settings editor: 在TARGETS -> Build Settings -> All中搜索signing 即可,修改对应的值为apple development即可

  • sandbox账户无法登录,提示要进入设置收验证码: 无论怎样我都收不到验证码, 最后重新建了一个sandbox账户就可以了,sandbox在点击登录按钮登录的时候按理说是不用验证码的,直接就可以登录了。当然,必须得退出本机自身的apple id才行

  • 添加了测试设备后,Xcode依然无法安装: 可能是因为Xcode没有及时更新云端的Provisioning Profile可以删除目录~/Library/MobileDevice/Provisioning,然后打包时候勾选Automatically manage signing,Xcode就会重新拉取了

  • NSURLConnection SSL error: 通常只需要在Info.plist中添加

    1
    2
    3
    4
    5
    <key>NSAppTransportSecurity</key>
    <dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    </dict>

扩展阅读

坚持原创技术分享,谢谢支持

欢迎关注我的其它发布渠道