Skip to content

Commit

Permalink
Merge pull request #20 from contentstack/hotfix/crash-on-caching
Browse files Browse the repository at this point in the history
Hotfix crash on caching
  • Loading branch information
uttamukkoji authored Nov 11, 2022
2 parents 4ef23e7 + b0c206a commit f26a358
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 44 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Build/
build/
DerivedData
Podfile.lock
Pods
Pods/
ContentstackTest/TestResult/
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### Version: 3.10.1
#### Date: Nov-11-2022

##### Hot fix:
- Fix crash on NSInvalidArgumentException

### Version: 3.10.0
#### Date: Aug-19-2022

Expand Down
4 changes: 2 additions & 2 deletions Contentstack.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Contentstack'
s.version = '3.10.0'
s.version = '3.10.1'
s.summary = 'Contentstack is a headless CMS with an API-first approach that puts content at the centre.'

s.description = <<-DESC
Expand All @@ -12,7 +12,7 @@ s.homepage = 'https://www.contentstack.com/'
s.license = { :type => 'Commercial',:text => 'See https://www.contentstack.com/'}
s.author = { 'Contentstack' => '[email protected]' }

s.source = { :git => 'https://github.com/contentstack/contentstack-ios.git', :tag => 'v3.10.0' }
s.source = { :git => 'https://github.com/contentstack/contentstack-ios.git', :tag => 'v3.10.1' }
s.social_media_url = 'https://twitter.com/Contentstack'

