diff --git a/SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index 3aaca83f4..31b0d6608 100644 --- a/SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -1106,6 +1106,11 @@ 5D1464331C99AC0900727339 /* OCMock.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = OCMock.framework.dSYM; path = Carthage/Build/iOS/OCMock.framework.dSYM; sourceTree = ""; }; 5D1464341C99AC0900727339 /* Quick.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = Quick.framework.dSYM; path = Carthage/Build/iOS/Quick.framework.dSYM; sourceTree = ""; }; 5D1464351C99AC0900727339 /* OCMock.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OCMock.framework; path = Carthage/Build/iOS/OCMock.framework; sourceTree = ""; }; + 5D3759B71CE1198F0088C60E /* SmartDeviceLink-iOS.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = "SmartDeviceLink-iOS.podspec"; sourceTree = ""; }; + 5D3759B81CE11A010088C60E /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = ""; }; + 5D3759B91CE11A010088C60E /* DEPENDENCIES.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = DEPENDENCIES.md; sourceTree = ""; }; + 5D3759BA1CE11A010088C60E /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; + 5D3759BB1CE11A010088C60E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 5D4019AF1A76EC350006B0C2 /* SmartDeviceLink-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SmartDeviceLink-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 5D4029D31A76F0340006B0C2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = SmartDeviceLink_Example/Images.xcassets; sourceTree = SOURCE_ROOT; }; 5D4029D51A76F0410006B0C2 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = SmartDeviceLink_Example/Info.plist; sourceTree = SOURCE_ROOT; }; @@ -2855,6 +2860,11 @@ 5D5934EE1A85160900687FB9 /* Protocol */, 5D5934ED1A85160400687FB9 /* Proxy */, 5D61FA201A84237100846EE7 /* SmartDeviceLink.h */, + 5D3759B71CE1198F0088C60E /* SmartDeviceLink-iOS.podspec */, + 5D3759BA1CE11A010088C60E /* LICENSE */, + 5D3759B81CE11A010088C60E /* CHANGELOG.md */, + 5D3759B91CE11A010088C60E /* DEPENDENCIES.md */, + 5D3759BB1CE11A010088C60E /* README.md */, 5D61FA1E1A84237100846EE7 /* Supporting Files */, ); path = SmartDeviceLink; @@ -4124,7 +4134,6 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; EMBEDDED_CONTENT_CONTAINS_SWIFT = NO; FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", "$(DEVELOPER_FRAMEWORKS_DIR)", "$(PROJECT_DIR)/Carthage/Build/iOS", @@ -4160,7 +4169,6 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; EMBEDDED_CONTENT_CONTAINS_SWIFT = NO; FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", "$(DEVELOPER_FRAMEWORKS_DIR)", "$(PROJECT_DIR)/Carthage/Build/iOS", diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/CHANGELOG.md b/SmartDeviceLink-iOS/SmartDeviceLink/CHANGELOG.md new file mode 100644 index 000000000..746883080 --- /dev/null +++ b/SmartDeviceLink-iOS/SmartDeviceLink/CHANGELOG.md @@ -0,0 +1,150 @@ +# 4.1.1 Release Notes +### Bug Fixes +* `SDLRPCStruct` subclasses now properly print their description. +* Fix SDL support for protocol V1 + +### Other +* Updated testing frameworks for Xcode 7.3 compatibility + +# 4.1.0 Release Notes +### Enhancements +* The `LAUNCH_APP` system request was implemented. +* The proxy now tracks application state and relays that information to the Head Unit on v4 and above. + +### Bug Fixes +* `[SDLProxyListener onProxyOpened]` will only be called when the RPC service starts, instead of any service. +* Sending heartbeat has been deprecated. The iOS proxy will now only respond to heartbeats. +* `SYSTEM_REQUEST` RPC now properly uploads and returns data. +* `SDLStreamingMediaManager`'s version check now correctly compares versions + +### Other +* Updates to the README with "Getting Started" code, and updated information on testing. +* License copyright updated to 2016. +* All testing frameworks are removed from the repository and must be bootstrapped when wanted. + +### Deprecations +* Methods relating to sending heartbeat have been deprecated. This should not affect your app in any way. These lower-level classes will be removed in future versions. + +# 4.0.3 Release Notes +### Enhancements +* Implement HTTP System Requests for policy updates + +### Bug Fixes +* Revert the reachability code in TCP. If you were having trouble with connecting to SDL Core, this should fix that particular bug. + +### Other +* Fixed numerous broken tests +* Moved templates and CONTRIBUTING to .github +* Enable code coverage by default when testing + +# 4.0.2 Release Notes +### Bug Fixes +* Debug logging is a bit better designed and is faster, and file logging happens on a separate queue. +* IAP code no longer causes an unnecessary 3 minute background timer to be set. External Accessory applications already get all the background time they need. +* SDLProxyListener delegate callbacks had some misnamed parameters 'request' should be 'response'. +* SDLProxyListener was marking the wrong type for a passed delegate object. `onOnLockScreenNotification:` now correctly passes a type `SDLOnLockScreenStatus` instead of an `SDLLockScreenStatus`. +* Return `nil` if an object was never set to an RPC. This fixes many unit tests. +* Don't allow `SDLRPCStruct` to initialize with a `nil` backing store. This fixes unit tests. +* MTU size has been fixed to be base 8 based instead of base 10. + +### Other +* Apple broke SDL's app launching scheme in iOS 9.0, so this code has been removed from the project. Apple fixed a bug in iOS 9.2 that alleviates much of the missing functionality. +* The example app no longer has video and audio code, and its app type is now `MEDIA` instead of `NAVIGATION`. +* Travis CI builds are fixed +* Pull-Request and Issue templates have been added + +# 4.0.1 Release notes +### Bug Fixes +* Fixed some implicit `self` captures with blocks. + +# 4.0.0 Release Notes (pre-release) +## Final Release (2015-10-5) +* Example app plist updated with required [ATS](https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/) keys. + +## Release Candidate 2 (2015-09-23) +* Fix a warning for passing in an NSUInteger to an int parameter. + +## Release Candidate 1 (2015-09-19) +### Enhancements +* Lock screen icon is now fetched +* Hex string parsing is now roughly twice as fast. + +### Bug Fixes +* Web request delegates weren't always called. +* Streaming audio fixes. +* Large chunks of data passed over TCP no longer uses far too much memory. +* Xcode 7 warnings fixed. +* Test frameworks updated for Swift 2.0. +* Build server fixes. + + +## Alpha 4 (2015-09-08) +### Enhancements +* Documentation update to SDLHMILevel. +* Formatted files. +* SDLChangeRegistration RPC updated with new parameters. +* Heartbeat is now implemented for v3 head units and greater. +* Callback methods in SDLProxyListener protocol implemented for new RPCs. +* Buffer size for transport greatly increased for v3 and greater. +* Now compatible with iOS 6+ instead of just iOS 7+ using Cocoapods. +* Video and Audio streaming is now implemented. Video Streaming is iOS 8+ only. The object will reject you if you are using an older version at runtime. + +### Bugfixes +* Properly reset the timer for IAP transport. + + +## Alpha 3 (2015-06-22) +### Bug Fixes +* Prevent NULL pointer calls on SDLPolicyDataParser, SDLV1ProtocolHeader, and SDLV2ProtocolHeader +* Fix transport not connecting if the app is launched after the device is connected to a head unit. + + +## Alpha 2 (2015-06-04) +### API Breaking Changes +* 28 header files moved to 'project' scope, making them unavailable to developers. +* Headers now use class forwarding (`@class`) instead of full imports whenever possible. +* SDLDebugToolConsole is given its own file +* SDLRPCStruct is given its own file +* SDLHMIZoneCapablities, SDLVRCapabilities, SDLVRHelpItem letter case fixed +* Fixed 'persistent' spelling and removed 'sync' in `+[SDLRPCRequestFactory buildPutFileWithFileName:fileType:persistentFile:correlationID:]` +* Removed unused ISDLProxy protocol and file +* SDLHMILevel enum names altered to match the rest of the enums +* Fixed spelling of SDLProxyListener `onEncodedSyncPDataResponse:` method +* SDLRPCRequestFactory `buildRegisterAppInterfaceWithAppName:ttsName:vrSynonyms:isMediaApp:languageDesired:hmiDisplayLanguageDesired:appID:` to take immutable arrays instead of mutable arrays, to match all the other methods +* Removed SDLTransport protocol and file +* Removed SDLInterfaceProtocol protocol and file + +### Enhancements +* Completely new project structure. This will enable future support for optional packages through Cocoapods (via subspecs) and frameworks +* Cocoapods distribution support +* Carthage distribution support +* Add a very basic example app +* Unit tests, using Quick, Nimble, and OCMock third party libraries (only used for unit testing) +* Partial documentation coverage +* Enable static analysis +* Initializers now return `instancetype` +* SDLEnums store values in an immutable NSArray +* Add initializers to SDLObjectWithPriority +* Add a `.clang-format` file +* Add SDLHMICapabilities struct +* Add new enum values for TextFieldName, ImageFieldName, KeyboardEvent, Result, and RequestType +* Add SDLSendLocation RPC +* Add SDLDialNumber RPC +* Add quicklook support to SDLEnum objects +* Protocols now conform to NSObject +* Add new RegisterAppInterfaceResponse parameters +* Add support for SDL 4.0 app launching +* Refactor IAP transport +* Add thread index to log format + +### Bugfixes +* Fix all SDLRPCMessages being initialized being set with 'request' type +* Fix all instances of 'receive' being spelled incorrectly +* Fix attempting to copy an SDLEnum in `+[SDLRPCRequestFactory buildPutFileWithFileName:fileType:persistentFile:correlationId:]` +* Fix SDLProtocolHeader `data` method using incorrect order of operations (#84) +* Fix SDLOnLockScreenStatus `hmiLevel` checking wrong class type (#83) +* Fix SDLProtocolMessageAssembler calling it's completion handler twice (#92) +* Fix SDLRPCRequestFactory `performAudioPassThru` not settting correlation id (#79) +* Fix OnSyncPData function ID being incorrect +* Fix uninitialized variable being captured by a block in SDLProxy +* Fix misspelling of 'dictionary' diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/DEPENDENCIES.md b/SmartDeviceLink-iOS/SmartDeviceLink/DEPENDENCIES.md new file mode 100644 index 000000000..f61912428 --- /dev/null +++ b/SmartDeviceLink-iOS/SmartDeviceLink/DEPENDENCIES.md @@ -0,0 +1,538 @@ +## Non-Library Dependencies + +### Quick +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +1. Definitions. +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. +END OF TERMS AND CONDITIONS +APPENDIX: How to apply the Apache License to your work. +To apply the Apache License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "{}" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. +Copyright 2014, Quick Team +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +### Nimble +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014 Quick Team + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +### OCMock 3 +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +1. Definitions. +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. +END OF TERMS AND CONDITIONS + +### OHHTTPStubs +- MIT LICENSE - + +Copyright (c) 2012 Olivier Halligon + +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. \ No newline at end of file diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/Info.plist b/SmartDeviceLink-iOS/SmartDeviceLink/Info.plist index 5284837db..76d0c69e8 100644 --- a/SmartDeviceLink-iOS/SmartDeviceLink/Info.plist +++ b/SmartDeviceLink-iOS/SmartDeviceLink/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.1.0 + 4.1.1 CFBundleSignature ???? CFBundleVersion diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/LICENSE b/SmartDeviceLink-iOS/SmartDeviceLink/LICENSE new file mode 100644 index 000000000..7f7887c5d --- /dev/null +++ b/SmartDeviceLink-iOS/SmartDeviceLink/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2016 Ford Motor Company, +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Ford Motor Company nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/README.md b/SmartDeviceLink-iOS/SmartDeviceLink/README.md new file mode 100644 index 000000000..74f105a31 --- /dev/null +++ b/SmartDeviceLink-iOS/SmartDeviceLink/README.md @@ -0,0 +1,218 @@ +[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) +[![Version](https://img.shields.io/cocoapods/v/SmartDeviceLink-iOS.svg?style=flat)](https://cocoapods.org/pods/SmartDeviceLink-iOS) +[![License](https://img.shields.io/cocoapods/l/SmartDeviceLink-iOS.svg?style=flat)](https://cocoapods.org/pods/SmartDeviceLink-iOS) +[![Build Status](https://img.shields.io/travis/smartdevicelink/sdl_ios/master.svg?style=flat)](https://travis-ci.org/smartdevicelink/sdl_ios) +[![codecov.io](https://img.shields.io/codecov/c/github/codecov/smartdevicelink/sdl_ios/master.svg?style=flat)](http://codecov.io/github/smartdevicelink/sdl_ios?branch=master) +[![Slack Status](http://sdlslack.herokuapp.com/badge.svg)](http://slack.smartdevicelink.org) + + +# SmartDeviceLink (SDL) + +SmartDeviceLink (SDL) is a standard set of protocols and messages that connect applications on a smartphone to a vehicle head unit. This messaging enables a consumer to interact with their application using common in-vehicle interfaces such as a touch screen display, embedded voice recognition, steering wheel controls and various vehicle knobs and buttons. There are three main components that make up the SDL ecosystem. + +* The [Core](https://github.com/smartdevicelink/sdl_core) component is the software which Vehicle Manufacturers (OEMs) implement in their vehicle head units. Integrating this component into their head unit and HMI based on a set of guidelines and templates enables access to various smartphone applications. +* The optional [SDL Server](https://github.com/smartdevicelink/sdl_server) can be used by Vehicle OEMs to update application policies and gather usage information for connected applications. +* The [iOS](https://github.com/smartdevicelink/sdl_ios) and [Android](https://github.com/smartdevicelink/sdl_android) libraries are implemented by app developers into their applications to enable command and control via the connected head unit. + +SmartDeviceLink + + +## Mobile Proxy + +The mobile library component of SDL is meant to run on the end user’s smart-device from within SDL enabled apps. The library allows the apps to connect to SDL enabled head-units and hardware through bluetooth, USB, and TCP. Once the library establishes a connection between the smart device and head-unit through the preferred method of transport, the two components are able to communicate using the SDL defined protocol. The app integrating this library project is then able to expose its functionality to the head-unit through text, media, and other interactive elements. + + +## SDL iOS + +We're still working on creating documentation for each of these individual repositories, but in the meantime, you can find more information about SmartDeviceLink [on the SDL Core README](https://github.com/smartdevicelink/sdl_core/blob/master/README.md) and [on Genivi](http://projects.genivi.org/smartdevicelink/about). + +See the [changelog](https://github.com/smartdevicelink/sdl_ios/blob/master/CHANGELOG.md) for release notes. This project uses [Semantic Versioning](http://semver.org/). + +### Installing + +##### Cocoapods + +You can install this library using [Cocoapods](https://cocoapods.org/pods/SmartDeviceLink-iOS). You can get started with Cocoapods by [following their install guide](https://guides.cocoapods.org/using/getting-started.html#getting-started), and learn how to use Cocoapods to install dependencies [by following this guide](https://guides.cocoapods.org/using/using-cocoapods.html). + +In your podfile, you want to add `pod 'SmartDeviceLink-iOS', '4.1.1'`. Then run `pod install` inside your terminal. With Cocoapods, we support iOS 6+. + +##### Carthage + +SDL iOS supports Carthage! Install using Carthage by following [this guide](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application). Carthage supports iOS 8+. + +##### Dynamic Framework + +Tagged to our releases is a dynamic framework file that can be drag-and-dropped into the application. Dynamic frameworks are supported on iOS 8+. + +### Reference Documentation + +You can find the latest reference documentation on [Cocoadocs](http://cocoadocs.org/docsets/SmartDeviceLink-iOS). Install this documentation to [Dash](http://kapeli.com/dash) or Xcode using [Docs for Xcode](https://documancer.com/xcode/). On the [docs page](http://cocoadocs.org/docsets/SmartDeviceLink-iOS), click the 'share' button in the upper right. + +### Getting Help + +If you see a bug, feel free to post an issue on the appropriate repository. Please see the [contribution guidelines](https://github.com/smartdevicelink/sdl_ios/blob/master/CONTRIBUTING.md) before proceeding. If you need general assistance, or have other questions, you can [sign up](http://slack.smartdevicelink.org) for the [SDL Slack](https://smartdevicelink.slack.com) and chat with other developers and the maintainers of the project. + +### Running Tests +To run tests, you will need to bootstrap the Carthage testing libraries. To do so, first [install Carthage](https://github.com/Carthage/Carthage#installing-carthage). + +Then, from the root project directory, run: +```bash +cd SmartDeviceLink-iOS +carthage bootstrap --platform ios +cd ../ +``` + +At this point, you can run tests from Xcode, or, if you wish to run the tests exactly as they will be run on the CI server, [install xctool](https://github.com/facebook/xctool#installation) and run: + +```bash +xctool -project SmartDeviceLink-iOS/SmartDeviceLink-iOS.xcodeproj -scheme SmartDeviceLink -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO RUN_CLANG_STATIC_ANALYZER=NO test +``` + +### SDL iOS Getting Started + +#### Other Installation Requirements +You may want to build the [sdl_core project](https://github.com/smartdevicelink/sdl_core) to be able to see your application connecting if you don't have an iAP enabled head unit to test. + +#### Enabling Background Capabilities +iOS 5 introduced the capability for an iOS application to maintain a connection to an external accessory while the application is in the background. This capability must be explicitly enabled for your application. + +To enable the feature for your application, select your application's build target, go to Capabilities, enable Background Modes, and select the External accessory communication mode. + +![Enable External Accessory Background Mode](http://i.imgur.com/zxn4lsb.png) + +#### SDL protocol strings +Your application must support a set of smartdevicelink protocol strings in order to be connected to smartdevicelink enabled head units. Go to your application's .plist, look at the source, and add the following code under the top level `dict`. Note: This is not required if you're only testing by connected to a wifi enabled head unit, but is required for USB and Bluetooth enabled head units. + +```xml +UISupportedExternalAccessoryProtocols + +com.smartdevicelink.prot29 +com.smartdevicelink.prot28 +com.smartdevicelink.prot27 +com.smartdevicelink.prot26 +com.smartdevicelink.prot25 +com.smartdevicelink.prot24 +com.smartdevicelink.prot23 +com.smartdevicelink.prot22 +com.smartdevicelink.prot21 +com.smartdevicelink.prot20 +com.smartdevicelink.prot19 +com.smartdevicelink.prot18 +com.smartdevicelink.prot17 +com.smartdevicelink.prot16 +com.smartdevicelink.prot15 +com.smartdevicelink.prot14 +com.smartdevicelink.prot13 +com.smartdevicelink.prot12 +com.smartdevicelink.prot11 +com.smartdevicelink.prot10 +com.smartdevicelink.prot9 +com.smartdevicelink.prot8 +com.smartdevicelink.prot7 +com.smartdevicelink.prot6 +com.smartdevicelink.prot5 +com.smartdevicelink.prot4 +com.smartdevicelink.prot3 +com.smartdevicelink.prot2 +com.smartdevicelink.prot1 +com.smartdevicelink.prot0 +com.ford.sync.prot0 + +``` + +#### Creating the SDLProxy +When creating a proxy, you will likely want a class to manage the Proxy and related functions for you. The example project located in this repository has a class called "ProxyManager" to serve this function. One important, somewhat odd note, is that when the proxy is created, it will immediately start. This means that you should only build the Proxy object when you are ready to search for connections. For production apps using iAP, this is early, since it ought to be ready for an iAP connection the entire time your app is available. However, when debugging using Wi-Fi, you may want to tie this to a button press, since the search can timeout. + +Another odd note is that if a connection disconnects for any reason, you will receive an `onProxyClosed` callback through the `SDLListener` delegate (see below), and you will have to completely discard and rebuild the proxy object. + +The example app's `startProxyWithTransportType` handles starting up the proxy when necessary. The proxy object should be stored as a property of it's parent class. + +```objc +switch (transportType) { +case ProxyTransportTypeTCP: { +self.proxy = [SDLProxyFactory buildSDLProxyWithListener:self tcpIPAddress:@"192.168.1.1" tcpPort:@"1234"]; +} break; +case ProxyTransportTypeIAP: { +self.proxy = [SDLProxyFactory buildSDLProxyWithListener:self]; +} break; +default: NSAssert(NO, @"Unknown transport setup: %@", @(transportType)); +} +``` + +#### SDLProxyListener + +Note in the following lines, that there is a call to pass a `listener` into the build method. + +```objc +self.proxy = [SDLProxyFactory buildSDLProxyWithListener:self tcpIPAddress:[Preferences sharedPreferences].ipAddress tcpPort:[Preferences sharedPreferences].port] +self.proxy = [SDLProxyFactory buildSDLProxyWithListener:self]; +``` + +This is an object that conforms to the `SDLProxyListener` protocol. This could be the object holding the reference to the proxy, as it is here. + +#### Implement onProxyOpened and other delegate methods +The `SDLProxyListener` protocol has four required methods: + +```objc +- (void)onOnDriverDistraction:(SDLOnDriverDistraction*) notification; +- (void)onOnHMIStatus:(SDLOnHMIStatus*) notification; +- (void)onProxyClosed; +- (void)onProxyOpened; +``` + +`onProxyOpened` is called when a connection is established between the head unit and your application. This is the place to set whatever state you need to, to know that your application is connected. It is also where you must send a register request with your app's information to the vehicle. The example app uses the following basic code: + +```objc +self.state = ProxyStateConnected; + +SDLRegisterAppInterface *registerRequest = [SDLRPCRequestFactory buildRegisterAppInterfaceWithAppName:SDLAppName languageDesired:[SDLLanguage EN_US] appID:SDLAppId]; +[self.proxy sendRPC:registerRequest]; +``` + +When the proxy is closed, you will receive a call to `onProxyClosed`. This is where you will reset the state of the proxy, because remember, when a connection is closed, it is assumed that you will destroy the current proxy. The example app runs a method called `resetProxyWithTransportType:` that runs the following: + +```objc +[self stopProxy]; +[self startProxyWithTransportType:transportType]; +``` + +`stopProxy` does the following: + +```objc +self.state = ProxyStateStopped; + +if (self.proxy != nil) { +[self.proxy dispose]; +self.proxy = nil; +} +``` + +#### onOnHMIStatus +When your app receives `onOnHMIStatus` it has changed HMI states on the head unit. For example, your application can be put into `HMI_FULL` meaning that it has full access to the vehicle screen. For more info on HMI Levels, [see the Cocoadoc documentation on the enum](http://cocoadocs.org/docsets/SmartDeviceLink-iOS/4.0.3/Classes/SDLHMILevel.html). + +You will want to track your first HMI FULL, for instance with a boolean value. The example application has extremely basic tracking of this type in the `onOnHMIStatus` callback. + +```objc +if ((notification.hmiLevel == [SDLHMILevel FULL]) && self.isFirstHMIFull) { +[self showInitialData]; +self.isFirstHMIFull = NO; +} +``` + +#### WiFi vs. iAP + +As described in the section "Creating the SDLProxy", you need will have separate setup for either WiFi (debugging) and iAP (production) code. + +```objc +switch (transportType) { +case ProxyTransportTypeTCP: { +self.proxy = [SDLProxyFactory buildSDLProxyWithListener:self tcpIPAddress:@"192.168.1.1" tcpPort:@"1234"]; +} break; +case ProxyTransportTypeIAP: { +self.proxy = [SDLProxyFactory buildSDLProxyWithListener:self]; +} break; +default: NSAssert(NO, @"Unknown transport setup: %@", @(transportType)); +} +``` + +When creating for WiFi, you will want to know the IP address and port of the Core system you are testing with. With IAP connections, you will use the "build" method without setting an IP and Port, and IAP will automatically be activated. diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m index 0e06aae12..0fe44f31e 100644 --- a/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m +++ b/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m @@ -45,7 +45,7 @@ typedef void (^URLSessionTaskCompletionHandler)(NSData *data, NSURLResponse *response, NSError *error); typedef void (^URLSessionDownloadTaskCompletionHandler)(NSURL *location, NSURLResponse *response, NSError *error); -NSString *const SDLProxyVersion = @"4.1.0"; +NSString *const SDLProxyVersion = @"4.1.1"; const float startSessionTime = 10.0; const float notifyProxyClosedDelay = 0.1; const int POLICIES_CORRELATION_ID = 65535; @@ -69,35 +69,35 @@ - (instancetype)initWithTransport:(SDLAbstractTransport *)transport protocol:(SD _debugConsoleGroupName = @"default"; _lsm = [[SDLLockScreenManager alloc] init]; _alreadyDestructed = NO; - + _mutableProxyListeners = [NSMutableSet setWithObject:theDelegate]; _protocol = protocol; _transport = transport; _transport.delegate = protocol; [_protocol.protocolDelegateTable addObject:self]; _protocol.transport = transport; - + [self.transport connect]; - + [SDLDebugTool logInfo:@"SDLProxy initWithTransport"]; [[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications]; } - + return self; } - (void)destructObjects { if (!_alreadyDestructed) { _alreadyDestructed = YES; - + [[NSNotificationCenter defaultCenter] removeObserver:self]; [[EAAccessoryManager sharedAccessoryManager] unregisterForLocalNotifications]; - + [[SDLURLSession defaultSession] cancelAllTasks]; - + [self.protocol dispose]; [self.transport dispose]; - + _transport = nil; _protocol = nil; _mutableProxyListeners = nil; @@ -108,7 +108,7 @@ - (void)dispose { if (self.transport != nil) { [self.transport disconnect]; } - + [self destructObjects]; } @@ -135,10 +135,10 @@ - (NSSet *)proxyListeners { - (void)sendMobileHMIState { UIApplicationState appState = [UIApplication sharedApplication].applicationState; SDLOnHMIStatus *HMIStatusRPC = [[SDLOnHMIStatus alloc] init]; - + HMIStatusRPC.audioStreamingState = [SDLAudioStreamingState NOT_AUDIBLE]; HMIStatusRPC.systemContext = [SDLSystemContext MAIN]; - + switch (appState) { case UIApplicationStateActive: { HMIStatusRPC.hmiLevel = [SDLHMILevel FULL]; @@ -150,10 +150,10 @@ - (void)sendMobileHMIState { default: break; } - + NSString *log = [NSString stringWithFormat:@"Sending new mobile hmi state: %@", HMIStatusRPC.hmiLevel.value]; [SDLDebugTool logInfo:log withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + [self sendRPC:HMIStatusRPC]; } @@ -169,7 +169,7 @@ - (SDLStreamingMediaManager *)streamingMediaManager { _streamingMediaManager = [[SDLStreamingMediaManager alloc] initWithProtocol:self.protocol]; [self.protocol.protocolDelegateTable addObject:_streamingMediaManager]; } - + return _streamingMediaManager; } @@ -178,9 +178,9 @@ - (SDLStreamingMediaManager *)streamingMediaManager { - (void)onProtocolOpened { _isConnected = YES; [SDLDebugTool logInfo:@"StartSession (request)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + [self.protocol sendStartSessionWithType:SDLServiceType_RPC]; - + if (self.startSessionTimer == nil) { self.startSessionTimer = [[SDLTimer alloc] initWithDuration:startSessionTime repeat:NO]; __weak typeof(self) weakSelf = self; @@ -203,10 +203,10 @@ - (void)onError:(NSString *)info exception:(NSException *)e { - (void)handleProtocolStartSessionACK:(SDLServiceType)serviceType sessionID:(Byte)sessionID version:(Byte)version { // Turn off the timer, the start session response came back [self.startSessionTimer cancel]; - + NSString *logMessage = [NSString stringWithFormat:@"StartSession (response)\nSessionId: %d for serviceType %d", sessionID, serviceType]; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + if (serviceType == SDLServiceType_RPC) { [self invokeMethodOnDelegates:@selector(onProxyOpened) withObject:nil]; } @@ -248,7 +248,7 @@ - (void)handleRPCDictionary:(NSDictionary *)dict { SDLRPCMessage *message = [[SDLRPCMessage alloc] initWithDictionary:[dict mutableCopy]]; NSString *functionName = [message getFunctionName]; NSString *messageType = [message messageType]; - + // If it's a response, append response if ([messageType isEqualToString:NAMES_response]) { BOOL notGenericResponseMessage = ![functionName isEqualToString:@"GenericResponse"]; @@ -256,50 +256,50 @@ - (void)handleRPCDictionary:(NSDictionary *)dict { functionName = [NSString stringWithFormat:@"%@Response", functionName]; } } - + // From the function name, create the corresponding RPCObject and initialize it NSString *functionClassName = [NSString stringWithFormat:@"SDL%@", functionName]; SDLRPCMessage *newMessage = [[NSClassFromString(functionClassName) alloc] initWithDictionary:[dict mutableCopy]]; - + // Log the RPC message NSString *logMessage = [NSString stringWithFormat:@"%@", newMessage]; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + // Intercept and handle several messages ourselves if ([functionName isEqualToString:NAMES_OnAppInterfaceUnregistered] || [functionName isEqualToString:NAMES_UnregisterAppInterface]) { [self handleRPCUnregistered:dict]; } - + if ([functionName isEqualToString:@"RegisterAppInterfaceResponse"]) { [self handleRegisterAppInterfaceResponse:(SDLRPCResponse *)newMessage]; } - + if ([functionName isEqualToString:@"EncodedSyncPDataResponse"]) { [SDLDebugTool logInfo:@"EncodedSyncPData (response)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; } - + if ([functionName isEqualToString:@"OnEncodedSyncPData"]) { [self handleSyncPData:newMessage]; } - + if ([functionName isEqualToString:@"OnSystemRequest"]) { [self handleSystemRequest:dict]; } - + if ([functionName isEqualToString:@"SystemRequestResponse"]) { [self handleSystemRequestResponse:newMessage]; } - + // Formulate the name of the method to call and invoke the method on the delegate(s) NSString *handlerName = [NSString stringWithFormat:@"on%@:", functionName]; SEL handlerSelector = NSSelectorFromString(handlerName); [self invokeMethodOnDelegates:handlerSelector withObject:newMessage]; - + // When an OnHMIStatus notification comes in, after passing it on (above), generate an "OnLockScreenNotification" if ([functionName isEqualToString:@"OnHMIStatus"]) { [self handleAfterHMIStatus:newMessage]; } - + // When an OnDriverDistraction notification comes in, after passing it on (above), generate an "OnLockScreenNotification" if ([functionName isEqualToString:@"OnDriverDistraction"]) { [self handleAfterDriverDistraction:newMessage]; @@ -334,11 +334,11 @@ - (void)handleSyncPData:(SDLRPCMessage *)message { // If URL != nil, perform HTTP Post and don't pass the notification to proxy listeners NSString *logMessage = [NSString stringWithFormat:@"OnEncodedSyncPData (notification)\n%@", message]; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + NSString *urlString = (NSString *)[message getParameters:@"URL"]; NSDictionary *encodedSyncPData = (NSDictionary *)[message getParameters:@"data"]; NSNumber *encodedSyncPTimeout = (NSNumber *)[message getParameters:@"Timeout"]; - + if (urlString && encodedSyncPData && encodedSyncPTimeout) { [self sendEncodedSyncPData:encodedSyncPData toURL:urlString withTimeout:encodedSyncPTimeout]; } @@ -346,10 +346,10 @@ - (void)handleSyncPData:(SDLRPCMessage *)message { - (void)handleSystemRequest:(NSDictionary *)dict { [SDLDebugTool logInfo:@"OnSystemRequest (notification)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + SDLOnSystemRequest *systemRequest = [[SDLOnSystemRequest alloc] initWithDictionary:[dict mutableCopy]]; SDLRequestType *requestType = systemRequest.requestType; - + // Handle the various OnSystemRequest types if (requestType == [SDLRequestType PROPRIETARY]) { [self handleSystemRequestProprietary:systemRequest]; @@ -373,7 +373,7 @@ - (void)handleAfterHMIStatus:(SDLRPCMessage *)message { NSString *statusString = (NSString *)[message getParameters:NAMES_hmiLevel]; SDLHMILevel *hmiLevel = [SDLHMILevel valueOf:statusString]; _lsm.hmiLevel = hmiLevel; - + SEL callbackSelector = NSSelectorFromString(@"onOnLockScreenNotification:"); [self invokeMethodOnDelegates:callbackSelector withObject:_lsm.lockScreenStatusNotification]; } @@ -382,7 +382,7 @@ - (void)handleAfterDriverDistraction:(SDLRPCMessage *)message { NSString *stateString = (NSString *)[message getParameters:NAMES_state]; BOOL state = [stateString isEqualToString:@"DD_ON"] ? YES : NO; _lsm.driverDistracted = state; - + SEL callbackSelector = NSSelectorFromString(@"onOnLockScreenNotification:"); [self invokeMethodOnDelegates:callbackSelector withObject:_lsm.lockScreenStatusNotification]; } @@ -410,11 +410,11 @@ - (void)handleSystemRequestProprietary:(SDLOnSystemRequest *)request { if (JSONDictionary == nil || request.url == nil) { return; } - + NSDictionary *requestData = JSONDictionary[@"HTTPRequest"]; NSString *bodyString = requestData[@"body"]; NSData *bodyData = [bodyString dataUsingEncoding:NSUTF8StringEncoding]; - + // Parse and display the policy data. SDLPolicyDataParser *pdp = [[SDLPolicyDataParser alloc] init]; NSData *policyData = [pdp unwrap:bodyData]; @@ -423,33 +423,33 @@ - (void)handleSystemRequestProprietary:(SDLOnSystemRequest *)request { NSString *logMessage = [NSString stringWithFormat:@"Policy Data from Module\n%@", pdp]; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; } - + // Send the HTTP Request [self uploadForBodyDataDictionary:JSONDictionary URLString:request.url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSString *logMessage = nil; - + if (error) { logMessage = [NSString stringWithFormat:@"OnSystemRequest (HTTP response) = ERROR: %@", error]; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return; } - + if (data == nil || data.length == 0) { [SDLDebugTool logInfo:@"OnSystemRequest (HTTP response) failure: no data returned" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return; } - + // Show the HTTP response [SDLDebugTool logInfo:@"OnSystemRequest (HTTP response)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + // Create the SystemRequest RPC to send to module. SDLSystemRequest *request = [[SDLSystemRequest alloc] init]; request.correlationID = [NSNumber numberWithInt:POLICIES_CORRELATION_ID]; request.requestType = [SDLRequestType PROPRIETARY]; request.bulkData = data; - + // Parse and display the policy data. SDLPolicyDataParser *pdp = [[SDLPolicyDataParser alloc] init]; NSData *policyData = [pdp unwrap:data]; @@ -458,7 +458,7 @@ - (void)handleSystemRequestProprietary:(SDLOnSystemRequest *)request { logMessage = [NSString stringWithFormat:@"Policy Data from Cloud\n%@", pdp]; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; } - + // Send and log RPC Request logMessage = [NSString stringWithFormat:@"SystemRequest (request)\n%@\nData length=%lu", [request serializeAsDictionary:2], (unsigned long)data.length]; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; @@ -474,7 +474,7 @@ - (void)handleSystemRequestLockScreenIconURL:(SDLOnSystemRequest *)request { [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return; } - + UIImage *icon = [UIImage imageWithData:data]; [self invokeMethodOnDelegates:@selector(onReceivedLockScreenIcon:) withObject:icon]; }]; @@ -485,38 +485,38 @@ - (void)sdl_handleSystemRequestHTTP:(SDLOnSystemRequest *)request { // TODO: not sure how we want to handle http requests that don't have bulk data (maybe as GET?) return; } - + [self sdl_uploadData:request.bulkData - toURLString:request.url - completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { - NSString *logMessage = nil; - if (error != nil) { - logMessage = [NSString stringWithFormat:@"OnSystemRequest (HTTP response) = ERROR: %@", error.localizedDescription]; - [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - return; - } - - if (data.length == 0) { - [SDLDebugTool logInfo:@"OnSystemRequest (HTTP response) failure: no data returned" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - return; - } - - // Show the HTTP response - NSString *responseLogString = [NSString stringWithFormat:@"OnSystemRequest (HTTP) response: %@", response]; - [SDLDebugTool logInfo:responseLogString withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - - // Create the SystemRequest RPC to send to module. - SDLPutFile *putFile = [[SDLPutFile alloc] init]; - putFile.fileType = [SDLFileType JSON]; - putFile.correlationID = @(POLICIES_CORRELATION_ID); - putFile.syncFileName = @"response_data"; - putFile.bulkData = data; - - // Send and log RPC Request - logMessage = [NSString stringWithFormat:@"SystemRequest (request)\n%@\nData length=%lu", [request serializeAsDictionary:2], (unsigned long)data.length]; - [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - [self sendRPC:putFile]; - }]; + toURLString:request.url + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + NSString *logMessage = nil; + if (error != nil) { + logMessage = [NSString stringWithFormat:@"OnSystemRequest (HTTP response) = ERROR: %@", error.localizedDescription]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + + if (data.length == 0) { + [SDLDebugTool logInfo:@"OnSystemRequest (HTTP response) failure: no data returned" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + return; + } + + // Show the HTTP response + NSString *responseLogString = [NSString stringWithFormat:@"OnSystemRequest (HTTP) response: %@", response]; + [SDLDebugTool logInfo:responseLogString withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + + // Create the SystemRequest RPC to send to module. + SDLPutFile *putFile = [[SDLPutFile alloc] init]; + putFile.fileType = [SDLFileType JSON]; + putFile.correlationID = @(POLICIES_CORRELATION_ID); + putFile.syncFileName = @"response_data"; + putFile.bulkData = data; + + // Send and log RPC Request + logMessage = [NSString stringWithFormat:@"SystemRequest (request)\n%@\nData length=%lu", [request serializeAsDictionary:2], (unsigned long)data.length]; + [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; + [self sendRPC:putFile]; + }]; } /** @@ -529,18 +529,18 @@ - (void)sdl_handleSystemRequestHTTP:(SDLOnSystemRequest *)request { - (NSDictionary *)validateAndParseSystemRequest:(SDLOnSystemRequest *)request { NSString *urlString = request.url; SDLFileType *fileType = request.fileType; - + // Validate input if (urlString == nil || [NSURL URLWithString:urlString] == nil) { [SDLDebugTool logInfo:@"OnSystemRequest (notification) failure: url is nil" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return nil; } - + if (fileType != [SDLFileType JSON]) { [SDLDebugTool logInfo:@"OnSystemRequest (notification) failure: file type is not JSON" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return nil; } - + // Get data dictionary from the bulkData NSError *error = nil; NSDictionary *JSONDictionary = [NSJSONSerialization JSONObjectWithData:request.bulkData options:kNilOptions error:&error]; @@ -548,7 +548,7 @@ - (NSDictionary *)validateAndParseSystemRequest:(SDLOnSystemRequest *)request { [SDLDebugTool logInfo:@"OnSystemRequest failure: notification data is not valid JSON." withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return nil; } - + return JSONDictionary; } @@ -565,11 +565,11 @@ - (void)sdl_uploadData:(NSData *_Nonnull)data toURLString:(NSString *_Nonnull)ur NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setValue:@"application/json" forHTTPHeaderField:@"content-type"]; request.HTTPMethod = @"POST"; - + // Logging NSString *logMessage = [NSString stringWithFormat:@"OnSystemRequest (HTTP Request) to URL %@", urlString]; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + // Create the upload task [[SDLURLSession defaultSession] uploadWithURLRequest:request data:data completionHandler:completionHandler]; } @@ -585,7 +585,7 @@ - (void)uploadForBodyDataDictionary:(NSDictionary *)dictionary URLString:(NSStri NSParameterAssert(dictionary != nil); NSParameterAssert(urlString != nil); NSParameterAssert(completionHandler != NULL); - + // Extract data from the dictionary NSDictionary *requestData = dictionary[@"HTTPRequest"]; NSDictionary *headers = requestData[@"headers"]; @@ -594,18 +594,18 @@ - (void)uploadForBodyDataDictionary:(NSDictionary *)dictionary URLString:(NSStri NSString *method = headers[@"RequestMethod"]; NSString *bodyString = requestData[@"body"]; NSData *bodyData = [bodyString dataUsingEncoding:NSUTF8StringEncoding]; - + // NSURLRequest configuration NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setValue:contentType forHTTPHeaderField:@"content-type"]; request.timeoutInterval = timeout; request.HTTPMethod = method; - + // Logging NSString *logMessage = [NSString stringWithFormat:@"OnSystemRequest (HTTP Request) to URL %@", urlString]; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + // Create the upload task [[SDLURLSession defaultSession] uploadWithURLRequest:request data:bodyData completionHandler:completionHandler]; } @@ -648,7 +648,7 @@ - (void)sendEncodedSyncPData:(NSDictionary *)encodedSyncPData toURL:(NSString *) request.HTTPMethod = @"POST"; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; request.timeoutInterval = 60; - + // Prepare the data in the required format NSString *encodedSyncPDataString = [[NSString stringWithFormat:@"%@", encodedSyncPData] componentsSeparatedByString:@"\""][1]; NSArray *array = [NSArray arrayWithObject:encodedSyncPDataString]; @@ -660,14 +660,14 @@ - (void)sendEncodedSyncPData:(NSDictionary *)encodedSyncPData toURL:(NSString *) [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return; } - + // Send the HTTP Request [[SDLURLSession defaultSession] uploadWithURLRequest:request data:data completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { [self syncPDataNetworkRequestCompleteWithData:data response:response error:error]; }]; - + [SDLDebugTool logInfo:@"OnEncodedSyncPData (HTTP request)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; } @@ -675,13 +675,13 @@ - (void)sendEncodedSyncPData:(NSDictionary *)encodedSyncPData toURL:(NSString *) - (void)syncPDataNetworkRequestCompleteWithData:(NSData *)data response:(NSURLResponse *)response error:(NSError *)error { // Sample of response: {"data":["SDLKGLSDKFJLKSjdslkfjslkJLKDSGLKSDJFLKSDJF"]} [SDLDebugTool logInfo:@"OnEncodedSyncPData (HTTP response)" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; - + // Validate response data. if (data == nil || data.length == 0) { [SDLDebugTool logInfo:@"OnEncodedSyncPData (HTTP response) failure: no data returned" withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; return; } - + // Convert data to RPCRequest NSError *JSONConversionError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&JSONConversionError]; @@ -689,7 +689,7 @@ - (void)syncPDataNetworkRequestCompleteWithData:(NSData *)data response:(NSURLRe SDLEncodedSyncPData *request = [[SDLEncodedSyncPData alloc] init]; request.correlationID = [NSNumber numberWithInt:POLICIES_CORRELATION_ID]; request.data = [responseDictionary objectForKey:@"data"]; - + [self sendRPC:request]; } } @@ -700,7 +700,7 @@ - (void)putFileStream:(NSInputStream *)inputStream withRequest:(SDLPutFile *)put inputStream.delegate = self; objc_setAssociatedObject(inputStream, @"SDLPutFile", putFileRPCRequest, OBJC_ASSOCIATION_RETAIN); objc_setAssociatedObject(inputStream, @"BaseOffset", [putFileRPCRequest offset], OBJC_ASSOCIATION_RETAIN); - + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [inputStream open]; } @@ -710,29 +710,29 @@ - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode { case NSStreamEventHasBytesAvailable: { // Grab some bytes from the stream and send them in a SDLPutFile RPC Request NSUInteger currentStreamOffset = [[stream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedIntegerValue]; - + NSMutableData *buffer = [NSMutableData dataWithLength:[SDLGlobals globals].maxMTUSize]; NSUInteger nBytesRead = [(NSInputStream *)stream read:(uint8_t *)buffer.mutableBytes maxLength:buffer.length]; if (nBytesRead > 0) { NSData *data = [buffer subdataWithRange:NSMakeRange(0, nBytesRead)]; NSUInteger baseOffset = [(NSNumber *)objc_getAssociatedObject(stream, @"BaseOffset") unsignedIntegerValue]; NSUInteger newOffset = baseOffset + currentStreamOffset; - + SDLPutFile *putFileRPCRequest = (SDLPutFile *)objc_getAssociatedObject(stream, @"SDLPutFile"); [putFileRPCRequest setOffset:[NSNumber numberWithUnsignedInteger:newOffset]]; [putFileRPCRequest setLength:[NSNumber numberWithUnsignedInteger:nBytesRead]]; [putFileRPCRequest setBulkData:data]; - + [self sendRPC:putFileRPCRequest]; } - + break; } case NSStreamEventEndEncountered: { // Cleanup the stream [stream close]; [stream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - + break; } case NSStreamEventErrorOccurred: { diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/SmartDeviceLink-iOS.podspec b/SmartDeviceLink-iOS/SmartDeviceLink/SmartDeviceLink-iOS.podspec new file mode 100644 index 000000000..1dd33ae57 --- /dev/null +++ b/SmartDeviceLink-iOS/SmartDeviceLink/SmartDeviceLink-iOS.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |s| + +s.name = "SmartDeviceLink-iOS" +s.version = "4.1.1" +s.summary = "Connect your app with cars!" +s.homepage = "https://github.com/smartdevicelink/SmartDeviceLink-iOS" +s.license = { :type => "New BSD", :file => "LICENSE" } +s.author = { "SmartDeviceLink Team" => "joel@livio.io" } +s.platform = :ios, "6.0" +s.source = { :git => "https://github.com/smartdevicelink/sdl_ios.git", :tag => s.version.to_s } +s.source_files = "SmartDeviceLink-iOS/SmartDeviceLink/*.{h,m}" +s.requires_arc = true + +end