wtapack 1.0.4 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 413f8bf6f6637084f59551cd1ec7a35cf2d1a28b
4
- data.tar.gz: c64eb0a95247d0fc1f137897b7ef333d8bbd27c7
3
+ metadata.gz: 5d9b012148ea0c5a46df2805c6d1b8cc783a050b
4
+ data.tar.gz: c82ea92f569f99efce65360351c1aa0eff102142
5
5
  SHA512:
6
- metadata.gz: 4cbb05c8a39e23ada0922b94ce43a70d1e075c16426667d0c66a8d5123754f3a9ff8943567d6407c2dcea35c6f858edc263270d85989331d0e7c7c95af772d09
7
- data.tar.gz: 95683b033d7691d413d2cc200f97d47e86e24ffa8067ad7d1c4c671c2acfb1422f1ab35dc9223030085f18756009aa449fe7066fe9a6509d48fdfbae444bacaf
6
+ metadata.gz: 620e12d8db481ee3f55341068ea08b12dbe14e356e8b584d69a54af52f79e6f21b4d11bce52c9250c8c3cc993f7987aa0926f0e0679e3d24a13b6a14b6b5ea89
7
+ data.tar.gz: 2d7d24c38bd6fa7610942c2627e1c3d2542c12b99fa4f830547e10adf676a0012fdace5a5e6959d0ec078a43ad36325e23e9ea18e33948a57606e35639786ba4
@@ -9,6 +9,8 @@
9
9
  @import Foundation;
10
10
 
11
11
  @interface PlistManager : NSObject
12
+ @property (strong, nonatomic, readonly) NSString* binaryName;
13
+
12
14
  - (void)updateBundleID:(NSString*)newBundleID;
13
15
  - (void)updateDisplayName:(NSString*)displayName;
14
16
 
@@ -88,4 +88,9 @@
88
88
  }
89
89
  }
90
90
  }
91
+
92
+ - (NSString*)binaryName
93
+ {
94
+ return self.infoPlist[@"CFBundleExecutable"];
95
+ }
91
96
  @end
@@ -15,4 +15,5 @@
15
15
 
16
16
  - (void)replaceProfile;
17
17
  - (void)replaceEntitlements;
18
+
18
19
  @end
data/ext/wtapack/main.m CHANGED
@@ -12,6 +12,10 @@
12
12
  #import "NSArray+WTAMap.h"
13
13
  #import "ErrorHandler.h"
14
14
  #import "PlistManager.h"
15
+ #import <sys/types.h>
16
+ #import <unistd.h>
17
+ #import <grp.h>
18
+ #import <pwd.h>
15
19
  #ifndef WTA_STANDALONE
16
20
  #import <ruby.h>
17
21
  #endif
@@ -22,6 +26,8 @@ static NSString* const usageString = @"Usage: %s -input <path to original .app>
22
26
  [-<extension name> <extension provisioning profile UUID> ...] -output <path to output ipa>";
23
27
 
24
28
  void showUsageAndExit(void);
29
+ void stripBinary(NSURL* binaryURL);
30
+ void setOwnership(NSURL* bundleURL);
25
31
 
26
32
  #ifndef WTA_STANDALONE