s.ios.deployment_target = '8.0'
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@
};
23C545FD1C197722007BBD27 /* Framework Generation Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
buildActionMask = 12;
files = (
);
inputPaths = (
Expand Down
2 changes: 1 addition & 1 deletion Contentstack/Contentstack.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Contentstack. All rights reserved.
//

// sdk-version: 3.10.0
// sdk-version: 3.10.1

#import <Foundation/Foundation.h>
#import <Contentstack/Config.h>
Expand Down
2 changes: 1 addition & 1 deletion Contentstack/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.10.0</string>
<string>3.10.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions ContentstackInternal/CSIOCoreHTTPNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import "NSObject+Extensions.h"
#import "CSURLSessionManager.h"

NSString *const sdkVersion = @"3.10.0";
NSString *const sdkVersion = @"3.10.1";

@interface CSIOCoreHTTPNetworking (){
id networkChangeObserver;
Expand Down Expand Up @@ -372,7 +372,7 @@ - (NSURLSessionDataTask*)requestForStack:(Stack*)stack
mutableRequest.HTTPMethod = @"GET";

NSURLSessionDataTask *task = [self.urlSessionManager dataTaskWithRequest:mutableRequest success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
if (cachePolicy != NETWORK_ONLY || cachePolicy != CACHE_THEN_NETWORK) {
if ((cachePolicy != NETWORK_ONLY || cachePolicy != CACHE_THEN_NETWORK) && responseObject != nil) {
[self saveToCacheDataTask:task responseObject:responseObject];
}
completionBlock(resType, responseObject, nil);
Expand Down
4 changes: 3 additions & 1 deletion Docs/DocGenerationScript.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ target="iphoneos";
# End constants
/usr/local/bin/appledoc \
--project-name "Contentstack" \
--templates "${PROJECT_DIR}/../appledoc/Templates" \
--project-company "Contentstack.com" \
--project-version "3.10.0" \
--project-version "3.10.1" \
--company-id "${companyID}" \
--docset-bundle-id "${companyID}.${companyForFeed}" \
--docset-bundle-name "${companyForFeed}" \
Expand All @@ -46,3 +47,4 @@ target="iphoneos";
--index-desc "${PROJECT_DIR}/Docs/overview.md" \
--exit-threshold 2 \
./Build/Products/Release-universal/Contentstack.framework/Headers

56 changes: 39 additions & 17 deletions Docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ Add the following line to your Podfile:

Run `pod install`, and you should now have the latest Contentstack release.


##### Manual

1. Download the [Latest iOS SDK release](https://www.contentstack.com/docs/platforms/ios/ios_sdk_latest) and extract the zip file to your local disk.

2. Drag and drop Contentstack.framework into your project folder in Xcode.
A window will appear, prompting you to choose one of the options for adding files. Click the ‘Destination’ checkbox to copy items into the destination group’s folder. This will add the SDK to your project.

3. In the project editor, select your app under `TARGETS`. Under the `General` tab, open `Linked Frameworks and Libraries` and add the following libraries:
- CoreGraphics.framework
- MobileCoreServices.framework
- Security.framework
- SystemConfiguration.framework

4. In your target app, click on the `Build Settings` tab and add the `-ObjC` flag to `Other Linker Flags`.


#### Import Header/Module
You can import header file in Objective-C project as:

Expand All @@ -41,3 +24,42 @@ You can also import as a Module:
//Swift
import Contentstack


#### Initializing your SDK

To start using the SDK in your application, you will need to initialize the stack by providing the required keys and values associated with them:

//Objc
Stack *stack = [Contentstack stackWithAPIKey: API_KEY accessToken: ACCESS_TOKEN environmentName: ENVIRONMENT];

//Swift
let stack:Stack = Contentstack.stackWithAPIKey(API_KEY, accessToken: ACCESS_TOKEN, environmentName: ENVIRONMENT)

To get the api credentials mentioned above, you need to log into your Contentstack account and then in your top panel navigation, go to Settings -&gt; Stack to view both your API Key and your Access Token

The stack object that is returned is a Contentstack client object, which can be used to initialize different modules and make queries against our [Content Delivery API](https://contentstack.com/docs/apis/content-delivery-api/). The initialization process for each module is explained in the following section.


#### Querying content from your stack

To fetch all entries of of a content type, use the query given below:

//Objc
ContentType *contentTypeObject = [stack contentTypeWithName:@"my_content_type"];
Query *queryObject = [contentTypeObj query];

//Swift
var contentTypeObject:ContentType = stack.contentTypeWithName("my_content_type")
var queryObject:Query = contentTypeObj.query()


To fetch a specific entry from a content type, use the following query:

//Objc
ContentType * contentTypeObject = [stack contentTypeWithName:@"my_content_type"];
Entry *entryObject = [contentTypeObject entryWithUID:@"ENTRY_UID"];
//Swift
var contentTypeObject:ContentType = stack.contentTypeWithName("my_content_type")
var entryObject:Entry = contentTypeObject.entryWithUID("ENTRY_UID")
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2012-2022 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PODFILE CHECKSUM: e70b33906e829ccd2b052bc0e0cff91ee8ee49e6

COCOAPODS: 1.11.3
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,6 @@ Latest Xcode and Mac OS X


To use this SDK on iOS platform, you will have to install the SDK according to the steps given below.


##### Manual


1. Download the [Latest iOS SDK release](https://www.contentstack.com/docs/platforms/ios/ios_sdk_latest) and extract the zip file to your local disk.
2. Drag and drop Contentstack.framework into your project folder in Xcode. A window will appear, prompting you to choose one of the options for adding files. Click the ‘Destination’ checkbox to copy items into the destination group’s folder. This will add the SDK to your project.
3. In the project editor, select your app under TARGETS. Under the General tab, open Linked Frameworks and Libraries and add the following libraries:
- CoreGraphics.framework
- MobileCoreServices.framework
- Security.framework
- SystemConfiguration.framework

4. In your target app, click on the Build Settings tab and add the -ObjC flag to Other Linker Flags.

##### CocoaPods

1. Add the following line to your Podfile:
Expand Down Expand Up @@ -315,7 +300,7 @@ You can use advanced sync queries to fetch custom results while performing initi
### The MIT License (MIT)
Copyright © 2012-2020 [Contentstack](https://www.contentstack.com/). All Rights Reserved
Copyright © 2012-2022 [Contentstack](https://www.contentstack.com/). All Rights Reserved
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down
6 changes: 4 additions & 2 deletions Script/ios-build-framework-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fi
# Build the other (non-simulator) platform
xcodebuild -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${SF_TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}/DependantBuilds/arm64" BUILD_ROOT="${BUILD_ROOT}" CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/arm64" SYMROOT="${SYMROOT}" ARCHS='arm64' VALID_ARCHS='arm64' $ACTION

xcodebuild -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${SF_TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}/DependantBuilds/arm7" BUILD_ROOT="${BUILD_ROOT}" CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/armv7" SYMROOT="${SYMROOT}" ARCHS='armv7 armv7s' VALID_ARCHS='armv7 armv7s' $ACTION
#xcodebuild -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${SF_TARGET_NAME}" -configuration "${CONFIGURATION}" -sdk iphoneos BUILD_DIR="${BUILD_DIR}" OBJROOT="${OBJROOT}/DependantBuilds/arm7" BUILD_ROOT="${BUILD_ROOT}" CONFIGURATION_BUILD_DIR="${IPHONE_DEVICE_BUILD_DIR}/armv7" SYMROOT="${SYMROOT}" ARCHS='armv7 armv7s' VALID_ARCHS='armv7 armv7s' $ACTION

# Copy the framework structure to the universal folder (clean it first)
rm -rf "${UNIVERSAL_OUTPUTFOLDER}"
Expand All @@ -49,8 +49,10 @@ cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${SF_TARGET_NAME}.framework
# Remove Info.plist file from universal folder
rm -r "${UNIVERSAL_OUTPUTFOLDER}/${SF_TARGET_NAME}.framework/Info.plist"

lipo -remove arm64 "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${SF_TARGET_NAME}.framework/${SF_TARGET_NAME}" -output "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${SF_TARGET_NAME}.framework/${SF_TARGET_NAME}"

# Smash them together to combine all architectures
lipo -create "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${SF_TARGET_NAME}.framework/${SF_TARGET_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/arm64/${SF_TARGET_NAME}.framework/${SF_TARGET_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/armv7/${SF_TARGET_NAME}.framework/${SF_TARGET_NAME}" -output "${UNIVERSAL_OUTPUTFOLDER}/${SF_TARGET_NAME}.framework/${SF_TARGET_NAME}"
lipo -create "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${SF_TARGET_NAME}.framework/${SF_TARGET_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/arm64/${SF_TARGET_NAME}.framework/${SF_TARGET_NAME}" -output "${UNIVERSAL_OUTPUTFOLDER}/${SF_TARGET_NAME}.framework/${SF_TARGET_NAME}"

#Convenience step to copy the framework to the project's directory
mkdir -p "${PROJECT_DIR}/Build"
Expand Down

0 comments on commit f26a358

Please sign in to comment.