Skip to content

Commit

Permalink
SPM support (#434)
Browse files Browse the repository at this point in the history
feat(spm): SPM support test

Add SPM support attempt.
  • Loading branch information
parfeon authored Mar 11, 2022
1 parent aaab013 commit c092b2e
Show file tree
Hide file tree
Showing 287 changed files with 499 additions and 47 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ reports/
##################
tests-configuration.json
Features/
PubNub Tests.xcworkspace

## Build generated
PubNub Example.xcworkspace
build/
DerivedData
Framework/Products
for-upload
Tests/Results

## Various settings
*.pbxuser
Expand Down
17 changes: 11 additions & 6 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
---
name: objective-c
scm: github.com/pubnub/objective-c
version: "5.0.0"
version: "5.1.0"
schema: 1
changelog:
- date: 2022-03-11
version: v5.1.0
changes:
- type: feature
text: "Make it possible to use PubNub Objective-C SDK using SPM."
- date: 2022-01-12
version: v5.0.0
changes:
Expand Down Expand Up @@ -1296,7 +1301,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: PubNub.framework
location: https://github.com/pubnub/objective-c/archive/refs/tags/v5.0.0.zip
location: https://github.com/pubnub/objective-c/archive/refs/tags/v5.1.0.zip
supported-platforms:
supported-operating-systems:
macOS:
Expand Down Expand Up @@ -1357,7 +1362,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.catalyst.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.0.0/PubNub.catalyst.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.0/PubNub.catalyst.xcframework.tar.gz
supported-platforms:
supported-operating-systems:
macOS:
Expand Down Expand Up @@ -1386,7 +1391,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.ios.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.0.0/PubNub.ios.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.0/PubNub.ios.xcframework.tar.gz
supported-platforms:
supported-operating-systems:
iOS:
Expand All @@ -1405,7 +1410,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.macos.framework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.0.0/PubNub.macos.framework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.0/PubNub.macos.framework.tar.gz
supported-platforms:
supported-operating-systems:
macOS:
Expand All @@ -1421,7 +1426,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.tvos.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.0.0/PubNub.tvos.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.0/PubNub.tvos.xcframework.tar.gz
supported-platforms:
supported-operating-systems:
tvOS:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v5.1.0
March 11 2022

#### Added
- Make it possible to use PubNub Objective-C SDK using SPM.

## v5.0.0
January 12 2022

Expand Down
2 changes: 2 additions & 0 deletions Example/PubNub/PubNub Example-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>pubsub.pubnub.com</key>
Expand Down
25 changes: 4 additions & 21 deletions Framework/PubNub Framework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2556,11 +2556,6 @@
7932485D1D874D9F00FBDF36 /* PNPublishSequence.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNPublishSequence.m; sourceTree = "<group>"; };
793887021BEAD49100DCC662 /* PNNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNNumber.h; sourceTree = "<group>"; };
793887031BEAD49100DCC662 /* PNNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNNumber.m; sourceTree = "<group>"; };
795158591C11C88500A9D3AE /* FABAttributes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FABAttributes.h; sourceTree = "<group>"; };
7951585A1C11C88500A9D3AE /* FABKitProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FABKitProtocol.h; sourceTree = "<group>"; };
7951585B1C11C88500A9D3AE /* Fabric+FABKits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Fabric+FABKits.h"; sourceTree = "<group>"; };
7951585C1C11C88500A9D3AE /* Fabric.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Fabric.h; sourceTree = "<group>"; };
795158611C11EA5500A9D3AE /* PubNub.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PubNub.h; sourceTree = "<group>"; };
7951954126BD44E9001E308C /* PubNub+PAM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PubNub+PAM.h"; sourceTree = "<group>"; };
7951954226BD44E9001E308C /* PubNub+PAM.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "PubNub+PAM.m"; sourceTree = "<group>"; };
7960B6611F6811D700FFAEBB /* PNDeleteMessageAPICallBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNDeleteMessageAPICallBuilder.h; sourceTree = "<group>"; };
Expand All @@ -2585,6 +2580,8 @@
797D606822D2E43F00E64C94 /* PNSignalStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNSignalStatus.m; sourceTree = "<group>"; };
797D606922D2E44000E64C94 /* PNSignalStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNSignalStatus.h; sourceTree = "<group>"; };
798842101C18AFE0003E8948 /* update_modulemap.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = update_modulemap.sh; sourceTree = "<group>"; };
79884C9927A745A600052B42 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../../Package.swift; sourceTree = "<group>"; };
79884CC627A7517600052B42 /* build_xcframework.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build_xcframework.sh; sourceTree = "<group>"; };
799D60E824C1B33900171C29 /* PNSendFileStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNSendFileStatus.h; sourceTree = "<group>"; };
799D60E924C1B33900171C29 /* PNSendFileStatus.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PNSendFileStatus.m; sourceTree = "<group>"; };
799D610124C36D5B00171C29 /* PNPublishRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNPublishRequest.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2652,7 +2649,6 @@
79AA8ECE26EB3A1200ADA747 /* PubNub+PAMPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PubNub+PAMPrivate.h"; sourceTree = "<group>"; };
79ABD88F1F01636B007634E0 /* PNTelemetry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNTelemetry.h; sourceTree = "<group>"; };
79ABD8901F01636B007634E0 /* PNTelemetry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNTelemetry.m; sourceTree = "<group>"; };
79ACC4961C11BD720056523A /* PubNub-Fabric-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PubNub-Fabric-Info.plist"; sourceTree = "<group>"; };
79CBB0411BD03D3F001FC34D /* PubNub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PubNub.h; sourceTree = "<group>"; };
79CBB0431BD03D3F001FC34D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
79CBB0561BD03DE4001FC34D /* PubNub+APNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PubNub+APNS.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3123,19 +3119,6 @@
path = Data;
sourceTree = "<group>";
};
795158581C11C88500A9D3AE /* Fabric */ = {
isa = PBXGroup;
children = (
7951585B1C11C88500A9D3AE /* Fabric+FABKits.h */,
7951585A1C11C88500A9D3AE /* FABKitProtocol.h */,
795158591C11C88500A9D3AE /* FABAttributes.h */,
7951585C1C11C88500A9D3AE /* Fabric.h */,
795158611C11EA5500A9D3AE /* PubNub.h */,
);
name = Fabric;
path = ../../Support/Fabric/Headers;
sourceTree = "<group>";
};
799D610024C36D3000171C29 /* Publish */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3326,12 +3309,11 @@
79CBB04F1BD03D93001FC34D /* Support Files */ = {
isa = PBXGroup;
children = (
795158581C11C88500A9D3AE /* Fabric */,
79884C9927A745A600052B42 /* Package.swift */,
79CBB0431BD03D3F001FC34D /* Info.plist */,
7915839D1BD7119E0084FC70 /* PubNub-iOS-Info.plist */,
7915839E1BD7119E0084FC70 /* PubNub-watchOS-Info.plist */,
79A8BCC61C58F97A00015BDE /* PubNub-tvOS-Info.plist */,
79ACC4961C11BD720056523A /* PubNub-Fabric-Info.plist */,
);
name = "Support Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -3665,6 +3647,7 @@
79CBB1DB1BD043BD001FC34D /* scripts */ = {
isa = PBXGroup;
children = (
79884CC627A7517600052B42 /* build_xcframework.sh */,
79CBB1DC1BD043BD001FC34D /* build_universal.sh */,
79CBB1DD1BD043BD001FC34D /* copy_products.sh */,
798842101C18AFE0003E8948 /* update_modulemap.sh */,
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-iOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-tvOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-watchOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.0.0</string>
<string>5.1.0</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
112 changes: 112 additions & 0 deletions Framework/scripts/export_for_spm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/sh

set -e

WORKING_DIRECTORY="$(pwd)"
SOURCES_FOLDER="$1"
[[ "$2" == public-only ]] && PUBLIC_ONLY=1 || PUBLIC_ONLY=0
PUBLIC_HEADERS=()
ALL_HEADERS=()
FILES=()


# Function allow retrieve relative path to header by it's filename.
path_for_file() {
local relative_path=""
for file in "${FILES[@]}"; do
filename="${file%%:*}"
path="${file##*:}"

if [[ "$filename" == "$1" ]]; then
relative_path="$path"
break
fi
done

echo "$relative_path"
}

store_public_header() {
local headerAlreadyAdded=0
for header in "${PUBLIC_HEADERS[@]}"; do
if [[ "$header" == "$1" ]]; then
headerAlreadyAdded=1
break
fi
done

if [[ $headerAlreadyAdded == 0 ]]; then
PUBLIC_HEADERS+=("$1")
fi
}


# Function allow to retrieve list of headers which has been imported in file
# and add them to public list of headers
gather_imported_headers_in_file() {
regex="import \"(.*)\""
while IFS='' read -r line; do
[[ -z "$line" || ! "$line" =~ $regex ]] && continue
imported_header_path="$(path_for_file "${BASH_REMATCH[1]}")"

# Skip file which doesn't exists.
if [[ -z "$imported_header_path" ]]; then
echo "WARNING: Imported file doesn't exists: ${BASH_REMATCH[1]}"
continue
fi

store_public_header "$imported_header_path"
gather_imported_headers_in_file "$SOURCES_FOLDER/$imported_header_path"
done < "$1"
}



if [[ $PUBLIC_ONLY == 1 ]]; then
# Retrieve list of potentially public headers.
while IFS='' read -r HEADER_PATH; do
RELATIVE_PATH="${HEADER_PATH#"$WORKING_DIRECTORY/$SOURCES_FOLDER/"}"
FILENAME="$(echo "$RELATIVE_PATH" | rev | cut -d/ -f1 | rev)"
FILES+=( "$FILENAME:$RELATIVE_PATH" )
ALL_HEADERS+=("$RELATIVE_PATH")
done <<< "$(find "$WORKING_DIRECTORY/$SOURCES_FOLDER" -type f ! \( -name "*.m" -o -name ".DS_Store" -o -name "*Private.h" \))"

# Scan for public headers
gather_imported_headers_in_file "$SOURCES_FOLDER/PubNub.h"
else
# Retrieve list of all headers.
while IFS='' read -r HEADER_PATH; do
RELATIVE_PATH="${HEADER_PATH#"$WORKING_DIRECTORY/$SOURCES_FOLDER/"}"
FILENAME="$(echo "$RELATIVE_PATH" | rev | cut -d/ -f1 | rev)"
FILES+=( "$FILENAME:$RELATIVE_PATH" )
ALL_HEADERS+=("$RELATIVE_PATH")
done <<< "$(find "$WORKING_DIRECTORY/$SOURCES_FOLDER" -type f ! \( -name "*.m" -o -name ".DS_Store" \))"
fi


# Create required folders structure.
! [[ -d "$WORKING_DIRECTORY/Sources" ]] && mkdir -p "$WORKING_DIRECTORY/Sources"
! [[ -d "$1/include" ]] && mkdir -p "$1/include"


# Create symbolic link to Objective-C SDK source files.
pushd "$WORKING_DIRECTORY/Sources"
! [[ -e PubNub ]] && ln -s ../PubNub
popd


# Create symbolic links for public headers
cd "$1/include"
! [[ -e "PubNub.h" ]] && ln -s "../PubNub.h"

if [[ $PUBLIC_ONLY == 1 ]]; then
for HEADER_PATH in "${PUBLIC_HEADERS[@]}"; do
FILENAME="$(echo "$HEADER_PATH" | rev | cut -d/ -f1 | rev)"
! [[ -e "$FILENAME" ]] && ln -s "../$HEADER_PATH"
done
else
for HEADER_PATH in "${ALL_HEADERS[@]}"; do
FILENAME="$(echo "$HEADER_PATH" | rev | cut -d/ -f1 | rev)"
! [[ -e "$FILENAME" ]] && ln -s "../$HEADER_PATH" "$FILENAME"
done
fi
Loading

0 comments on commit c092b2e

Please sign in to comment.