myTargetSDK / mytarget-ios

ios myTarget sdk
GNU Lesser General Public License v3.0
5 stars 5 forks source link

Add support for Apple Silicon (M1) #16

Closed xoridius closed 2 years ago

xoridius commented 2 years ago

Shipped framework breaks iOS Simulator builds on Apple Silicon (M1 macs).

XCFrameworks are required to include the arm64 slice for iOS devices and the macOS iOS simulator for Macs running on Apple silicon.

To fix the issue:

1) Recompile libraries as XCFrameworks with arm64-simulator slice (generic/platform=iOS Simulator) 2) Remove deprecated EXCLUDED_ARCHS[1] and VALID_ARCHS[2] build configuration overrides from podspecs (remove all uses of spec.pod_target_xcconfig and spec.user_target_xcconfig).

Simplified example of building framework target as XCFramework:

# archive framework for device targets
xcodebuild archive -project 'Project.xcodeproj' -scheme 'FrameworkDemo' -configuration Release -destination 'generic/platform=iOS' -archivePath 'archive/FrameworkDemo-iphoneos.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

# archive framework for simulator targets (code signing not required)
xcodebuild archive -project 'Project.xcodeproj' -scheme 'FrameworkDemo' -configuration Release -destination 'generic/platform=iOS Simulator' -archivePath 'archive/FrameworkDemo-iphonesimulator.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"

# build XCFramework
xcodebuild -create-xcframework \
-framework archive/FrameworkDemo-iphoneos.xcarchive/Products/Library/Frameworks/FrameworkDemo.framework \
-framework archive/FrameworkDemo-iphonesimulator.xcarchive/Products/Library/Frameworks/FrameworkDemo.framework \
-output archive/FrameworkDemo.xcframework

References:

aserrr commented 2 years ago

Hello,

Thank you for detailed report.

Actually, myTarget SDK already supports Apple Silicon (M1) since v.5.11.0 (released 2021-04-16)

mytarget-ios-sdk-5.15.2/MyTargetSDK.xcframework/ios-arm64_x86_64-simulator/MyTargetSDK.framework

lipo -archs MyTargetSDK arm64 x86_64

mytarget-ios-sdk-5.15.2/MyTargetSDK.xcframework/ios-arm64_armv7/MyTargetSDK.framework

lipo -archs MyTargetSDK arm64 armv7

Also, there is no "user_target_xcconfig" attribute in .podspec file. We use only "pod_target_xcconfig" attribute in order to simplify Pods merging process. Yes, you're right, there is "VALID_ARCHS" parameter used but I believe it should be ignored while installation. Anyway we'll check if it cause some issues and test our SDK installation side by side with others.

xoridius commented 2 years ago

@aserrr Thanks for response.

user_target_xcconfig is used in myTrackerSDK dependency pod, which cause xcconfig merge conflicts during pod install and pollutes user target. Also I believe it is not required to specify source_files and public_header_files fields for framework headers when using vendored_frameworks, so there is a little room for podspec cleanup.

Would you mind sharing details about your case using pod_target_xcconfig you mentioned earlier?

aserrr commented 2 years ago

We will update podspec files for myTarget and myTracker SDK in future releases.