Skip to content
This repository was archived by the owner on Nov 24, 2020. It is now read-only.

Commit d81689e

Browse files
author
Fabricio Carvalhal
committed
public modifiers needed for modularized apps on target ios
1 parent 9ff9289 commit d81689e

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/target/swift.cr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ abstract class SwiftTarget < Target
5555

5656
def generate_struct_type(t)
5757
String.build do |io|
58-
io << "class #{t.name}: Codable {\n"
58+
io << "public class #{t.name}: Codable {\n"
5959
t.fields.each do |field|
60-
io << ident "var #{field.name}: #{native_type field.type}\n"
60+
io << ident "public var #{field.name}: #{native_type field.type}\n"
6161
end
62-
io << ident "\nvar copy: #{t.name} {\n"
62+
io << ident "\npublic var copy: #{t.name} {\n"
6363
io << ident ident "return #{t.name}(\n"
6464
io << ident ident ident t.fields.map { |field| "#{field.name}: #{generate_property_copy(field.type, field.name)}" }.join(",\n")
6565
io << ident ident "\n)\n"
@@ -74,7 +74,7 @@ abstract class SwiftTarget < Target
7474
io << ident <<-END
7575
7676
77-
init() {
77+
public init() {
7878
7979
END
8080
t.fields.each do |field|
@@ -83,7 +83,7 @@ END
8383
io << ident <<-END
8484
}
8585
86-
init(#{t.fields.map { |f| "#{f.name}: #{native_type f.type}" }.join(", ")}) {
86+
public init(#{t.fields.map { |f| "#{f.name}: #{native_type f.type}" }.join(", ")}) {
8787
8888
END
8989
t.fields.each do |field|
@@ -92,7 +92,7 @@ END
9292
io << ident <<-END
9393
}
9494
95-
init(json: [String: Any]) throws {
95+
public init(json: [String: Any]) throws {
9696
let jsonData = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted)
9797
let decodedSelf = try decoder.decode(#{t.name}.self, from: jsonData)\n
9898
@@ -103,7 +103,7 @@ END
103103
io << ident <<-END
104104
}
105105
106-
func toJSON() -> [String: Any] {
106+
public func toJSON() -> [String: Any] {
107107
var json = [String: Any]()
108108
109109
END
@@ -122,9 +122,9 @@ END
122122
def generate_enum_type(t)
123123
String.build do |io|
124124
if t.name == "ErrorType"
125-
io << "enum #{t.name}: String, Error, Codable {\n"
125+
io << "public enum #{t.name}: String, Error, Codable {\n"
126126
else
127-
io << "enum #{t.name}: String, CaseIterable, DisplayableValue, Codable {\n"
127+
io << "public enum #{t.name}: String, CaseIterable, DisplayableValue, Codable {\n"
128128
end
129129

130130
t.values.each do |value|
@@ -142,7 +142,7 @@ END
142142
io << ident ident "return dictionary\n"
143143
io << ident "}\n"
144144

145-
io << ident "\nstatic func allDisplayableValues() -> [String] {\n"
145+
io << ident "\npublic static func allDisplayableValues() -> [String] {\n"
146146
io << ident ident "var displayableValues: [String] = []\n"
147147
io << ident ident "for enumCase in self.allCases {\n"
148148
io << ident ident ident "displayableValues.append(enumCase.displayableValue)\n"

src/target/swift_ios.cr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class SwiftIosTarget < SwiftTarget
66
import Alamofire
77
import KeychainSwift
88
9-
protocol ApiCallsLogic: class {\n
9+
public protocol ApiCallsLogic: class {\n
1010
END
1111

1212
@ast.operations.each do |op|
@@ -24,18 +24,18 @@ END
2424
@io << "}\n\n" # CloseAPICallsProtocol
2525
@io << <<-END
2626
27-
class API {
28-
static var customUrl: String?
29-
static var useStaging = false
30-
static var globalCallback: (_ method: String, _ result: ApiInternal.Result<Any?>, _ callback: ((ApiInternal.Result<Any?>) -> Void)?) -> Void = { _, result, callback in
27+
public class API {
28+
public static var customUrl: String?
29+
public static var useStaging = false
30+
public static var globalCallback: (_ method: String, _ result: ApiInternal.Result<Any?>, _ callback: ((ApiInternal.Result<Any?>) -> Void)?) -> Void = { _, result, callback in
3131
callback?(result)
3232
}
3333
34-
static var isEnabledAssertion = true
35-
static var calls: ApiCallsLogic = Calls()
36-
static var apiInternal = ApiInternal()
34+
public static var isEnabledAssertion = true
35+
public static var calls: ApiCallsLogic = Calls()
36+
public static var apiInternal = ApiInternal()
3737
38-
static var decoder: JSONDecoder = {
38+
public static var decoder: JSONDecoder = {
3939
let currentDecoder = JSONDecoder()
4040
currentDecoder.dateDecodingStrategy = .custom({ (decoder) -> Date in
4141
let container = try decoder.singleValueContainer()
@@ -54,7 +54,7 @@ class API {
5454
}()
5555
5656
// MARK: Struct and Enums
57-
struct NoReply: Codable {}\n\n
57+
public struct NoReply: Codable {}\n\n
5858
END
5959
# ApiCalls
6060
@io << ident(String.build do |io|
@@ -102,20 +102,20 @@ END
102102

103103
@io << <<-END
104104
105-
class ApiInternal {
105+
public class ApiInternal {
106106
var baseUrl = #{@ast.options.url.inspect}
107107
108108
// MARK: ApiInternal Inner classes
109-
enum Result<T> {
109+
public enum Result<T> {
110110
case success(T)
111111
case failure(Error)
112112
}
113113
114-
class Error: Codable {
114+
public class Error: Codable {
115115
var type: API.ErrorType
116116
var message: String
117117
118-
init(type: API.ErrorType, message: String) {
118+
public init(type: API.ErrorType, message: String) {
119119
self.type = type
120120
self.message = message
121121
}
@@ -299,11 +299,11 @@ END
299299
}
300300
}
301301
}
302-
protocol DisplayableValue: RawRepresentable {
302+
public protocol DisplayableValue: RawRepresentable {
303303
var displayableValue: String { get }
304304
}
305305
306-
extension DisplayableValue where RawValue == String {
306+
public extension DisplayableValue where RawValue == String {
307307
var displayableValue: String {
308308
return self.rawValue
309309
}

0 commit comments

Comments
 (0)