CocoaPods 接入 KSAdSDK
project 'Unity-iPhone.xcodeproj'
source 'https://cdn.cocoapods.org/'
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!
target 'Unity-iPhone' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
resourcePath='../../Resource/' #资源总路径
# Pods for Unity-iPhone
pod 'KSAdSDK', '3.3.14'
pod 'Masonry', '~> 1.1.0'
pod 'JLRoutes'
pod 'Aspects'
pod 'SDWebImage', '5.9.4'
pod 'CocoaLumberjack'
pod 'MJExtension'
pod 'BlocksKit/Core'
end
pod init Unity-iPhone.xcodeproj
pod install
如果安装时遇到:
[!] CocoaPods could hot find compatible versions for pod "KSAdSDK" : In Podfile:
~~~
- out-of-date source repos which you can update with "pod repo update' or with pod install --repo-update .
- mistyped the name or version.
- not added the source repo that hosts the Podspec to your Podfile.
遇到上方的错误时可以根据提示更新资源仓库:pod repo update,或者直接更新并安装即可 pod install --repo-update
手动方式接入KSAdSDK
一、将KSAdSDK.framework文件手动加入工程,因为该sdk为动态库,所以需要在
General->Frameworks,Libraries,and Embedded Content
中将KSAdSDK.framework的Embed修改为Embed&Sign
二、修改Xcode --> File --> Project Settings/Workspace Settings-->Build System 修改为 Legacy Build System(Deprecated)
三、在上传应用商店时注意要移除 x86_64, i386两个架构,不然在交付App Store时会提示如下错误
ERROR ITMS-90087: "Unsupported Architectures. The executable for xiaochijie.app/Frameworks/KSAdSDK.framework contains unsupported architectures '[i386, x86_64]'."
ERROR ITMS-90125: "The binary is invalid. The encryption info in the LC_ENCRYPTION_INFO load command is either missing or invalid, or the binary is already encrypted. This binary does not seem to have been built with Apple's linker."
解决方法:
在Build Phases中添加以下Run Scripts脚本
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 '*.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
REF
https://u.kuaishou.com/home/detail/1157