Skip to content

Commit 94daf20

Browse files
authored
Swift migration (#456)
1 parent 8a65fce commit 94daf20

File tree

9 files changed

+698
-526
lines changed

9 files changed

+698
-526
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ deploy:
4444
- provider: releases
4545
skip_cleanup: true
4646
api_key: $GITHUB_TOKEN
47-
file: Release/Leanplum.framework.zip
47+
file:
48+
- Release/Leanplum.framework.zip
49+
- Release/dynamic/Leanplum.xcframework.zip
4850
draft: true
4951
on:
5052
tags: true

Leanplum-iOS-SDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Pod::Spec.new do |s|
2727
s.weak_frameworks = 'AdSupport', 'StoreKit'
2828
s.library = 'sqlite3'
2929
s.documentation_url = 'https://docs.leanplum.com/'
30-
s.source_files = 'LeanplumSDK/LeanplumSDK/Classes/**/*'
30+
s.source_files = 'LeanplumSDK/LeanplumSDK/Classes/**/*', 'LeanplumSDK/LeanplumSDK/ClassesSwift/**/*'
3131
s.module_name = 'Leanplum'
3232
s.resource_bundle = {
3333
'Leanplum-iOS-SDK' => 'LeanplumSDK/LeanplumSDKBundle/Resources/**/*'

LeanplumSDK/LeanplumSDK.xcodeproj/project.pbxproj

Lines changed: 653 additions & 449 deletions
Large diffs are not rendered by default.

LeanplumSDK/LeanplumSDK.xcodeproj/xcshareddata/xcschemes/Leanplum-Static.xcscheme

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
buildForAnalyzing = "YES">
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
17-
BlueprintIdentifier = "075AAD1626847C6F007CA1BD"
18-
BuildableName = "libLeanplum.a"
17+
BlueprintIdentifier = "6A714AEF26F8B317004A34A9"
18+
BuildableName = "Leanplum.framework"
1919
BlueprintName = "Leanplum-Static"
2020
ReferencedContainer = "container:LeanplumSDK.xcodeproj">
2121
</BuildableReference>
@@ -50,8 +50,8 @@
5050
<MacroExpansion>
5151
<BuildableReference
5252
BuildableIdentifier = "primary"
53-
BlueprintIdentifier = "075AAD1626847C6F007CA1BD"
54-
BuildableName = "libLeanplum.a"
53+
BlueprintIdentifier = "6A714AEF26F8B317004A34A9"
54+
BuildableName = "Leanplum.framework"
5555
BlueprintName = "Leanplum-Static"
5656
ReferencedContainer = "container:LeanplumSDK.xcodeproj">
5757
</BuildableReference>

LeanplumSDK/LeanplumSDK/Classes/Utilities/LPUtils.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#import "LPAPIConfig.h"
2929
#import "LPConstants.h"
3030
#import "Leanplum.h"
31-
31+
#import <Leanplum/Leanplum-Swift.h>
3232

3333
@implementation LPUtils
3434

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// LeanplumUtils.swift
3+
// LeanplumSDK
4+
//
5+
// Created by Nikola Zagorchev on 20.09.21.
6+
//
7+
8+
import Foundation
9+
10+
public class LeanplumUtils: NSObject {
11+
}

Package.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,15 @@
22
import PackageDescription
33

44
let package = Package(
5-
name: "LeanplumSDK",
5+
name: "Leanplum",
66
products: [
7-
.library(name: "LeanplumSDK", targets: ["LeanplumSDK"])
7+
.library(name: "Leanplum", targets: ["Leanplum"])
88
],
99
targets: [
10-
.target(
11-
name: "LeanplumSDK",
12-
path: "LeanplumSDK/LeanplumSDK",
13-
exclude: [
14-
"Supporting Files/Info.plist"
15-
],
16-
resources: [
17-
.process("Resources")
18-
],
19-
publicHeadersPath: "include"
10+
.binaryTarget(
11+
name: "Leanplum",
12+
url: "github/Leanplum.xcframework.zip";
13+
checksum: "checksum";
2014
)
2115
]
2216
)

Tools/build.sh

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -168,32 +168,6 @@ build_ios_static() {
168168
-sdk iphoneos \
169169
SKIP_INSTALL=NO
170170

171-
run "Creating simulator static library from libLeanplum.a ..." \
172-
lipo -create \
173-
Release/static/LeanplumSDK-iphonesimulator.xcarchive/Products/Library/Frameworks/libLeanplum.a \
174-
-output Release/static/LeanplumSDK-iphonesimulator.xcarchive/Products/Library/Frameworks/Leanplum.framework/Leanplum
175-
176-
run "Creating ios static library from libLeanplum.a ..." \
177-
lipo -create \
178-
Release/static/LeanplumSDK-iphoneos.xcarchive/Products/Library/Frameworks/libLeanplum.a \
179-
-output Release/static/LeanplumSDK-iphoneos.xcarchive/Products/Library/Frameworks/Leanplum.framework/Leanplum
180-
181-
run "Copying modulemap for simulator ..." \
182-
cp -r Release/dynamic/LeanplumSDK-iphonesimulator.xcarchive/Products/Library/Frameworks/Leanplum.framework/Modules \
183-
Release/static/LeanplumSDK-iphonesimulator.xcarchive/Products/Library/Frameworks/Leanplum.framework/Modules
184-
185-
run "Copying modulemap for ios ..." \
186-
cp -r Release/dynamic/LeanplumSDK-iphoneos.xcarchive/Products/Library/Frameworks/Leanplum.framework/Modules \
187-
Release/static/LeanplumSDK-iphoneos.xcarchive/Products/Library/Frameworks/Leanplum.framework/Modules
188-
189-
run "Copying Info.plist to static simulator framework ..." \
190-
cp Release/dynamic/LeanplumSDK-iphonesimulator.xcarchive/Products/Library/Frameworks/Leanplum.framework/Info.plist \
191-
Release/static/LeanplumSDK-iphonesimulator.xcarchive/Products/Library/Frameworks/Leanplum.framework/Info.plist
192-
193-
run "Copying Info.plist to static iphone framework ..." \
194-
cp Release/dynamic/LeanplumSDK-iphoneos.xcarchive/Products/Library/Frameworks/Leanplum.framework/Info.plist \
195-
Release/static/LeanplumSDK-iphoneos.xcarchive/Products/Library/Frameworks/Leanplum.framework/Info.plist
196-
197171
run "Creating Leanplum-SDK-iOS static xcframework ..." \
198172
xcodebuild -create-xcframework \
199173
-framework Release/static/LeanplumSDK-iphonesimulator.xcarchive/Products/Library/Frameworks/Leanplum.framework \
@@ -235,9 +209,28 @@ zip_ios() {
235209
cd Release/dynamic
236210
zip -r Leanplum.framework.zip *
237211
mv Leanplum.framework.zip ..
212+
213+
echo "zipping dynamic xcframework for SPM"
214+
zip -r Leanplum.xcframework.zip *
238215
cd -
239216
}
240217

218+
update_spm_info(){
219+
echo "updating SPM checksum and url"
220+
package_file=Package.swift
221+
package_tmp_file=Package_tmp.swift
222+
checksum=`swift package compute-checksum Release/dynamic/Leanplum.xcframework.zip`
223+
awk -v value="\"$checksum\";" '!x{x=sub(/checksum:.*/, "checksum: "value)}1' $package_file > $package_tmp_file \
224+
&& mv $package_tmp_file $package_file
225+
226+
version=`cat sdk-version.txt`
227+
lp_framework="Leanplum.xcframework.zip"
228+
github_url="https://github.com/Leanplum/Leanplum-iOS-SDK/releases/download"
229+
url="$github_url/$version/$lp_framework"
230+
awk -v value="\"$url\";" '!x{x=sub(/url: .*/, "url: "value)}1' $package_file > $package_tmp_file \
231+
&& mv $package_tmp_file $package_file
232+
}
233+
241234
zip_unreal_engine() {
242235
echo "zipping for Unreal Engine release"
243236
pwd

Tools/spm.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)