omise / omise-ios

Omise iOS SDK
https://www.opn.ooo
MIT License
74 stars 36 forks source link

Built for iOS #120

Closed acrabb closed 1 year ago

acrabb commented 3 years ago

Running our project in Xcode 12 to a simulator gets the following build error:

Building for iOS Simulator, but the linked and embedded framework 'OmiseSDK.framework' was built for iOS.

Has anyone else seen this issue?

igroomgrim commented 3 years ago

Could you try with this binary framework, I'm just building it from v4.0.1 You can download then extract and drag it into your project. OmiseSDK401.xcframework.zip

acrabb commented 3 years ago

Thanks @igroomgrim , the ios-arm64_i386_x86_64-simulator version worked for the simulator. but now building for iOS (physical device) doesn't work with that binary. The opposite error occurs:

Building for iOS, but the linked framework 'OmiseSDK.framework' was built for iOS Simulator.

Can we not have both iOS and iOS Simulator in the same binary? And if not, how can I include both in the project without changing binaries every time I switch from phone to sim?

Much appreciated.

igroomgrim commented 3 years ago

@acrabb For that OmiseSDK.xcframework you don't need to go inside the binary file and select .framework by architecture. You can drag and drop OmiseSDK.xcframework directly to your project. It works both on Simulator and iOS device targets. Example:

Screen Shot 2563-12-09 at 08 33 03

👍 🙇

wiosm commented 3 years ago

@acrabb you can try using pod also. It's not official from Omise but you can try, I did and it can be applied successfully for my project. Let me know if you need any help. pod 'Omise', '4.0.1'

igroomgrim commented 3 years ago

@wiosm Thanks for your project. 🙇 But @acrabb just be careful when you use not official SDK. You can use it, but it's at your own risk. 🔐 👌

acrabb commented 3 years ago

Thanks @igroomgrim for some reason the xcframework is leaving me with a runtime error:

dyld: Library not loaded: @rpath...
Reason: image not found

Not sure what's going on 🤔

Is this Omise Build Phase still required?

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 'OmiseSDK.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
acrabb commented 3 years ago

Think I fixed it by adding it to the Build Phase Embedded Frameworks I swear I tried this many times before it actually worked. Thanks Apple.