{"id":31303,"date":"2024-12-17T12:38:57","date_gmt":"2024-12-17T04:38:57","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=31303"},"modified":"2024-12-17T12:38:57","modified_gmt":"2024-12-17T04:38:57","slug":"%e8%8b%b9%e6%9e%9capp%e7%bd%91%e9%a1%b5%e5%b0%81%e8%a3%85%e6%97%a0%e9%9c%80%e4%b8%8a%e6%9e%b6%e6%80%8e%e4%b9%88%e5%ae%9e%e7%8e%b0%e7%9a%84","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/31303\/","title":{"rendered":"\u82f9\u679capp\u7f51\u9875\u5c01\u88c5\u65e0\u9700\u4e0a\u67b6\u600e\u4e48\u5b9e\u73b0\u7684?"},"content":{"rendered":"

\u82f9\u679c\u7684iOS\u64cd\u4f5c\u7cfb\u7edf\u6709\u7740\u975e\u5e38\u4e25\u683c\u7684\u5e94\u7528\u4e0a\u67b6\u6d41\u7a0b\u548c\u5ba1\u6838\u6807\u51c6\uff0c\u5c24\u5176\u662f\u5bf9\u4e8e\u5305\u542b\u654f\u611f\u5185\u5bb9\u6216\u8005\u6d89\u53ca\u7528\u6237\u9690\u79c1\u7684\u5e94\u7528\uff0c\u5ba1\u6838\u96be\u5ea6\u66f4\u662f\u500d\u589e\u3002\u4e3a\u4e86\u89c4\u907f\u8fd9\u4e9b\u5ba1\u6838\u98ce\u9669\u548c\u6d41\u7a0b\u7e41\u7410\uff0c\u5f88\u591a\u5f00\u53d1\u8005\u6216\u8005\u4f01\u4e1a\u9009\u62e9\u4e86\u5229\u7528\u82f9\u679c\u63d0\u4f9b\u7684\u7f51\u9875\u5c01\u88c5\u6280\u672f\uff0c\u5c06\u539f\u672c\u9700\u8981\u4e0a\u67b6\u7684\u5e94\u7528\uff0c\u901a\u8fc7\u7f51\u9875\u65b9\u5f0f\u63d0\u4f9b\u7ed9\u7528\u6237\u4f7f\u7528\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u82f9\u679capp\u7f51\u9875\u5c01\u88c5\u7684\u539f\u7406\u548c\u8be6\u7ec6\u64cd\u4f5c\u6b65\u9aa4\u3002<\/p>\n

\u4e00\u3001\u82f9\u679capp\u7f51\u9875\u5c01\u88c5\u7684\u539f\u7406<\/p>\n

\u82f9\u679capp\u7f51\u9875\u5c01\u88c5\u6280\u672f\u7684\u539f\u7406\u662f\u5c06\u7f51\u9875\u5728iOS\u8bbe\u5907\u4e0a\u4f5c\u4e3a\u4e00\u4e2a\u72ec\u7acb\u7684\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\uff0c\u901a\u8fc7\u7279\u5b9a\u7684\u6280\u672f\u624b\u6bb5\uff0c\u5c06\u7f51\u9875\u5c01\u88c5\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u7528\u6237\u53ef\u4ee5\u50cf\u666e\u901a\u5e94\u7528\u4e00\u6837\u5728\u684c\u9762\u4e0a\u5b89\u88c5\u548c\u6253\u5f00\u3002\u5177\u4f53\u5b9e\u73b0\u65b9\u5f0f\u662f\u901a\u8fc7UIWebView\u6216\u8005WKWebView\u63a7\u4ef6\u52a0\u8f7d\u7f51\u9875\uff0c\u5e76\u901a\u8fc7JavaScript\u4e0e\u539f\u751f\u4ee3\u7801\u8fdb\u884c\u4ea4\u4e92\uff0c\u5b9e\u73b0\u4e86\u7f51\u9875\u4e0e\u539f\u751f\u5e94\u7528\u7684\u65e0\u7f1d\u8854\u63a5\u3002<\/p>\n

\u4e8c\u3001\u82f9\u679capp\u7f51\u9875\u5c01\u88c5\u7684\u8be6\u7ec6\u64cd\u4f5c\u6b65\u9aa4<\/p>\n

1. \u51c6\u5907\u5de5\u4f5c<\/p>\n

\u5728\u5f00\u59cb\u7f51\u9875\u5c01\u88c5\u4e4b\u524d\uff0c\u9700\u8981\u51c6\u5907\u597d\u4ee5\u4e0b\u5de5\u4f5c\uff1a<\/p>\n

– \u4e00\u4e2a\u53ef\u4f9b\u5c01\u88c5\u7684\u7f51\u9875\uff0c\u5fc5\u987b\u662f\u652f\u6301\u79fb\u52a8\u7aef\u7684\u7f51\u9875\uff1b<\/p>\n

– Xcode\u5f00\u53d1\u73af\u5883\uff1b<\/p>\n

– \u5f00\u53d1\u8005\u8d26\u53f7\uff0c\u7528\u4e8e\u7b7e\u540d\u548c\u6253\u5305\u5e94\u7528\uff1b<\/p>\n

– \u5e94\u7528\u56fe\u6807\u548c\u542f\u52a8\u753b\u9762\u7b49\u8d44\u6e90\u3002<\/p>\n

2. \u521b\u5efaXcode\u5de5\u7a0b<\/p>\n

\u6253\u5f00Xcode\uff0c\u9009\u62e9\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5de5\u7a0b\uff0c\u9009\u62e9Single View Application\u7c7b\u578b\uff0c\u586b\u5199\u5e94\u7528\u7684\u540d\u79f0\u3001\u7ec4\u7ec7\u540d\u79f0\u548cBundle Identifier\u7b49\u4fe1\u606f\u3002\u7136\u540e\u5728\u5de6\u4fa7\u5bfc\u822a\u680f\u4e2d\u9009\u62e9\u201cGeneral\u201d\u9009\u9879\u5361\uff0c\u586b\u5199\u5e94\u7528\u56fe\u6807\u3001\u542f\u52a8\u753b\u9762\u7b49\u4fe1\u606f\u3002<\/p>\n

3. \u6dfb\u52a0WebView\u63a7\u4ef6<\/p>\n

\u5728Xcode\u7684Main.storyboard\u6587\u4ef6\u4e2d\uff0c\u62d6\u62fd\u4e00\u4e2aWebView\u63a7\u4ef6\u5230\u89c6\u56fe\u4e2d\u3002\u7136\u540e\u5728ViewController.swift\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n

“`swift<\/p>\n

import UIKit<\/p>\n

import WebKit<\/p>\n

class ViewController: UIV<\/p>\n

<\/figure>\n<\/p>\n

iewController {<\/p>\n

@IBOutlet weak var webView: WKWebView!<\/p>\n

override func viewDidLoad() {<\/p>\n

super.viewDidLoad()<\/p>\n<\/p>\n

let url = URL(string: “http:\/\/www.example.com”)<\/p>\n

let request = URLR\u82f9\u679cAPP\u4e0a\u67b6<\/a>equest(url: url!)<\/p>\n

webView.load(request)<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u8fd9\u6bb5\u4ee3\u7801\u7684\u4f5c\u7528\u662f\u5728WebView\u4e2d\u52a0\u8f7d\u6307\u5b9a\u7684\u7f51\u9875\u3002<\/p>\n

4. \u8fd0\u884c\u6d4b\u8bd5<\/p>\n

\u5728Xcode\u4e2d\u70b9\u51fb\u8fd0\u884c\u6309\u94ae\uff0c\u5c06\u5e94\u7528\u5b89\u88c5\u5230\u6a21\u62df\u5668\u6216\u8005\u771f\u673a\u4e0a\u3002\u6b64\u65f6\uff0c\u5e94\u7528\u5c06\u4f1a\u5728WebView\u4e2d\u52a0\u8f7d\u6307\u5b9a\u7684\u7f51\u9875\u3002<\/p>\n

5. \u6253\u5305\u53d1\u5e03<\/p>\n

\u5f53\u5e94\u7528\u5b8c\u6210\u6d4b\u8bd5\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7Xcode\u5c06\u5e94\u7528\u6253\u5305\u6210ipa\u6587\u4ef6\u5e76\u53d1\u5e03\u5230\u5e94\u7528\u5546\u5e97\u6216\u8005\u901a\u8fc7\u5176\u4ed6\u65b9\u5f0f\u5206\u53d1\u7ed9\u7528\u6237\u3002\u5177\u4f53\u64cd\u4f5c\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n

– \u5728Xcode\u7684\u5de6\u4fa7\u5bfc\u822a\u680f\u4e2d\u9009\u62e9\u201cProduct\u201d -> \u201cArchive\u201d\uff1b<\/p>\n

– \u7b49\u5f85Xcode\u81ea\u52a8\u6253\u5305\u5b8c\u6210\uff1b<\/p>\n

– \u70b9\u51fb\u201cDistribute App\u201d\u6309\u94ae\uff0c\u9009\u62e9Ad Hoc\u6216\u8005Enterprise\u65b9\u5f0f\u8fdb\u884c\u6253\u5305\uff1b<\/p>\n

– \u586b\u5199\u76f8\u5173\u4fe1\u606f\uff0c\u5305\u62ec\u7b7e\u540d\u548c\u63cf\u8ff0\u6587\u4ef6\u7b49\uff1b<\/p>\n

– \u70b9\u51fb\u201cExport\u201d\u6309\u94ae\uff0c\u9009\u62e9\u4fdd\u5b58ipa\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/p>\n

\u4e09\u3001\u82f9\u679capp\u7f51\u9875\u5c01\u88c5\u7684\u4f18\u7f3a\u70b9<\/p>\n

\u4f18\u70b9\uff1a<\/p>\n

– \u7f51\u9875\u5c01\u88c5\u53ef\u4ee5\u89c4\u907f\u82f9\u679c\u5e94\u7528\u4e0a\u67b6\u7684\u5ba1\u6838\u98ce\u9669\u548c\u6d41\u7a0b\u7e41\u7410\uff1b<\/p>\n

– \u7f51\u9875\u5c01\u88c5\u53ef\u4ee5\u5feb\u901f\u5b9e\u73b0\u5e94\u7528\u7684\u8de8\u5e73\u53f0\u652f\u6301\uff0c\u4e0d\u9700\u8981\u9488\u5bf9\u4e0d\u540c\u5e73\u53f0\u5f00\u53d1\u4e0d\u540c\u7684\u5e94\u7528\u7a0b\u5e8f\uff1b<\/p>\n

– \u7f51\u9875\u5c01\u88c5\u53ef\u4ee5\u8282\u7701\u5f00\u53d1\u6210\u672c\u548c\u4eba\u529b\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u4e00\u4e9b\u7b80\u5355\u7684\u5e94\u7528\u6765\u8bf4\uff0c\u7f51\u9875\u5c01\u88c5\u53ef\u4ee5\u5feb\u901f\u5b9e\u73b0\u3002<\/p>\n

\u7f3a\u70b9\uff1a<\/p>\n

– \u7f51\u9875\u5c01\u88c5\u7684\u5e94\u7528\u4e0d\u80fd\u5b8c\u5168\u8131\u79bb\u7f51\u7edc\u73af\u5883\uff0c\u5bf9\u4e8e\u4e00\u4e9b\u9700\u8981\u79bb\u7ebf\u4f7f\u7528\u7684\u5e94\u7528\u6765\u8bf4\uff0c\u7f51\u9875\u5c01\u88c5\u4e0d\u662f\u6700\u4f73\u9009\u62e9\uff1b<\/p>\n

– \u7f51\u9875\u5c01\u88c5\u7684\u5e94\u7528\u7684\u6027\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u53ef\u80fd\u4e0d\u5982\u539f\u751f\u5e94\u7528\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u4e00\u4e9b\u9700\u8981\u9891\u7e41\u4ea4\u4e92\u7684\u5e94\u7528\u6765\u8bf4\uff1b<\/p>\n

– \u7f51\u9875\u5c01\u88c5\u7684\u5e94\u7528\u7684\u529f\u80fd\u548c\u6269\u5c55\u6027\u53d7\u9650\u4e8e\u7f51\u9875\u672c\u8eab\uff0c\u5982\u679c\u7f51\u9875\u7684\u529f\u80fd\u6709\u9650\uff0c\u90a3\u4e48\u5c01\u88c5\u540e\u7684\u5e94\u7528\u4e5f\u4f1a\u6709\u76f8\u5e94\u7684\u5c40\u9650\u6027\u3002<\/p>\n

\u603b\u7684\u6765\u8bf4\uff0c\u82f9\u679capp\u7f51\u9875\u5c01\u88c5\u6280\u672f\u662f\u4e00\u79cd\u5feb\u901f\u5b9e\u73b0\u5e94\u7528\u7684\u65b9\u5f0f\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u4e00\u4e9b\u7b80\u5355\u7684\u5e94\u7528\u6765\u8bf4\uff0c\u7f51\u9875\u5c01\u88c5\u53ef\u4ee5\u5feb\u901f\u5b9e\u73b0\u3002\u4f46\u662f\u5bf9\u4e8e\u4e00\u4e9b\u9700\u8981\u79bb\u7ebf\u4f7f\u7528\u3001\u9700\u8981\u9ad8\u6027\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u7684\u5e94\u7528\u6765\u8bf4\uff0c\u7f51\u9875\u5c01\u88c5\u53ef\u80fd\u4e0d\u662f\u6700\u4f73\u9009\u62e9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u82f9\u679c\u7684iOS\u64cd\u4f5c\u7cfb\u7edf\u6709\u7740\u975e\u5e38\u4e25\u683c\u7684\u5e94\u7528\u4e0a\u67b6\u6d41\u7a0b\u548c\u5ba1\u6838\u6807\u51c6\uff0c\u5c24\u5176\u662f\u5bf9\u4e8e\u5305\u542b\u654f\u611f\u5185\u5bb9\u6216\u8005\u6d89\u53ca\u7528\u6237\u9690\u79c1\u7684\u5e94\u7528\uff0c\u5ba1\u6838\u96be\u5ea6\u66f4\u662f\u500d\u589e\u3002\u4e3a\u4e86\u89c4\u907f\u8fd9\u4e9b\u5ba1\u6838\u98ce\u9669\u548c\u6d41\u7a0b\u7e41\u7410\uff0c\u5f88\u591a\u5f00\u53d1\u8005\u6216\u8005\u4f01\u4e1a\u9009\u62e9\u4e86\u5229\u7528\u82f9\u679c\u63d0\u4f9b\u7684\u7f51\u9875\u5c01<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[13149,77,149,19,21164],"topic":[],"class_list":["post-31303","post","type-post","status-publish","format-standard","hentry","category-appsj","tag-13149","tag-77","tag-149","tag-19","tag-app"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/31303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=31303"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/31303\/revisions"}],"predecessor-version":[{"id":31339,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/31303\/revisions\/31339"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=31303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=31303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=31303"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=31303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}