27
33
  VALUE rb_main(int argc, const char * argv[]) {
@@ -149,11 +155,16 @@ int main(int argc, const char* argv[]) {
149
155
  [appPlistManager updateDisplayName:newDisplayName];
150
156
  }
151
157
 
158
+ NSString* binaryName = appPlistManager.binaryName;
159
+
152
160
  [appPlistManager commit];
153
161
 
154
162
  [mainProfileManager replaceEntitlements];
155
163
 
156
164
  [mainProfileManager replaceProfile];
165
+
166
+ setOwnership(destApp);
167
+ system([NSString stringWithFormat:@"/bin/chmod -RH u+w,go-w,a+rX \"%s\"", destApp.path.fileSystemRepresentation].UTF8String);
157
168
 
158
169
  // Extensions handling starts here
159
170
  NSString* extensionsString = [standardDefaults stringForKey:@"extensions"];
@@ -187,6 +198,10 @@ int main(int argc, const char* argv[]) {
187
198
  [extensionProfileManager replaceEntitlements];
188
199
 
189
200
  [extensionProfileManager replaceProfile];
201
+
202
+ // strip binary
203
+ NSURL* binaryURL = [extensionURL URLByAppendingPathComponent:extension];
204
+ stripBinary(binaryURL);
190
205
 
191
206
  // Code signing
192
207
  [CodeSigner signBinary:extensionURL];
@@ -200,14 +215,42 @@ int main(int argc, const char* argv[]) {
200
215
  options:NSDirectoryEnumerationSkipsHiddenFiles
201
216
  error:NULL];
202
217
 
218
+ // Check to see if the Swift libs are included
219
+ NSArray* swiftLibs = [frameworks filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF.path CONTAINS %@", @"libswift"]];
220
+
221
+ if (swiftLibs.count)
222
+ {
223
+ NSURL* swiftSupportURL = [tmpDirURL URLByAppendingPathComponent:@"SwiftSupport"];
224
+ [fm createDirectoryAtURL:swiftSupportURL withIntermediateDirectories:YES attributes:nil error:NULL];
225
+ for (NSURL* lib in swiftLibs)
226
+ {
227
+ [fm copyItemAtURL:lib toURL:[swiftSupportURL URLByAppendingPathComponent:lib.lastPathComponent] error:NULL];
228
+ }
229
+
230
+ setOwnership(swiftSupportURL);
231
+ }
232
+
203
233
  dispatch_apply(frameworks.count,
204
234
  dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
205
235
  0),
206
236
  ^(size_t i) {
207
237
  // Embedded Frameworks don't need a provisioning profile
208
238
  [fm removeItemAtURL:[frameworks[i] URLByAppendingPathComponent:@"embedded.mobileprovision"] error: NULL];
239
+
240
+ NSRange frameRange = [[frameworks[i] lastPathComponent] rangeOfString:@".framework"];
241
+ if (frameRange.location != NSNotFound)
242
+ {
243
+ NSLog(@"%@", [frameworks[i] path]);
244
+ NSString* frameworkBinaryName = [[frameworks[i] lastPathComponent] substringWithRange:NSMakeRange(0, frameRange.location)];
245
+ NSURL* binaryURL = [frameworks[i] URLByAppendingPathComponent:frameworkBinaryName];
246
+ stripBinary(binaryURL);
247
+ }
248
+
209
249
  [CodeSigner signFramework:frameworks[i]];
210
250
  });
251
+
252
+ NSURL* binaryURL = [destApp URLByAppendingPathComponent:binaryName];
253
+ stripBinary(binaryURL);
211
254
 
212
255
  // Finally sign whole app.
213
256
  [CodeSigner signBinary:destApp];
@@ -249,6 +292,21 @@ void showUsageAndExit(void)
249
292
  [ErrorHandler fatalErrorWithMessage:[NSString stringWithFormat:usageString, [[NSProcessInfo processInfo].arguments.firstObject UTF8String]]
250
293
  exitCode:EX_USAGE];
251
294
  }
295
+
296
+ void stripBinary(NSURL* binaryURL)
297
+ {
298
+ NSString* stripCommand = [NSString stringWithFormat:@"/usr/bin/strip -x \"%s\"", binaryURL.path.fileSystemRepresentation];
299
+ system(stripCommand.UTF8String);
300
+ }
301
+
302
+ void setOwnership(NSURL* bundleURL)
303
+ {
304
+ uid_t currentUID = getuid();
305
+ gid_t currentGID = getgid();
306
+
307
+ NSString* chownCommand = [NSString stringWithFormat:@"/usr/sbin/chown -RH %@:%@ \"%s\"", @(currentUID), @(currentGID), bundleURL.path.fileSystemRepresentation];
308
+ system(chownCommand.UTF8String);
309
+ }
252
310
  // This is left here for historical interest, in case anyone wants to know how to do this.
253
311
  //NSMutableDictionary* readRawEntitlements(NSURL* rawEntitlementsPath)
254
312
  //{
data/lib/wtapack.rb CHANGED
@@ -30,7 +30,6 @@ module Wtapack
30
30
  # end
31
31
 
32
32
  argc = argv.count
33
-
34
33
  Wtapack::native_pack(argc, argv)
35
34
  end
36
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wtapack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Thompson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-29 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler