User Tools

Site Tools


Sidebar

Go Back

Refresh

You are not allowed to add pages

Direct Link

library:ios:dev

This is an old revision of the document!


Xcode Misc

1. IOS version not be supported by this version of Xcode

With error message as: Failed to prepare device for develoment.

  1. Get device support package from Gitee or GitHub
  2. Save to: Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

2. About Xcode

4. How to Trust APP

Settings→General→ VPN & Device Management

5. 自动更新编译版本号

采用脚本的方式修改版本号。

  1. 选中Target → Build Phases → 添加一个script [New Run Script Phases]
  2. 添加脚本
// Read version and buildnumber from info.plist
buildNumber=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
shortVersion=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")

// Updata buildnumber
buildNumber=`date +"%y%m%d.%H%M"`
buildNumber="$shortVersion.$buildNumber"

// Update info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
  • 只在Release时更新
if [ "${CONFIGURATION}" = "Release" ]; then

fi

6. Xcode清除最近打开的工程

如果直接点击屏幕下方的Xcode图标,回弹出一个xcode的启动框,右边会列出你最近打开过的工程

如果想清除这些记录,就点击xcode的菜单栏,[File] → [Open Recent] → [Clear Menu],再次启动xcode就看不到先前打开过的工程了

Edit

7. 多余的profiles及证书

~/Library/MobileDevice/Provisioning Profiles

8. 删除不必要的虚拟机

三个占用空间最大的文件分别是: 1.iOS.simruntime 9.76 GB 2.tvOS.simruntime 5.39 GB 3.watchOS.simruntime 6.83 GB

iOS.simruntime日常使用删不得,tvOS.simruntime, watchOS.simruntime ,大部分开发者接触不到,可直接删除

/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/watchOS.simruntime /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS.simruntime

9. 安装早期版本Xcode

  1. 登录自己的appleId账号,https://developer.apple.com/download/more/,下载Xcode安装包
  2. 解压安装包
  3. 如果出现安装包已损坏(Damaged)的弹窗,按以下步骤4,5,6,7解决,否则转到步骤8
  4. 打开系统偏好设置–> 安全性与隐私–>通用–>选择任何来源。
  5. 若你的配置中没有『任何来源』选项,打开命令行工具,执行:sudo spctl –master-disable;再次查看以上选项,【任何来源】就会出现,选中后。
  6. 解除解压验证:xattr -d com.apple.quarantine Xcode*.xip
  7. 将mac的系统时间到Xcode的发布时间,然后就可以解压。(Xcode 13.2.1 December 17, 2021)
  8. 再次双击打开Xcope安装包

10. Xcode升级到Xcode12以后编译老工程时报错

Xcode升级到Xcode12以后,在编译老工程时报错“iPad Air 2 cannot run xxx. xxx architectures (arm64) include none that iPad Air 2 can execute Intel 64-bit).”解决方法

  1. 切换到工程里的“TARGETS”,选择“Build Settings”选项;
  2. 在“Search”处输入“ VALID_ARCHS”,定位到“ VALID_ARCHS”;
  3. 单击选中“ VALID_ARCHS”项,点击键盘“delete”按钮直接删除该项;
  4. 重新运行程序即可。

如果使用真机进行编译或打包,需要将VALID_ARCHS设置为arm64,这样真机就可以正常编译了。如果使用模拟器编译或者打包的话,将arm64的设置删除掉就可以了,设置为空。 但是这样在模拟器合真机之间切换的话还是比较麻烦的。

In your project Build Settings

Architectures,set to Standard architectures - $(ARCHS_STANDARD) In Build Active Architectures Only,set Debug to Yes,Release to No let Excluded Architectures empty VALID_ARCHS, set to arm64 arm64e x86_64

11. App upload tool

https://help.apple.com/app-store-connect/#/devb1c185036

Upload your app binary files with the Transporter app The Transporter app for macOS is a simple and easy way to upload an app to App Store Connect for distribution on the App Store. In addition to uploading your build, you can upload your metadata packages, view delivery progress (including warnings, errors, and delivery logs), as well as a history of past deliveries.

You can download the Transporter app on the Mac App Store.

See the Transporter for macOS Help for more information.

12. Programming Tips

12.1 Evaluates a JavaScript string in the context of the specified frame and content world.

evaluateJavaScript(_:in:in:completionHandler:)

Declaration

@MainActor func evaluateJavaScript(
    _ javaScript: String,
    in frame: WKFrameInfo? = nil,
    in contentWorld: WKContentWorld,
    completionHandler: ((Result<Any, Error>) -> Void)? = nil
)

https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript

12.2 WKWebkit容器透明

webView.isOpaque = false
webView.backgroundColor = UIColor.clear
webView.scrollView.backgroundColor = UIColor.clear

12.3 WKWebkit 手势

webview内容下移20px

iOS 11:
webView.scrollView.contentInsetAdjustmentBehavior = .never
iOS 7-10:
self.automaticallyAdjustsScrollViewInsets = false

webview可以向下拉动,出现一片空白

添加
webView.scrollView.isScrollEnabled = false

webview可两指缩放

设置代理:
webView.scrollView.delegate = self
实现以下方法
// Not work
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
      return nil
}
// work
func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) {
      scrollView.pinchGestureRecognizer?.isEnabled = false
      scrollView.panGestureRecognizer.isEnabled = false
}

阻止input输入文字时页面视图放大

<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">

模拟器存储目录

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

13. 当前苹果商店对Xcode及MacOS的最低要求

April 25, 2022

Starting April 25, 2022, iOS, iPadOS, and watchOS apps submitted to the App Store must be built with Xcode 13, which includes the SDKs for iOS 15, iPadOS 15, and watchOS 8.
4月25日起,开发者向 App Store 提交的应用必须使用 Xcode 13 创建
App Store submission requirement starts April 25

April 25, 2023

Starting April 25, 2023, iOS, iPadOS, and watchOS apps submitted to the App Store must be built with Xcode 14.1 or later. \\https://developer.apple.com/news/?id=jd9wcyov

Xcode 13.4 最低要求 macOS Monterey 12
Xcode 13.2 最低要求 macOS Big Sur 11.3
Xcode 13 最低要求 macOS Big Sur 11.3
Minimum requirements and supported SDKs

14. Apps Upload misc

14.1 Upload tool

14.2 Missing Compliance

App Store 中 选择build的时候发现有“Missing Compliance” 警告。

解决办法:在info.plist中, 加入App Uses Non-Exempt Encryption,值为NO,重新打包上传

14.3 APP icon 不显示

在 Targets → Build Phases → Copy Bundle Resources 添加Assets.xcassets文件夹。

15. Links

library/ios/dev.1684215054.txt.gz · Last modified: 2023/05/16 13:30 by lhaosen