Difference between revisions of "IOS AddSDK 4.1.0"

From AdLocus
Jump to: navigation, search
(→‎專案設定)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
__TOC__
 
__TOC__
−
== 加入 Cocoapods ==
+
== 加入 SDK Library ==
−
* 加入Cocoapods到專案中(參考https://cocoapods.org/)
+
* 請將AdLocus.framework拖曳到您的專案中,並勾選下面兩個選項:
−
* 於Podfile中加入Pod ‘AdLocus’ 並儲存
+
** "Copy items into destination group's folder (if needed)"
−
* 重新執行pod install
+
** "Create group for any added folders"
 +
[[File:IOS_Add_File_2.jpg]]
 +
* 在General 中 Embedded Binaries 中加入 AdLocus.framework
 +
[[File:ios_embedded_binaries.jpg|1200px]]
 +
[[File:ios_embedded_binaries2.jpg|1200px]]
  
−
== 專案設定 ==
+
== 設定 Info.plist ==
−
* Target設定說明
+
* 在 Info.plist 中加入
−
[[File:iOS_SDK_Target_Setting_1.jpg|900px]]
+
** App Transport Security Settings
−
** 點擊Target
+
*** Allow Arbitrary Loads  =  YES
−
** 點擊Build Phase
+
** NSLocationAlwaysUsageDescription
−
** 展開Embed Pods Frameworks(如果沒有此項,則如下圖)
+
** NSLocationWhenInUseUsageDescription
−
 
+
[[File:ios_infoplist.jpg|1200px]]
−
[[File:iOS_SDK_Target_Setting_2.jpg|900px]]
+
−
*** 點擊Build Phase的左上角”+”
+
−
*** 選New Run Script Phase
+
−
*** 將Run Script的名稱令為Embed Pods Frameworks
+
−
 
+
−
** 在Input File中加入$(SRCROOT)/Pods/Pods/AdLocus/AdLocus.framework
+
−
 
+
−
* Clean與Run
+
  
 
== 設定編譯相容性 ==
 
== 設定編譯相容性 ==

Latest revision as of 18:43, 20 September 2016

加入 SDK Library

  • 請將AdLocus.framework拖曳到您的專案中,並勾選下面兩個選項:
    • "Copy items into destination group's folder (if needed)"
    • "Create group for any added folders"

IOS Add File 2.jpg

  • 在General 中 Embedded Binaries 中加入 AdLocus.framework

Ios embedded binaries.jpg Ios embedded binaries2.jpg

設定 Info.plist

  • 在 Info.plist 中加入
    • App Transport Security Settings
      • Allow Arbitrary Loads = YES
    • NSLocationAlwaysUsageDescription
    • NSLocationWhenInUseUsageDescription

Ios infoplist.jpg

設定編譯相容性

  • 在 Build Setting 中 Embedded Content Contains Swift Code 設為 YES

Ios embedded contents swift.jpg

  • Release 時移除模擬器用的 binary 檔:
    • 在 Build Phases 中加入 Run Script

Ios run script 0.jpg

    • 並填入:
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
 
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name 'AdLocus.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
 
EXTRACTED_ARCHS=()
 
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
 
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
 
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
 
done

Ios run script 1.jpg

開啟BACKGROUND MODE

  • 在Capabilities 中開啟 Background Mode 並勾選Background fetch

Ios backgroundfetch.jpg