[{"data":1,"prerenderedAt":635},["ShallowReactive",2],{"content-query-BhFLHlrQyb":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"body":10,"_type":629,"_id":630,"_source":631,"_file":632,"_stem":633,"_extension":634},"\u002Fdocs\u002Fios-sdk","docs",false,"","iOS 接入指南","在 iOS 应用中集成 XXinstall 归因 SDK。",{"type":11,"children":12,"toc":623},"root",[13,21,27,32,39,44,51,80,530,535,617],{"type":14,"tag":15,"props":16,"children":18},"element","h2",{"id":17},"概述",[19],{"type":20,"value":17},"text",{"type":14,"tag":22,"props":23,"children":24},"p",{},[25],{"type":20,"value":26},"iOS 归因 SDK 核心逻辑以预编译的 XCFramework 二进制分发，支持 React Native (Expo)、Flutter 和纯原生 Swift 三种接入方式。归因完成后自动上报设备画像（去重\u002F防刷）。",{"type":14,"tag":15,"props":28,"children":30},{"id":29},"接入方式",[31],{"type":20,"value":29},{"type":14,"tag":33,"props":34,"children":36},"h3",{"id":35},"纯原生-swift-项目",[37],{"type":20,"value":38},"纯原生 Swift 项目",{"type":14,"tag":22,"props":40,"children":41},{},[42],{"type":20,"value":43},"如果你的 iOS 项目不使用 React Native，可以直接集成 XCFramework：",{"type":14,"tag":45,"props":46,"children":48},"h4",{"id":47},"集成-xcframework",[49],{"type":20,"value":50},"集成 XCFramework",{"type":14,"tag":52,"props":53,"children":54},"ol",{},[55,70,75],{"type":14,"tag":56,"props":57,"children":58},"li",{},[59,61,68],{"type":20,"value":60},"将 ",{"type":14,"tag":62,"props":63,"children":65},"code",{"className":64},[],[66],{"type":20,"value":67},"XXinstallCore.xcframework",{"type":20,"value":69}," 拖入 Xcode 项目",{"type":14,"tag":56,"props":71,"children":72},{},[73],{"type":20,"value":74},"在 Target → General → Frameworks, Libraries, and Embedded Content 中确认已添加",{"type":14,"tag":56,"props":76,"children":77},{},[78],{"type":20,"value":79},"调用 SDK：",{"type":14,"tag":81,"props":82,"children":86},"pre",{"className":83,"code":84,"language":85,"meta":7,"style":7},"language-swift shiki shiki-themes github-dark","import XXinstallCore\n\n\u002F\u002F 设置 API 地址\nXXinstall.setHost(\"https:\u002F\u002Fyour-api-domain.com\")\n\n\u002F\u002F 初始化并获取归因结果\nlet config = XXinstallConfig(\n    appKey: \"YOUR_APP_KEY\",\n    appSecret: \"YOUR_APP_SECRET\",\n    debug: true\n)\n\nXXinstall.initialize(config: config) { result in\n    switch result {\n    case .success(let attr):\n        print(\"归因: inviteCode=\\(attr.inviteCode ?? \"nil\"), channel=\\(attr.channel)\")\n    case .failure(let error):\n        print(\"归因失败: \\(error.localizedDescription)\")\n    }\n}\n","swift",[87],{"type":14,"tag":62,"props":88,"children":89},{"__ignoreMap":7},[90,108,118,128,160,168,177,206,230,252,270,278,286,318,332,369,439,473,512,521],{"type":14,"tag":91,"props":92,"children":95},"span",{"class":93,"line":94},"line",1,[96,102],{"type":14,"tag":91,"props":97,"children":99},{"style":98},"--shiki-default:#F97583",[100],{"type":20,"value":101},"import",{"type":14,"tag":91,"props":103,"children":105},{"style":104},"--shiki-default:#B392F0",[106],{"type":20,"value":107}," XXinstallCore\n",{"type":14,"tag":91,"props":109,"children":111},{"class":93,"line":110},2,[112],{"type":14,"tag":91,"props":113,"children":115},{"emptyLinePlaceholder":114},true,[116],{"type":20,"value":117},"\n",{"type":14,"tag":91,"props":119,"children":121},{"class":93,"line":120},3,[122],{"type":14,"tag":91,"props":123,"children":125},{"style":124},"--shiki-default:#6A737D",[126],{"type":20,"value":127},"\u002F\u002F 设置 API 地址\n",{"type":14,"tag":91,"props":129,"children":131},{"class":93,"line":130},4,[132,138,144,149,155],{"type":14,"tag":91,"props":133,"children":135},{"style":134},"--shiki-default:#E1E4E8",[136],{"type":20,"value":137},"XXinstall.",{"type":14,"tag":91,"props":139,"children":141},{"style":140},"--shiki-default:#79B8FF",[142],{"type":20,"value":143},"setHost",{"type":14,"tag":91,"props":145,"children":146},{"style":134},[147],{"type":20,"value":148},"(",{"type":14,"tag":91,"props":150,"children":152},{"style":151},"--shiki-default:#9ECBFF",[153],{"type":20,"value":154},"\"https:\u002F\u002Fyour-api-domain.com\"",{"type":14,"tag":91,"props":156,"children":157},{"style":134},[158],{"type":20,"value":159},")\n",{"type":14,"tag":91,"props":161,"children":163},{"class":93,"line":162},5,[164],{"type":14,"tag":91,"props":165,"children":166},{"emptyLinePlaceholder":114},[167],{"type":20,"value":117},{"type":14,"tag":91,"props":169,"children":171},{"class":93,"line":170},6,[172],{"type":14,"tag":91,"props":173,"children":174},{"style":124},[175],{"type":20,"value":176},"\u002F\u002F 初始化并获取归因结果\n",{"type":14,"tag":91,"props":178,"children":180},{"class":93,"line":179},7,[181,186,191,196,201],{"type":14,"tag":91,"props":182,"children":183},{"style":98},[184],{"type":20,"value":185},"let",{"type":14,"tag":91,"props":187,"children":188},{"style":134},[189],{"type":20,"value":190}," config ",{"type":14,"tag":91,"props":192,"children":193},{"style":98},[194],{"type":20,"value":195},"=",{"type":14,"tag":91,"props":197,"children":198},{"style":140},[199],{"type":20,"value":200}," XXinstallConfig",{"type":14,"tag":91,"props":202,"children":203},{"style":134},[204],{"type":20,"value":205},"(\n",{"type":14,"tag":91,"props":207,"children":209},{"class":93,"line":208},8,[210,215,220,225],{"type":14,"tag":91,"props":211,"children":212},{"style":140},[213],{"type":20,"value":214},"    appKey",{"type":14,"tag":91,"props":216,"children":217},{"style":134},[218],{"type":20,"value":219},": ",{"type":14,"tag":91,"props":221,"children":222},{"style":151},[223],{"type":20,"value":224},"\"YOUR_APP_KEY\"",{"type":14,"tag":91,"props":226,"children":227},{"style":134},[228],{"type":20,"value":229},",\n",{"type":14,"tag":91,"props":231,"children":233},{"class":93,"line":232},9,[234,239,243,248],{"type":14,"tag":91,"props":235,"children":236},{"style":140},[237],{"type":20,"value":238},"    appSecret",{"type":14,"tag":91,"props":240,"children":241},{"style":134},[242],{"type":20,"value":219},{"type":14,"tag":91,"props":244,"children":245},{"style":151},[246],{"type":20,"value":247},"\"YOUR_APP_SECRET\"",{"type":14,"tag":91,"props":249,"children":250},{"style":134},[251],{"type":20,"value":229},{"type":14,"tag":91,"props":253,"children":255},{"class":93,"line":254},10,[256,261,265],{"type":14,"tag":91,"props":257,"children":258},{"style":140},[259],{"type":20,"value":260},"    debug",{"type":14,"tag":91,"props":262,"children":263},{"style":134},[264],{"type":20,"value":219},{"type":14,"tag":91,"props":266,"children":267},{"style":140},[268],{"type":20,"value":269},"true\n",{"type":14,"tag":91,"props":271,"children":273},{"class":93,"line":272},11,[274],{"type":14,"tag":91,"props":275,"children":276},{"style":134},[277],{"type":20,"value":159},{"type":14,"tag":91,"props":279,"children":281},{"class":93,"line":280},12,[282],{"type":14,"tag":91,"props":283,"children":284},{"emptyLinePlaceholder":114},[285],{"type":20,"value":117},{"type":14,"tag":91,"props":287,"children":289},{"class":93,"line":288},13,[290,294,299,303,308,313],{"type":14,"tag":91,"props":291,"children":292},{"style":134},[293],{"type":20,"value":137},{"type":14,"tag":91,"props":295,"children":296},{"style":140},[297],{"type":20,"value":298},"initialize",{"type":14,"tag":91,"props":300,"children":301},{"style":134},[302],{"type":20,"value":148},{"type":14,"tag":91,"props":304,"children":305},{"style":140},[306],{"type":20,"value":307},"config",{"type":14,"tag":91,"props":309,"children":310},{"style":134},[311],{"type":20,"value":312},": config) { result ",{"type":14,"tag":91,"props":314,"children":315},{"style":98},[316],{"type":20,"value":317},"in\n",{"type":14,"tag":91,"props":319,"children":321},{"class":93,"line":320},14,[322,327],{"type":14,"tag":91,"props":323,"children":324},{"style":98},[325],{"type":20,"value":326},"    switch",{"type":14,"tag":91,"props":328,"children":329},{"style":134},[330],{"type":20,"value":331}," result {\n",{"type":14,"tag":91,"props":333,"children":335},{"class":93,"line":334},15,[336,341,346,351,355,359,364],{"type":14,"tag":91,"props":337,"children":338},{"style":98},[339],{"type":20,"value":340},"    case",{"type":14,"tag":91,"props":342,"children":343},{"style":134},[344],{"type":20,"value":345}," .",{"type":14,"tag":91,"props":347,"children":348},{"style":140},[349],{"type":20,"value":350},"success",{"type":14,"tag":91,"props":352,"children":353},{"style":134},[354],{"type":20,"value":148},{"type":14,"tag":91,"props":356,"children":357},{"style":98},[358],{"type":20,"value":185},{"type":14,"tag":91,"props":360,"children":361},{"style":134},[362],{"type":20,"value":363}," attr)",{"type":14,"tag":91,"props":365,"children":366},{"style":98},[367],{"type":20,"value":368},":\n",{"type":14,"tag":91,"props":370,"children":372},{"class":93,"line":371},16,[373,378,382,387,392,397,402,407,412,417,421,426,430,435],{"type":14,"tag":91,"props":374,"children":375},{"style":140},[376],{"type":20,"value":377},"        print",{"type":14,"tag":91,"props":379,"children":380},{"style":134},[381],{"type":20,"value":148},{"type":14,"tag":91,"props":383,"children":384},{"style":151},[385],{"type":20,"value":386},"\"归因: inviteCode=",{"type":14,"tag":91,"props":388,"children":389},{"style":151},[390],{"type":20,"value":391},"\\(attr.",{"type":14,"tag":91,"props":393,"children":394},{"style":134},[395],{"type":20,"value":396},"inviteCode",{"type":14,"tag":91,"props":398,"children":399},{"style":98},[400],{"type":20,"value":401}," ??",{"type":14,"tag":91,"props":403,"children":404},{"style":151},[405],{"type":20,"value":406}," \"nil\"",{"type":14,"tag":91,"props":408,"children":409},{"style":151},[410],{"type":20,"value":411},")",{"type":14,"tag":91,"props":413,"children":414},{"style":151},[415],{"type":20,"value":416},", channel=",{"type":14,"tag":91,"props":418,"children":419},{"style":151},[420],{"type":20,"value":391},{"type":14,"tag":91,"props":422,"children":423},{"style":134},[424],{"type":20,"value":425},"channel",{"type":14,"tag":91,"props":427,"children":428},{"style":151},[429],{"type":20,"value":411},{"type":14,"tag":91,"props":431,"children":432},{"style":151},[433],{"type":20,"value":434},"\"",{"type":14,"tag":91,"props":436,"children":437},{"style":134},[438],{"type":20,"value":159},{"type":14,"tag":91,"props":440,"children":442},{"class":93,"line":441},17,[443,447,451,456,460,464,469],{"type":14,"tag":91,"props":444,"children":445},{"style":98},[446],{"type":20,"value":340},{"type":14,"tag":91,"props":448,"children":449},{"style":134},[450],{"type":20,"value":345},{"type":14,"tag":91,"props":452,"children":453},{"style":140},[454],{"type":20,"value":455},"failure",{"type":14,"tag":91,"props":457,"children":458},{"style":134},[459],{"type":20,"value":148},{"type":14,"tag":91,"props":461,"children":462},{"style":98},[463],{"type":20,"value":185},{"type":14,"tag":91,"props":465,"children":466},{"style":134},[467],{"type":20,"value":468}," error)",{"type":14,"tag":91,"props":470,"children":471},{"style":98},[472],{"type":20,"value":368},{"type":14,"tag":91,"props":474,"children":476},{"class":93,"line":475},18,[477,481,485,490,495,500,504,508],{"type":14,"tag":91,"props":478,"children":479},{"style":140},[480],{"type":20,"value":377},{"type":14,"tag":91,"props":482,"children":483},{"style":134},[484],{"type":20,"value":148},{"type":14,"tag":91,"props":486,"children":487},{"style":151},[488],{"type":20,"value":489},"\"归因失败: ",{"type":14,"tag":91,"props":491,"children":492},{"style":151},[493],{"type":20,"value":494},"\\(error.",{"type":14,"tag":91,"props":496,"children":497},{"style":134},[498],{"type":20,"value":499},"localizedDescription",{"type":14,"tag":91,"props":501,"children":502},{"style":151},[503],{"type":20,"value":411},{"type":14,"tag":91,"props":505,"children":506},{"style":151},[507],{"type":20,"value":434},{"type":14,"tag":91,"props":509,"children":510},{"style":134},[511],{"type":20,"value":159},{"type":14,"tag":91,"props":513,"children":515},{"class":93,"line":514},19,[516],{"type":14,"tag":91,"props":517,"children":518},{"style":134},[519],{"type":20,"value":520},"    }\n",{"type":14,"tag":91,"props":522,"children":524},{"class":93,"line":523},20,[525],{"type":14,"tag":91,"props":526,"children":527},{"style":134},[528],{"type":20,"value":529},"}\n",{"type":14,"tag":45,"props":531,"children":533},{"id":532},"可选参数",[534],{"type":20,"value":532},{"type":14,"tag":536,"props":537,"children":538},"table",{},[539,563],{"type":14,"tag":540,"props":541,"children":542},"thead",{},[543],{"type":14,"tag":544,"props":545,"children":546},"tr",{},[547,553,558],{"type":14,"tag":548,"props":549,"children":550},"th",{},[551],{"type":20,"value":552},"参数",{"type":14,"tag":548,"props":554,"children":555},{},[556],{"type":20,"value":557},"类型",{"type":14,"tag":548,"props":559,"children":560},{},[561],{"type":20,"value":562},"说明",{"type":14,"tag":564,"props":565,"children":566},"tbody",{},[567,590],{"type":14,"tag":544,"props":568,"children":569},{},[570,580,585],{"type":14,"tag":571,"props":572,"children":573},"td",{},[574],{"type":14,"tag":62,"props":575,"children":577},{"className":576},[],[578],{"type":20,"value":579},"skipWebView",{"type":14,"tag":571,"props":581,"children":582},{},[583],{"type":20,"value":584},"Bool",{"type":14,"tag":571,"props":586,"children":587},{},[588],{"type":20,"value":589},"跳过内置 WebView 指纹采集（默认 false）",{"type":14,"tag":544,"props":591,"children":592},{},[593,602,612],{"type":14,"tag":571,"props":594,"children":595},{},[596],{"type":14,"tag":62,"props":597,"children":599},{"className":598},[],[600],{"type":20,"value":601},"webViewFingerprint",{"type":14,"tag":571,"props":603,"children":604},{},[605,610],{"type":14,"tag":91,"props":606,"children":607},{},[608],{"type":20,"value":609},"String: Any",{"type":20,"value":611},"?",{"type":14,"tag":571,"props":613,"children":614},{},[615],{"type":20,"value":616},"外部传入 WebView 指纹（用于自定义采集场景）",{"type":14,"tag":618,"props":619,"children":620},"style",{},[621],{"type":20,"value":622},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":110,"depth":110,"links":624},[625,626],{"id":17,"depth":110,"text":17},{"id":29,"depth":110,"text":29,"children":627},[628],{"id":35,"depth":120,"text":38},"markdown","content:docs:ios-sdk.md","content","docs\u002Fios-sdk.md","docs\u002Fios-sdk","md",1784877317041]